Dear r helpers, I would like to look at the interaction between two two-level factors, one between and one within participants, after accounting for any variance due to practice (31 trials in each of two blocks) in the task. It seems to require treating practice as a covariate. All the examples I noticed for handling covariates (i.e. ANCOVA, including the ones in Faraway's "Practical regression and anova using r") use lm(), but this doesn't handle repeated-measures. I thought of a solution in the form of first running a regression on the covariate:> cov.accnt = lm (myMeasure ~ myCovMeasure, data=dat)and then run the aov() on the residuals:> m.aov = aov (cov.accnt$residuals ~ withinVar*betweenVar +Error(subj/withinVar, data=dat) Does it seem to be a valid answer to my problem? Is there an existing function that can do this (perhaps more appropriately)? Thank you for any help, dror [[alternative HTML version deleted]]
David Winsemius
2010-Dec-26 13:59 UTC
[R] Doing a mixed-ANOVA after accounting for a covariate
On Dec 26, 2010, at 7:42 AM, Dror D Lev wrote:> Dear r helpers, > > I would like to look at the interaction between two two-level > factors, one > between and one within participants, after accounting for any > variance due > to practice (31 trials in each of two blocks) in the task. > It seems to require treating practice as a covariate. > > All the examples I noticed for handling covariates (i.e. ANCOVA, > including > the ones in Faraway's "Practical regression and anova using r") use > lm(), > but this doesn't handle repeated-measures.See if Dalgaard's piece in R-News offers better guidance: http://www.r-project.org/doc/Rnews/Rnews_2007-2.pdf> > I thought of a solution in the form of first running a regression on > the > covariate: >> cov.accnt = lm (myMeasure ~ myCovMeasure, data=dat) > > and then run the aov() on the residuals: >> m.aov = aov (cov.accnt$residuals ~ withinVar*betweenVar + > Error(subj/withinVar, data=dat) > > Does it seem to be a valid answer to my problem? > > Is there an existing function that can do this (perhaps more > appropriately)? > > Thank you for any help, > dror-- David Winsemius, MD West Hartford, CT
RICHARD M. HEIBERGER
2010-Dec-26 19:45 UTC
[R] Doing a mixed-ANOVA after accounting for a covariate
Dror, Please look at the demo(MMC.apple) in the HH package install.packages("HH") ## if you don't already have it. library(HH) demo(MMC.apple) Please reply to the list if there are further queries. Rich On Sun, Dec 26, 2010 at 7:42 AM, Dror D Lev <dror.teach@gmail.com> wrote:> Dear r helpers, > > I would like to look at the interaction between two two-level factors, one > between and one within participants, after accounting for any variance due > to practice (31 trials in each of two blocks) in the task. > It seems to require treating practice as a covariate. > > All the examples I noticed for handling covariates (i.e. ANCOVA, including > the ones in Faraway's "Practical regression and anova using r") use lm(), > but this doesn't handle repeated-measures. > > I thought of a solution in the form of first running a regression on the > covariate: > > cov.accnt = lm (myMeasure ~ myCovMeasure, data=dat) > > and then run the aov() on the residuals: > > m.aov = aov (cov.accnt$residuals ~ withinVar*betweenVar + > Error(subj/withinVar, data=dat) > > Does it seem to be a valid answer to my problem? > > Is there an existing function that can do this (perhaps more > appropriately)? > > Thank you for any help, > dror > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]