Skip to content

getting between groups variance when using (1|x:y)in the formula

2 messages · Ben Bolker, Hans Ekbrand

#
Hans Ekbrand <hans at ...> writes:
I don't think that's something that glmer() estimates -- it
assumes that the variance is equal for every y-within-x combination.
I suppose you could just compute the variance of each group of
conditional modes, i.e. if xyests are your x:y conditional modes
and xests are your x conditional modes then you could
tapply(xyests,list(xests),var) ...  someone may suggest something
better ...
3 days later
#
On 2012-06-01 13:53, Ben Bolker wrote:
Thanks for your suggestion, Ben. I ended up doing like this.:

my.df <- ranef(my.fit, postVar = TRUE, whichel = "x:y")$x
my.var <- as.numeric(attr(my.df, "postVar"))
foo <- strsplit(rownames(my.df), ":")
the.names <- unique(sapply(1:nrow(my.df), function(x) {foo[[x]][2] }))
the.sd <- sapply(the.names, function(x) {
   these <- grep(paste(":", x, "$", sep = ""), rownames(my.df))
   sqrt(sum(my.var[these])/length(these))
})

I am not really sure about the meaningfulness of this measure, but it 
varied over the levels of y in the way I expected.