Skip to content

Extracting means and SE from lme & lmer with random terms

2 messages · Julie Kern, Ben Bolker

#
Dear R gurus,

I?ve done a lot of reading around this topic but can?t seem to find a
solution that is working.

I am running linear mixed models with lme & a few glmms with lmer
(binomial response term). I would like to extract (not predict) the
means & their SE of the fixed effects from the model but am having
difficulties. For example, having run the model

Vocalising<-lmer(Vocalsing~Sex+Age+Rank+fixef4...fixef7+(1|Group/ID),
data=mydata, family=binomial, REML=FALSE)

I would get a value for the mean proportion of males and females that
vocalised during bouts as well as the standard error of the
proportion.
I have tried using allEffects in the effects package but am only
managing to get means. Is this because I have random terms in my model
as well as fixed? If so how would you recommend I proceed?
I have tried using  attr(ranef(mymodel, postVar = TRUE)[[1]],
"postVar")as recommended on http://glmm.wikidot.com/faq but this
produces a list of 40 or so numbers so I?ve clearly misunderstood
this!

Any tips or advice would be greatly appreciated!

Thank you!

Julie
1 day later
#
Julie Kern <juliekern27 at ...> writes:
Can you give us a (small!) reproducible example?
  Do you get the desired results (in terms of which values are
computed) if you use glm() instead of lmer() and drop the random
effects term?

  A couple of notes:

 * REML is silently ignored when fitting GLMMs (there is a bit
of commentary on this in http://glmm.wikidot.com/faq ; the development
version of lme4 produces a warning).
 * the CRAN version of lme4 silently passes control to glmer() when
'family' is specified, but it is probably better to call glmer() explicitly
when doing GLMMs (the development version requires that you call glmer()
explicitly).
the incantation you reproduce here is for getting the variances
of the random effect 'estimates' (conditional modes), not for getting
the standard errors of the fixed-effect parameters.

  Ben Bolker