1
votes

I am having hard time while performing Linear Mixed Models (LMM) on data with weights (I mean the weight of the different groups differs). Furthermore, it seems that weights are not kept while using glmulti(). Below is a reproducible example:

require(lme4)
require (glmulti)    
data(cake)
cake$wght <- as.numeric(cake$replicate)
fm1 <- lmer(angle ~ recipe + temperature + (1|replicate), cake, REML= FALSE)
print(VarCorr(fm1),comp=c("Variance","Std.Dev."))

In this case residual variance of the random effect equals 22.36.

fm2 <- lmer(angle ~ recipe + temperature + (1|replicate), cake, weights=wght,REML= FALSE)
print(VarCorr(fm2),comp=c("Variance","Std.Dev."))

And here,residual variance of the random effect is now 155. For linear models, residual variance remains unchanged whatever the weights, while it seems not to be the case here.

The second issue occurs when performing a model averaging with weighted data. It seems that glmulti() does not account for specified weights in the following examples:

wlmer.glmulti <- function (formula, data, random = "", weights ,...) {
lmer(paste(deparse(formula), random), data = data, weights)}
#(watch out doesn't converge!!)
LMM <- glmulti(angle ~ recipe + temperature  , data=cake,  random="+ (1|replicate)", fitfunc =      wlmer.glmulti, weights=cake$wght,report=T, level = 1,crit="aic",method="g")
summary(LMM@objects[[1]])  # is similar to fm1

Any suggestion is most welcome. Thanks

1

1 Answers

1
votes

A short answer to my own post above.

1/ Dealing with weights in Linear Mixed Models:

To avoid large inflation of residual variances of the RE due to weight, once can "simply" ensure that the sum of all weights equal 1.

2/ Integrating weights into model averaging procedure (glmulti)

Directly insert the weights into the wrapper (thanks to Vincent Calcagno for the tip). From previous example:

wlmer.glmulti <- function (formula, data, random = "", weights ,...) {
lmer(paste(deparse(formula), random), data = data, weights)}

Updated working alternative

wlmer.glmulti <- function (formula, data, random = "", weights ,...) {
lmer(paste(deparse(formula), random), data = data, data$wght)}

Hope this will be useful at some point ;)