What is the difference between Matlab Anovan and R mixed Model?
Gordon, Joanne <jcgordon at ...> writes:
Dear all,
I would really like to perform a linear mixed effects model in R but have limited maths and computational skill. I have a matlab Anovan function that does the job but I like doing basic things in R and would like to try the analysis there.
I believe my data is unbalanced and that I would like to perform a crossed analysis (if my self teaching is correct). My dependent variable ( A) is continuous. I then have three independent categorical variables (B, C- fixed) (D= random) My random variable pertains to 'Individual'.
so D is 'individual'?
Several people have advised my that the main important thing is that I have included the effects of the random factor interactions with the other fixed factors- for example the advice was "try adding the first level interaction terms? Of particular importance is the interaction between the fixed effect and random effect (BirdNo), because the correct calculation of the F-statistic for a mixed model should be the MSE of the fixed effect (e.g. A) over the MSE for the interaction term (e.g. A*D). It looks like R doesn't automatically do this if the model doesn't include the interaction terms."
see e.g. Schielzeth and Nakagawa _Methods in Ecology and Evolution_ on this topic.
And someone who uses R suggested: lmer(A ~ B + C + (1|D), data=emgDat) lmer(A ~ B + C + (1|D) + (1|D*B*C),data=emgDat)
I think you want lmer(A ~ B*C + (B*C|D), data=emgDat) **BUT** this only makes sense if the treatments B and C vary within individuals, or at least within some individuals. Otherwise you can't estimate the interaction between B and C (and their interaction) and D , which is what that last term does ... Hope that helps.