Using model.avg in the MuMIn package, I have created an averaged model from a set of lme4 models. I now want to use the averaged model coefficients in various other functions in other packages, which do not take objects of the class 'averaging'. How can I create a new lme4 object model that takes the estimates and errors of the averaged model?

A trivial example:

library(lme4)
library(MuMIn)
options(na.action = na.fail)
m1 = lmer(distance ~ age * Sex + (1|Subject), data= Orthodont)
d1 = dredge(m1)
a1 = model.avg(d1)
summary(a1)

Now I would like to do something like: Run a model with all the terms that are present in the averaged model

m2 = m1   # in this case all terms in the original model were present in the averaged model

Then I would like to manually set / assign the coefficients (and errors) for fixed and random effects as calculated through the model averaging process to the new model. So I'm looking for something like:

coef(m2) = coef(a1)
ranef(m2) = ranef(a1)   

This doesn't work of course, but something along those lines is ultimately what I'd like to be able to do.

There are examples of 'hacking' coefficients for linear models, e.g. see https://stackoverflow.com/questions/28633537/partial-residual-plot-based-on-model-average-coefficients-in-r - but I need to also include the random component of the averaged model.

0

There are 0 answers