Skip to content

CANNOT PARTITION ERROR VARIANCE AMONG EXPERIMENTS

2 messages · Kassim Baba Yussif, Paul Johnson

#
I am analyzing data from multiple experiments using linear mixed effect
model. However, I cannot partition the error variance based on each
experiment. I will therefore be grateful if I can be guided on how to go
about it.

Below is the model I used:

lmer(yield~Experiment+(1|Genotype), data = MET)
#
Hi Kassim,

fit <- lmer(yield~Experiment+(1|Genotype), data = MET)

# variance "explained" by fixed effects, i.e. between experiments
fitval <- model.matrix(fit) %*% fixef(fit)
n <- length(fitval)
Vf <- sum((fitval - mean(fitval))^2)/n
#  var(fitval) would be simpler but uses n-1 as the denominator whereas I think (?!) n is correct
# (in practice it'll only make a substantial difference if n is very small)

# genotype random effect variance (unexplained variation among genotypes)
Vr <- VarCorr(fit)$Genotype[, ]
# (note that this doesn't work when there are random slopes)

# residual/error variance (unexplained variation between observations)
Ve <- attr(VarCorr(fit), "sc")^2

var(MET$yield)
# ...should be not too far from
Vf + Vr + Ve

Best wishes,
Paul