Hi Simon

You have to replace А" with the getME() function:

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

Sincerely, Andrea

........................................

Andrea Cantieni
Research Assistant

University of Teacher Education Schwyz
Institute for Media and Schools
Zaystrasse 42
6410 Goldau
Switzerland

Tel. +41 41 859 05 72
andrea.cantieni@phsz.ch<mailto:andrea.cantieni@phsz.ch>
www.phsz.ch<http://www.phsz.ch>

..........................................
 _____               _   _               _           _
|  __ \             | | | |             (_)         | |
| |__) |   ___ _ __ | |_| |__  _   _ ___ _  __ _ ___| |_
|  _  /   / _ \ '_ \| __| '_ \| | | / __| |/ _` / __| __|
| | \ \  |  __/ | | | |_| | | | |_| \__ \ | (_| \__ \ |_
|_|  \_\  \___|_| |_|\__|_| |_|\__,_|___/_|\__,_|___/\__|





Am 03.05.2014 um 11:29 schrieb Simon Sun <simons6831@gmail.com<mailto:simons6831@gmail.com>>:

Dear Ben,

I am a user of your excellent work lme4. While during my work I realized the
problem that the package doesn't provide function to return standardized
coefficients.

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

But I couldn't make it work, every time it showed:

Error in apply(Mod@x[, -1], 2, sd) : no slot of name "x" for this object of
class "lmerMod"

Could you please help me figure it out? Thank you very much!

_______________________________________________
R-sig-mixed-models@r-project.org<mailto:R-sig-mixed-models@r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models


	[[alternative HTML version deleted]]

