[R-sig-ME] estimating contrasts and their standard errors from mixed effects models in lme4

Adam D. I. Kramer adik at ilovebacon.org
Fri Nov 20 03:18:40 CET 2009


Hi Eva,

 	If your data frame contains the factor variables you are interested
in analyzing, use the contrasts() function to get and set which contrasts
you would like.

 	Then, just use the factor variable in your fixed-effects formula.
lmer will automatically use the contrasts you provided, and you will get a
effect line for each contrast (including estimate and standard error).

So, for example, I just completed this analysis and set it to my advisor. 
We're looking at the perception of personal risk of an adverse outcome
occurring. There were three adverse outcomes, which I had contrast-coded in
the following manner:

> contrasts(h3a2$effect)
     heaVcri achVcri
cri       0       0
hea       1       0
ach       0       1

...so when I use the h3a2$effect variable using lmer:

> summary( lmer(risk ~ effect*order + income + (1|subj), data=h3a2) )
... I get these fixed effects:

Fixed effects:
                     Estimate Std. Error t value
(Intercept)          0.92254    0.21431   4.305
effectheaVcri       -0.53837    0.24859  -2.166
effectachVcri       -0.40662    0.25000  -1.627
order               -0.31194    0.07823  -3.987
income              -0.08551    0.03618  -2.363
effectheaVcri:order  0.27001    0.11736   2.301
effectachVcri:order  0.19991    0.11764   1.699

...output lines 2 and 3 are the two contrasts (labeled with the name of the
variable and then the name of the contrast: effectheaVcri is really
"effect""heaVcri"), with their estimates, and standard errors.  Lines 6 and
7 are the same contrasts' interactions with the "order" variable.

Really, the order effect is what I'm interested in here--order predicted
less risk, meaning that people who rated a given disorder later on in the
experiment thought they were less at risk for the disorder (even after we
control for what the disorder is, so for me the contrasts are more or less
control variables).

Hope this helps!

--Adam

On Thu, 19 Nov 2009, eva petkova wrote:

> This must have come up before, but i did not find it in the help archive.
>
> in a mixed effects model fitted with lmer, i have an interaction term
> between two factors, each with more than two levels and would like to
> estimate and test  various contrasts between different combinations of the
> factor levels. i need the point estimates and the standard errors for these
> many contrasts.  does anyone know if there is a function that calculates the
> standard errors of contrasts?
>
> thank you
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




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