0
votes

I am new to mixed model analysis. Can somebody help me to get things clear?

I have the follwoing repeated measurement design: pre test - intervention - post test.

Varaibles: Go_rt - reaction time. pre_post - categorical variable (pre-test;post-test) expectation - participants expectations.

I have the follwoing R code where I want apply mixed model to evalute wether reaction time is statistically different (pre-test vs post test). Plus I want to whether there is interction with effect with participants expectations.

mod <- lmer(Go_rt ~ pre_post +expectations + pre_post:expectations + (1|participant), data=data, REML=FALSE)

What I doubt about is whether the pre_post variable has to be specified in the random part. So the code will look like this:

mod1 <- lmer(Go_rt ~ pre_post +expectations + pre_post:expectations + (1+ pre_post|participant), data=data, REML=FALSE)

And what will it change if I change it like this?

mod2 <- lmer(Go_rt ~ pre_post +expectations + pre_post:expectations + (1|participant) + (1|pre_post), data=data, REML=FALSE)

Actually the mod2 give me significant results for interaciton effect whereas mod & mod1 does not.

2

2 Answers

0
votes

If I am understanding your question correctly, you do not want to have a random intercept for your treatment (pre/post). This is not some noise that you wish to account for, but your experimental question, so mod2 is out. Also, you really shouldn't have a random effect that only has two levels (https://dynamicecology.wordpress.com/2015/11/04/is-it-a-fixed-or-random-effect/).

Pre-test should be the reference level of the factor, so that you can easily interpret what effect your treatment had on reaction time. You can change that by modifying the following code to your data:

data$pre_post = relevel(data$pre_post, ref="pre")

For reaction time, it's also convention in many disciplines to model log reaction time, this can easily be done by putting it in the model formula, which I have done below. If this is not the case in your field, feel free to disregard this.

It's also possible that expectations affects your participants differently, so you could also add a random slope for expectations by participant. First, I would test if the first random slope, pre_post, leads to a significantly better model fit. I would do that with the following code. Note that REML has been changed to true because you are comparing random effects now.

mod1 <- lmer(log(Go_rt) ~ pre_post + expectations + pre_post:expectations + (1|participant), data=data, REML=TRUE)

mod1.1 <- lmer(log(Go_rt) ~ pre_post + expectations + (1 + pre_post|participant), data=data, REML=TRUE)
anova(mod1, mod1.1)

If it does lead to a better model, I would leave it in. Then I would test whether or not a random slope for expectations improves the model.

mod1.2 <- lmer(log(Go_rt) ~ pre_post + expectations + (1 + pre_post + expectations|participant), data=data, REML=TRUE)
anova(mod1.1, mod1.2)

After I had found the best random effects structure, I would look at the fixed-effects, beginning with the interaction, and see if it was significant in the likelihood ratio test, again using the anova() function.

I hope this helps. There are other ways of looking at random effects, and seeing whether or not they are warranted or not using the rePCA() function included in lme4. It is probably a good idea to look into this paper if you are fitting mixed models: https://arxiv.org/pdf/1506.04967.pdf

0
votes

It isn't exactly clear what you are asking, it seems that you are unsure of what you should be modelling, which is a statistical question and may be more appropriate on Cross Validated, but it also seems that you are unsure about R (or rather the package lme4) syntax.

Check out this https://arxiv.org/pdf/1406.5823.pdf comprehensive guide to using lme4, specifically page 6 will be helpful for understanding random effects syntax. From that document:

"Each random-effects term is of the form (expr|factor). The expression expr is evaluated as a linear model formula, producing a model matrix following the same rules used in standard R modelling functions (e.g., lm or glm). The expression factor is evaluated as an R factor"

When you have RE terms specified like this: (1|participant) + (1|pre_post) that means that the RE are crossed (see PeerJ paper below), whereas pre_post + (1+ pre_post|participant) is a correlated intercept and slope (see page 6 in link above).

I agree with @sjp that you don't want to use a random effect for something with only two levels. This paper, which is a wonderful introduction to mixed models, suggests that you should have at least 5 levels: https://peerj.com/articles/4794/

An alternative to @sjp suggestion of log transforming data that might work for trial time data is to use the glmer() function with a family=gamma argument, but either way it is good to inspect residual plots for model fits http://www.sthda.com/english/articles/39-regression-model-diagnostics/161-linear-regression-assumptions-and-diagnostics-in-r-essentials/.

In the case that you don't actually need a random effects term, then the base R functions lm and glm will replace lmer and glmer respectively.