[R-sig-ME] random effects specification

Reinhold Kliegl reinhold.kliegl at gmail.com
Tue Apr 8 21:47:04 CEST 2008


On Tue, Apr 8, 2008 at 8:13 PM, Sebastian P. Luque <spluque at gmail.com> wrote:
> On Tue, 8 Apr 2008 19:31:08 +0200,
>  "Reinhold Kliegl" <reinhold.kliegl at gmail.com> wrote:
>
>  [...]

>  > If you learn how to combine estimates, you can derive the pattern of
>  > means directly from your first analyses.
>
>  You mean using approaches as those used in estimable() from the gmodels
>  package?  If so, is that equivalent to doing a separate analysis for
>  each level of community with mixed models?  I think it isn't for fixed
>  effects only models.
>

> tapply(dta$n, list(dta$treatment, dta$community), mean)
          A            B
a 18.78058 18.74912
b 19.11358 18.38756
c 18.79208 18.73067
d 19.10998 18.40533

> (n.lmer1)
...
Fixed effects:
                      Estimate Std. Error t value
(Intercept)           18.78058    0.01784  1052.7
communityB            -0.03146    0.02523    -1.2
treatmentb             0.33300    0.02523    13.2
treatmentc             0.01150    0.02523     0.5
treatmentd             0.32939    0.02523    13.1
communityB:treatmentb -0.69456    0.03568   -19.5
communityB:treatmentc -0.02995    0.03568    -0.8
communityB:treatmentd -0.67318    0.03568   -18.9

You can reconstruct the table of means from the coefficients:
                      A                                                   B
a :  intercept                               intercept + communityB
b:   intercept + treatmentb          intercept + treatmentb +
communityB + communityB:treatmentb
c:   intercept + treatmentc          intercept + treatmentc +
communityB + communityB:treatmentc
d:   intercept + treatmentd          intercept + treatmentd +
communityB + communityB:treatmentd

This is a consequence of the default treatment contrasts associated
with factors as attributes.
> contrasts(dta$treatment)
  b c d
a 0 0 0
b 1 0 0
c 0 1 0
d 0 0 1

> contrasts(dta$community)
  B
A 0
B 1

You can change the default, that is specify your own contrasts as
factor attributes most flexibly via C (see ?C). lmer uses the factor
attribute (like, e.g.,  lm and other programs) and provides test
statistics for each of the contrasts (and their products).

Best
Reinhold




More information about the R-sig-mixed-models mailing list