Jordan Ramsey
2012-Jul-09 19:06 UTC
[R] Type II ANOVA for user-defined contrasts with covariates
I'm wondering if anyone would be able to help me out. I'm trying to use a type II ANOVA for a model with user-specified contrasts and covariates. I have two treatment groups and a control group. I'm comparing average treatment to controls and also between the two treatment groups, but I'm also looking to adjust for age and gender as covariates: contrastMat=cbind(c(-1,-1,2),c(1,-1,0)) contrasts(groups)=contrastMat Model=lm(Response~Age+Gender+Age:Gender+groups) since I'm interested in SS(R | A,G,AG) I was hoping then to use the Anova() function in the car() package to find the type II ANOVA for my specified contrasts, but when I do so it only looks at Response as a whole instead of the two contrasts. Any ideas where I'm going wrong? Thanks, JR [[alternative HTML version deleted]]
John Fox
2012-Jul-10 01:22 UTC
[R] Type II ANOVA for user-defined contrasts with covariates
Dear Jordan, Oddly, essentially the same question was posed by someone else three days ago. Because groups enters the model additively, the proper test for each contrast is just the t-test for the corresponding coefficient in the summary() for the model. I hope this helps, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox On Mon, 9 Jul 2012 20:06:22 +0100 Jordan Ramsey <jmr201 at cam.ac.uk> wrote:> I'm wondering if anyone would be able to help me out. I'm trying to use a > type II ANOVA for a model with user-specified contrasts and covariates. > > I have two treatment groups and a control group. I'm comparing average > treatment to controls and also between the two treatment groups, but I'm > also looking to adjust for age and gender as covariates: > > contrastMat=cbind(c(-1,-1,2),c(1,-1,0)) > contrasts(groups)=contrastMat > > Model=lm(Response~Age+Gender+Age:Gender+groups) > > since I'm interested in SS(R | A,G,AG) > > I was hoping then to use the Anova() function in the car() package to find > the type II ANOVA for my specified contrasts, but when I do so it only > looks at Response as a whole instead of the two contrasts. Any ideas where > I'm going wrong? > > Thanks, > JR > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code./
Maybe Matching Threads
- car::Anova - Can it be used for ANCOVA with repeated-measures factors.
- ANOVA contrast matrix vs. TukeyHSD?
- [package-car:Anova] extracting residuals from Anova for Type II/III Repeated Measures ?
- Please help: ANOVA with SS Type III for unequal sample sized data
- two way ANOVA with unequal sample sizes