Learn R Programming

JMbayes (version 0.8-85)

mvglmer: Multivariate Mixed Models

Description

Fits multivariate mixed models under a Bayesian approach using JAGS.

Usage

mvglmer(formulas, data, families, engine = c("JAGS", "STAN"), 
    overdispersion = FALSE, priors = NULL, init = NULL, control = NULL, …)

Arguments

formulas

a list of R formulas representing the mixed models; these should be lme4-type formulas.

data

a data.frame that contains all the variable to be used when fitting the multivariate mixed model.

families

a list of families objects correspond to each outcome.

engine

a character string indicating whether to use JAGS or STAN to fit the model.

overdispersion

logical; for Poisson outcomes, should an overdispersion parameter be included.

priors

a named list of user-specified prior parameters:

taus_betas

the prior precision parameter for the fixed effects; default is 0.001.

priorK.D

degrees of freedom for the wishart prior for the inverse covariance matrix of the random effects; default is number of random effects plus one.

priorR.D

precision matrix of the wishart prior for the inverse covariance matrix of the random effects; default to a diagonal matrix with diagonal ellements given a Gamma prior with parameters A_R.D and A_R.D.

A_R.D

the prior shape parameter of the Gamma prior for the diagonal elements of the precision matrix of the wishart prior for the inverse covariance matrix of the random effects; default is 0.5.

B_R.D

the prior shape parameter of the Gamma prior for the diagonal elements of the precision matrix of the wishart prior for the inverse covariance matrix of the random effects; default is 0.001.

tau_half_cauchy

prior precision parameter of a half-Cauchy distribution for the precision parameter of a random intercept, when only a single outcome is specified with a single random effect; default is 0.1.

A_tau

the prior shape parameter for the precision of the error terms of Gaussian outcomes.

B_tau

the prior rate parameter for the precision of the error terms of Gaussian outcomes.

init

a list of initial values.

control

a list of control values with components:

n.iter

integer specifying the total number of iterations after burn in; default is 28000.

n.burnin

integer specifying how many of iterations to discard as burn-in; default is 3000.

n.thin

integer specifying the thinning of the chains; default is 50.

n.adapt

integer specifying the number of adapt iterations in which the acceptance rates are checked; default is 3000.

n.chains

integer specifying the number of chains to use; default is 2.

n.processors

integer specifying the number of processors to use; default is the number of available processors minus one.

working.directory

a character string giving the path on where to save the JAGS model; default is the working directory.

clear.model

logical; should the JAGS models be deleted after the model has run; default is TRUE.

seed

an integer setting the random seed; default is 1.

options passed to the control argument.

Value

A list of class mvglmer with components:

mcmc

a list with the MCMC samples for each parameter.

components

a list with design matrices and responses vectors extracted by applying the formulas in data.

data

a copy of data.

control

a copy of the control values used in the fit.

mcmc.info

a list with information over the MCMC (i.e., time it took, iterations, etc.).

DIC

the DIC value for the fitted model.

pD

the pD valu for the fitted model.

Rhat

a list with the Rhat convergence diagnostics for each parameter.

priors

a copy of the priors used.

postMeans

a list with posterior means.

postModes

a list with posterior modes calculated using kernel desnisty estimation.

EffectiveSize

a list with effective sample sizes.

StErr

a list with posterior standard errors.

StDev

a list with posterior standard deviations.

CIs

a list with 95% credible intervals.

Pvalues

a list of tail probabilities for containg the zero value.

call

the matched call.

Details

This function creates a JAGS program representing a multivariate mixed effects that is run with JAGS using the jagsUI package. Currently only Gaussian, Bernoulli and Poisson longitudinal outcomes can be handled.

See Also

mvJointModelBayes, jointModelBayes

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
MixedModelFit <- mvglmer(list(log(serBilir) ~ year + (year | id),
                               spiders ~ year + (1 | id)), data = pbc2,
                          families = list(gaussian, binomial))

summary(MixedModelFit)
plot(MixedModelFit)
# }

Run the code above in your browser using DataLab