Skip to content
Prev 11874 / 20628 Next

Accessing and updating lmer objects

After you install new random effect covariance parameters into a merMod object, you need to propagate the changes to the various dependent matrix decompositions. For a lmm, it looks something like:

newTheta <- c(1, 0, 1)
fm at pp$setTheta(newTheta)
fm at pp$updateDecomp()
fm at resp$updateMu(fm at pp$linPred(0.0))
fm at pp$updateRes(fm at resp$wtres);
fm at pp$solve()
fm at resp$updateMu(fm at pp$linPred(1.0))

And then to get the deviance for the object,

fm at resp$objective(fm at pp$ldL2(), fm at pp$ldRX2(), fm at pp$sqrL(1.0))


That's the R equivalent of what the C++ code does for each optimization step. If you're working with a glmm, the process is similar but you can see how to do it much more easily by calling glmer with devFunOnly = TRUE and examining the resulting function.

In fact, if all you want to do is install the parameters, you can grab the deviance function for a lmm/glmm and simply call that with your desired parameters to get an updated object. However, if you want to interject modifications you will need to modify the above steps.

Vince
On May 6, 2014, at 3:27 PM, Ben Bolker wrote: