3
$\begingroup$

I have been using MCMCglmm in R to fit bivariate (two response traits) mixed models in R, but now I need to move to lme to account for temporal autocorrelation of the residuals. In MCMCglmm I can fit the following model (data in wide format):

mod.mcmc=MCMCglmm(cbind(dvm,sdl)~trait-1+poly(month,3),random=~us(trait):id,rcov=~us(trait):units,data=wide21,family=c("gaussian","gaussian"),verbose=FALSE,prior=prior1,pr=TRUE)

And from it extract the variance-covariance matrices (posterior modes) at the random and residual level, with this code:

cor.matrix.bet=matrix(posterior.mode(posterior.cor(mcmc2$VCV[,1:4])),2,2,dimnames=list(c("dvm", "sdl"), c("dvm", "sdl")))

cor.matrix.res=matrix(posterior.mode(posterior.cor(mcmc2$VCV[,5:8])),2,2,dimnames=list(c("dvm", "sdl"), c("dvm", "sdl")))

In lme, my models looks like this right now (data in long format):

mod.lme=lme(value~trait*poly(month,3)-1,data=long21,random=~trait-1|id,weights=varIdent(form=~1|trait),correlation=corAR1(form=~tim|id/trait))

This model differs from the one in MCMCglmm in that I specified a temporal correlation structure in the residuals, something that cannot be done in MCMCglmm. Specifically, "tim" is a timer variable, and the temporal correlation is assessed within each individual ("id") and within each of the two traits ("trait").

I can extract the random variance-covariance matrix of mod.lme wit the getVarCov() function. But how can I get the residual variance-covariance matrix?

And also, the residual variance-covariance matrix is unstructured ("us") in mod.MCMC, which is exactly what I want because then, all the covariances are estimated. In mod.lme I have somehow contrained this (I guess) by using the correlation function, but can I still incorporate somehow in the model that I want a "us" structure for the residuals, or is it completely non-sense since I already have the corAR1 in the model?

Thank you

$\endgroup$
1
  • $\begingroup$ getVarCov(mod.lme, type = "conditional") has a type argument in which you can specify that you want the "conditional" covariance matrix, which correspond to the residual covariance. $\endgroup$
    – lioumens
    Jun 25, 2022 at 6:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.