Jakub Szewczyk
2013-Nov-16 16:45 UTC
[R] repeated-measures multiple regression/ANCOVA/MANCOVA
Dear List, I am trying to analyze a dataset where I have 1 continuous between-item variable (C), and 2 factorial within-item variables (3- and 2-level: F3, F2). I'm interested in whether slope of C is different from 0 at different combinations of F3 and F2, and whether it varies between these combinations. And unfortunately I need a decent anova-like table with p-values. The reason is that 1) this analysis is going to be repeated 9 times for different parts of the data (not comparable), so such an omnibus table will give a good overview of which places need a follow up with simpler models; 2) this is the norm in my field of reseach, although usually with factorial variables only. I'm wondering how to do it properly in R without falling into any pitfalls, avoiding violations of any assumptions (like sphericity) and what is the most apropriate type of sum of squares for this analysis. The 2 solutions I found so far are: based on nlme::lme():> res.lme = nlme::lme(data=d, y ~ C * F3 * F2, random = ~ 1|item/F3/F2) > anova(res.lme) for type I SS > Anova(res.lme, type="II/III") # for type II/III SSbased on lmerTest package:> res.lmertest = lmerTest::lmer(data=d, y ~ C * F3 * F2 + (1|item)) > anova(res.lmertest) # for type III SSI also considered running repeated-measures ANCOVA using aov() with nested error terms, but that wouldn't protect me against sphericity assumption violations. I also considered using car::Anova() for running a repeated-measures MANCOVA analysis, but if I got this thread right (http://thread.gmane.org/gmane.comp.lang.r.general/270271/focus=270275), this is (at present) not possible to do. Are these ways of analyzing data valid? Concerning the type of SS: I tried to read all discussions in this list on this topic. If I got it right, since I'm interested in interactions of C with other factors in the first place, in my case using SS type III would make sense - is this a good logic? Many thanks for help, Jakub
Michael Friendly
2013-Nov-17 15:22 UTC
[R] repeated-measures multiple regression/ANCOVA/MANCOVA
On 11/16/2013 11:45 AM, Jakub Szewczyk wrote:> I am trying to analyze a dataset where I have 1 continuous > between-item variable (C), and 2 factorial within-item variables (3- > and 2-level: F3, F2). I'm interested in whether slope of C is > different from 0 at different combinations of F3 and F2, and whether > it varies between these combinations.[snip]> I also considered using car::Anova() for running a repeated-measures > MANCOVA analysis, but if I got this thread right > (http://thread.gmane.org/gmane.comp.lang.r.general/270271/focus=270275), > this is (at present) not possible to do. > > Are these ways of analyzing data valid?AFAICS, you do not have a time-varying covariate, so a repeated measures Anova() should work. You can probably test your hypotheses using car::linearHypothesis on the parameters in C:F2, C:F3. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA