# lmer: standardized regression coefficients

I have analyzed some data (the exact nature of which, I assume, is irrelevant for this question) using linear mixed effects models with the lmer() function from lme4.

There has been at least one question about standardized regression coefficients previously, in which, obviously, there has been the recommendation to use the scale() function in order to obtain standardized predictors and outcome variables before entering these into a model.

Furthermore, in a comment on an answer, @crash posted a link to an email by Ben Bolker, in which the latter provided a function, applying lm.beta() to "lmer-land".

The function, as provided there, looks like this:

lm.beta.lmer <- function(mod) {
b <- fixef(mod)[-1]
sd.x <- apply(mod at X[,-1],2,sd)
sd.y <- sd(mod at y)
b*sd.x/sd.y
}


Yet, the "mod at X" and "mod at y" parts are hyperlinked and appear not to resemble executable R code. Specifically, when trying to define this function, R outputs

Error: unexpected symbol in:
"b <- fixef(mod)[-1]
sd.x <- apply(mod at"


so apparently R does not like the spaces.

I am interested in how I would need to change the code of lm.beta.lmer() in order to successfully apply this to my lmer models, but my nooby R skills forbid me to do so.

If anyone provided a useful answer to this, I would deeply appreciate this.

Cheers, bunsen

EDIT Thanks @Wolfgang, I was not aware of this. However, having changed the abovementioned code accordingly, i.e. writing mod@X and mod@y, I get the following output when applying the function to a model:

>lm.beta.lmer(mod)
Error in apply(mod@X[, -1], 2, sd) :
no slot of name "X" for this object of class "lmerMod"


Apparently, the code fails to access the Field X in slot pp of the lmerMod object (of which the first column is labelled "(Intercept)", so I assume it is the one that should be deleted). Since I get this error, I do not know, whether the Field y of slot resp of this object will be accessed, but I guess not.

I have attempted various ways of changing the code in order to make it access the X and y fields of the respective slots, but failed. Which part am I doing incorrectly, or rather (since I do not tell the ways I've tried): which is a possible way to access these fields?

I have noticed, that most likely I will be faster using the scale() function, but I am eager to learn a solution to my question.

Thanks again!

• The mod at X parts are supposed to be mod@X. Mailing lists often replace "@" with " at " to make it more difficult for spammers to farm e-mail addresses. – Wolfgang Nov 10 '14 at 11:05
• Thanks @Wolfgang. However, there are problems that follow and I have edited my question accordingly. – bunsenbaer Nov 10 '14 at 17:10

You can get at X and y using the getME() function. So, this should work:
lm.beta.lmer <- function(mod) {