user53330 user53330 - 3 months ago 13
R Question

R ranef(model, condVar) attributes NULL, but postVar show results + deprecated warning

I am finding a weird behaviour in lmer (lme4 version 1.1.12) model fits trying to extract random effect attributes (conditional variances).

With the Arabidopsis dataset:

#Model maybe makes no sense and fits horribly, but that doesn't matter for my point
model <- lmer(total.fruits ~ nutrient * gen + (nutrient + gen | reg), data=Arabidopsis)

# Get conditional variances with postVar generates output + warning
attr(ranef(model, postVar=T)[[1]], "postVar")


, , 1

[,1] [,2] [,3]
[1,] 45.263 -3.37843 -1.57356
[2,] -3.378 0.70041 0.01081
[3,] -1.574 0.01081 0.08008

, , 2

[,1] [,2] [,3]
[1,] 98.09 -1.519936 -4.790450
[2,] -1.52 0.314335 0.005048
[3,] -4.79 0.005048 0.250406

, , 3

[,1] [,2] [,3]
[1,] 19.1829 -1.8417121 -0.5693759
[2,] -1.8417 0.4106308 -0.0009613
[3,] -0.5694 -0.0009613 0.0301338


Warning message:
In ranef.merMod(model, postVar = T) :
‘postVar’ is deprecated: please use ‘condVar’ instead


BUT, with condVar:

#Input
attr(ranef(model, condVar=T)[[1]], "condVar")
#Output
NULL


I discovered that while working with another dataset, where I get exactly the same behaviour (postVar works, but gives warning, condVar does nothing).

I'm now sticking with postVar and ignoring the warning, but I wanted to know if there is something I am missing with this, or it is a bug, or if I am doing something wrong? (I discovered this trying to make a qqplot with ggplot, and it wont work if I don't use postCond)
Any comments would be appreciated,
Thanks!

Answer

This is admittedly confusing. The argument has changed to condVar but the attribute name is still postVar ...

attr(ranef(model, condVar=TRUE)[[1]], "postVar")