Stephen, You are looking for the nesting of the FirstFactor within the SecondFactor. Here is an example for your two-way design. The model.matrix shows the dummy variables. The last four columns show the two-level comparisons of Fir within each level of Sec
Rich tmp <- data.frame(y=rnorm(16), Sec=rep(LETTERS[1:4], each=4), Fir=rep(factor(1:2), 4, each=2)) contrasts(tmp$Fir) <- c(1, -1) tmp.aov <- aov(y ~ Sec/Fir, data=tmp) anova(tmp.aov) cbind(tmp, model.matrix(tmp.aov)[, -1]) On Fri, Sep 7, 2012 at 2:46 PM, Stephen Politzer-Ahles < politzerahl...@gmail.com> wrote: > Hello everyone, > > I am running a mixed effects model where I have two fixed factors, one with > 2 levels and one with 4, and their interaction. Let's say these are my > factors and their levels: > > FirstFactor: 1, 2 > SecondFactor: A, B, C, D > > For the interaction, I am interested in the four two-way comparisons, not > the two four-way comparisons. In other words, I want to test whether 1A is > significantly different than 2A, whether 1B is significantly different than > 1B, etc; I am not interested in the comparison of 1A~1B~1C~1D. > > However, the latter comparisons are what the coefficients seem to give me > when I summarize my model. For instance, the coefficient for the > interaction term "FirstFactor2:SecondFactorB" doesn't tell me how different > 2B is from 1B, it tells me how different 2B is from 2A. > > Is there a straightforward way to code the contrasts so that the > coefficients I get for the interaction terms do the comparisons I'm > interested in? > > Thank you for your advice, > Steve Politzer-Ahles > > -- > Stephen Politzer-Ahles > University of Kansas > Linguistics Department > http://www.linguistics.ku.edu/ > > [[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 > and provide commented, minimal, self-contained, reproducible code. > [[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 and provide commented, minimal, self-contained, reproducible code.