Help with mixed model in R I'm trying to apply regression on my data and I would like to be sure to do it correctly.
My dependent variable (DV) is the position of the subject (numeric value).
My independent variables (IV) are :


*

*The group in which the subject is (2 groups, a subject is in one or the other)

*The type of stimulus (2 different types, each subject is confronted with each stimulus so it is a "within" variable)

*The time of the measure (each subject got measured 3 times for each stimulus, so 6 times in total)
I'm interested in each principal effect and the triple interaction (not the doubles).


If I'm correct, I have 1 between-subject IV (the group) and 2 within-subject crossed IV (stim and time).
My dataframe counts 6 columns:


*

*The NS column gives the number of the subject.

*The Pos column which gives the subject's position

*The Group column

*The Stim column (the type of stimulus).

*The Time column (the moment of measurement; coded -0.5, 0 and 0.5)


Here is the code I ran in R :
RegAlc <- lmer(Pos ~ Group + Time + Stim + Group:Time:Task +
                     (Time*Stim|NS), data = d)
summary(RegAlc)

The code works but I would like to be sure that this is the correct way to analyze these data.
Thank you very much!
 A: It is not clear whether the Pos outcome variable is a continuous random variable, resulting in error terms having the normal distribution. Note that this is an assumption behind the linear mixed model you are fitting with lmer().
Regarding the structure of the model,


*

*You have included the main effects of Group, Time and Stim, and their three-way interaction, without including the two-way interactions. Typically, this is not done. Moreover, interaction terms are complex terms requiring sufficiently large sample size to estimate them stably. This holds for two-way interactions, and even more for three-way ones. Are you certain that you want to include all these interaction terms?

*The random-effects part is often build using a build-up approach, starting from random intercepts, i.e., (1 | NS), then including random slopes, i.e., (Time | NS), and performing a likelihood ratio test (using the anova() function) to see if the fit of the model is improved. You could continue to include more complex random-effects terms. But note that often the dependencies in the data are not that complex to support including many/complex random-effects terms. Trying to fit a mixed model with such a complex structure may result in unstable estimated and boundary problems (i.e., the same variances of the random effects are estimated to be zero).

