[R-sig-ME] standardized parameter estimates in random regression model

Ben Bolker bbolker at gmail.com
Mon Jun 24 16:42:00 CEST 2013


tommy gaillard <tommy.gaillard40 at ...> writes:

> 
>  Dear all,
> 
>  I am currently trying to quantify between-individual differences in
> intercept and slope of vigilance behavior.
>  Here is my model:
> model<-lmer(logfreq_vig~logdensity+logbiomasstrue+(1|Idtag),
> na.action=na.omit, data=tabimpala)
> 
> I would need to obtain the value of Vi (estimator of the intercept
> deviation) and Vs (=estimator of the slope deviation)
>  with their Confidence
> Interval.
>    I have tried the scale function and the lm.beta function 
> to standardize
> the variables but it is not working...
>   Does someone would have an idea to obtain those values?

  You should probably tell us what package the lm.beta function is
from ... sos::findFn() tells me that there are two in contributed packages
(QuantPsyc and scaleCoef). scaleCoef has been archived ...


Looking at what QuantPsyc::lm.beta actually does:

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

The lme4 equivalent steps would be:

library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
b <- fixef(fm1)[-1]     ## get coefficients except intercept
mf <- model.frame(fm1)  ## pull out original data
sx <- sapply(mf[names(b)],sd)  ## calc sd of input variables
sy <- sd(mf[[1]])              ## sd of response
b*sx/sy

Note that this is a bit fragile (as is the original lm.beta()): it assumes

* the model has an intercept
* all the predictors are continuous responses (no factors,
  interactions, etc etc)
* the response is stored as the first column of the model frame

It might be worth writing a more robust version of this at some point.

  It's good to give reproducible examples of what you want to do
(and specify what's not working -- don't just say "it's not working")



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