Rich,

Thank you very much for your response and the example! I think this solved
my problem completely. I am using lmer rather than aov for my model, though
(I have crossed random effects for subjects and items), so I'd just like to
check and make sure I'm understanding the model output correctly, if that's
ok.

I used c(-1, 1) for the contrasts to make the first level of Fir the
reference level. Then I ran:

test <- lmer(Latency ~ (Nuisance1*Nuisance2) + (Sec/Fir) + (1|Subject) +
(1|Item), datatotest)

(Nuisance1 and Nuisance2 are some other variables that I'm not interested
in.) Then I got output like this:

Fixed effects:
                                    Estimate Std. Error t value
(Intercept)                         6.738905   0.041673  161.71
Nuisance1                          -0.008652   0.009294   -0.93
Nuisance2                          -0.005143   0.003789   -1.36
SecB                               -0.011166   0.011633   -0.96
SecC                                0.010848   0.011528    0.94
SecD                               -0.009048   0.011581   -0.78
Nuisance1:Nuisance2                 0.002642   0.002360    1.12
SecA:Fir1                          -0.009879   0.008283   -1.19
SecB:Fir1                          -0.032136   0.008293   -3.88
SecC:Fir1                           0.006748   0.008131    0.83
SecD:Fir1                           0.006153   0.008206    0.75

It looks like the last four coefficients are what I was looking for: each
one describes the difference between the two levels at Fir, for a given
level of Sec. Specifically it's saying how different the level of Fir that
I gave "1" to in the contrast matrix differs from the level I gave "-1" to,
which is the baseline. (At least, under this interpretation, the
coefficients are consistent with what I see when I plot the raw averages.)

I hope this is on the right track. Thanks again for your assistance!

Best,
Steve Politzer-Ahles



On Fri, Sep 7, 2012 at 3:51 PM, Richard M. Heiberger <r...@temple.edu> wrote:

> 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.
>>
>
>


-- 
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.

Reply via email to