# Variance component analysis nlme

Is there a way to carry a variance component analysis using nlme or lme4 packages and how would I calculate the percentage of variance that is attributable to the random effects?

For example, my output from lme is:

Random effects:
Formula: ~1 | Group
(Intercept)
StdDev:   0.6592846

Formula: ~1 | Test %in% Group
(Intercept)
StdDev:    227.5543

Formula: ~1 | Person %in% Test %in% Group
(Intercept) Residual
StdDev:    388.7217 40.67243


Thank you.

A variance component analysis (VCA) with lme4 could look like this.

Consider this dataset, where measurements on 10 devices, for 5 days each with two replicates on each day were performed for assessing the total variability and the contribution of 3 variance components (device, day, error):

> dat <- data.frame(y=50+rep(rnorm(10,,2.5), rep(10,10))+rep(rnorm(50,,2), rep(2,50))+rnorm(100,,1.5), device=gl(10,10), day=gl(5,2,100))
> fit <- lmer(y~(1|device)+(1|device:day), dat)
> sum.fit <- summary(fit)
> vc.tab <- as.data.frame(sum.fit$varcor) > vc.tab$CV <- vc.tab$sdcor*100/mean(dat$y)
> vc.tab$Perc <- paste(round(vc.tab$vcov/sum(vc.tab\$vcov)*100, 2),"%", sep="")
> vc.tab <- vc.tab[,-c(2:3)]
> vc.tab
grp     vcov    sdcor       CV   Perc
1 device:day 5.886198 2.426149 4.779134 58.27%
2     device 1.886688 1.373568 2.705714 18.68%
3   Residual 2.328238 1.525856 3.005699 23.05%


For this (fully) nested model, this is the usual VCA-table. Now, confidence intervals for VC and total variance are the next step.