Hello

I'm working with mixed effects models using lmer() and have some problems to 
get all variance components of the model's random effects. I can get the 
variance of the random effect out of the summary and use it for further 
calculations, but not the variance component of the residual term. Could 
somebody help me with that problem? Thanks a lot! Below an example.

Aline



## EXAMPLE
#----------

require(lme4)

## Simulate data for the example
set.seed(6)
x1 <- runif(n=100, min=10, max=100) ## a continuos variable
x2 <- runif(n=100, min=10, max=100) ## a continuos variable

treat <- rep(letters[1:4], times=25) ## a fixed factor with 4 levels
treat.effect <- 20*rep(1:4, times=25) 

group.label <- rep(LETTERS[1:5], each=20)  ## the random effect
group.effect <- 10*rep(1:5, each=20)       ## there are 5 groups

## Response variable:
y <- 2*x1 + (-5)*x2 + treat.effect + group.effect + rnorm(100)

## Dataframe
d.ex <- data.frame(y, x1, x2, "Group"=group.label, treat)

## Apply model
mod1 <- lmer(y~x1+x2+treat+x1:treat+ (1|Group), data=d.ex)
output <- summary(mod1); output # ok, there is the variance component of the 
random effect group and the residual term

## Now I'd like to get the variance components of the random effect "Group" and 
of the residual term "Residual" in order 
# to do further calculations with these numbers
output$varcor[1] ## reveals the variance of the random effect "Group"
output$varcor[2] ## does not reveal the residual term! what other command do I 
need to use then?

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to