Skip to content
Prev 8856 / 20628 Next

Heterogeneous (co)variances in a bivariate model with MCMCglmm?

Vincent--

I've been doing a bit of work on multivariate mixed models using 
MCMCglmm with some colleagues (actually, for a tutorial paper on that 
topic...).

The following will fit random intercepts and slopes for two outcomes but 
*not* allowing correlations between outcomes (note that "j" is the 
grouping variable in our data).  Data is for simple two treatment over 
time study (common in psychiatry / psychology) with two outcomes.

# random intercept and slopes, but not correlated across outcomes
prior2 <- list(R = list(V = diag(2), nu = 1.002),
                G = list(G1 = list(V = diag(2), nu = 1.002),
                         G2 = list(V = diag(2), nu = 1.002)))

mult.mcmc3 <- MCMCglmm(cbind(y, y2) ~ -1 + trait*(tx*time),
                        data = data.wide,
                        random = ~ us(at.level(trait, 1) +
                                   at.level(trait, 1):time):j +
                                   us(at.level(trait, 2) +
                                   at.level(trait, 2):time):j,
                        rcov = ~ us(trait):units,
                        family = c("gaussian","gaussian"),
                        verbose = TRUE,
                        nitt = 25000, burnin = 5000, thin = 20,
                        prior = prior2)


Fitting correlated effects is actually a bit less "wordy" in terms of 
syntax:

# unstructured matrix between outcomes
prior3 <- list(R = list(V = .2*diag(2), nu = 3),
                G = list(G1 = list(V = diag(c(.2,.2,.1,.1)), nu = 5)))

mult.mcmc3.1 <- MCMCglmm(cbind(y, y2) ~ -1 + trait*(tx*time),
                        data = data.wide,
                        random = ~ us(-1 + trait*time):j,
                        rcov = ~ us(trait):units,
                        family = c("gaussian","gaussian"),
                        verbose = TRUE,
                        nitt = 25000, burnin = 5000, thin = 20,
                        prior = prior3)

Note that we're using simulated data and have been futzing a bit with 
priors, so I would definitely *not* suggest "prior3" for off-the-shelf 
usage.

Hope that helps.

cheers, Dave