[R-sig-ME] standardized coefficients in glmer model

Ben Bolker bbolker at gmail.com
Sat Dec 11 17:09:12 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10-12-11 02:21 AM, Leeuwen, Casper van wrote:
> Dear R-list,
> 
> I'm running a mixed effect logistic regression with both factors and
> covariates, an interaction and a random factor.
> 
> model <- glmer (intact_binomial ~ species + sex + retention_time +
> body_mass + body_mass * retention_time + (1 | individual) , family =
> binomial (link = "logit") ) summary(model)
> 
> summary() returns effects sizes given as coefficients of the
> different factors. However, I would like to indicate the importance
> of the different terms in the model, to determine the relative
> importance of for instance sex versus body_mass: which one is more
> important in explaining my dependent variable?

  If all your variables were numeric (which sex is not) then

model_scaled <- glmer(...,data=scale(mydata))

would work: looking at lm.beta and Make.Z in the QuantPsyc package (you
didn't tell us where lm.beta() came from ...), Make.Z seems (as far as I
can tell) to replicate the behavior of the built-in scale() function.
But that approach won't work properly for factors with more than two
levels ...

  Here's lm.beta:

lm.beta
function (MOD)
{
    b <- summary(MOD)$coef[-1, 1]
    sx <- sd(MOD$model[-1])
    sy <- sd(MOD$model[1])
    beta <- b * sx/sy
    return(beta)
}

 Here's a translation into lmer-land:

lm.beta.lmer <- function(mod) {
  b <- fixef(mod)[-1]            ## fixed-effect coefs, sans intercept
  sd.x <- apply(mod at X[,-1],2,sd) ## pull out model (design) matrix,
                                 ## drop intercept column, calculate
                                 ## sd of remaining columns
  sd.y <- sd(mod at y)              ## sd of response
  b*sd.x/sd.y
}

  Here's an example, using the Orthodont data from the nlme package:

library(nlme)
data(Orthodont)
dat <- as.data.frame(Orthodont)
detach(package:nlme)

library(lme4)
fm2 <- lmer(distance ~ age + Sex + (age|Subject), data = dat)
lm.beta.lmer(fm2)

  For this example (which like yours has Sex, a two-level factor, as its
only non-numeric predictor) we can show that we get the same answer (up
to numeric fuzz) by scale()ing:

pdat <- with(dat,cbind(distance,age,s=as.numeric(Sex)))
pdat <- scale(pdat)
dat2 <- data.frame(pdat,Subject=dat$Subject)

fm3 <- lmer(distance ~ age + s + (age|Subject), data = dat2)
fixef(fm3)

  The only remaining question I have is whether it makes sense to scale
by sd(y) in this case -- may not generalize to the GLM case from the LM
case?  But you should have the correct *relative* magnitudes of
parameters in any case.

  good luck,
    Ben Bolker

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0DoigACgkQc5UpGjwzenOqSgCZAcApAJmi5JmuhZL4H1prsFp9
4p0AnAlkF7B5JU1b7hrXqA/eLfy5l2TZ
=Vkhu
-----END PGP SIGNATURE-----




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