Description Usage Arguments Details Value See Also Examples
Bayesian inference for multivariate GLMs with groupspecific coefficients that are assumed to be correlated across the GLM submodels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  stan_mvmer(
formula,
data,
family = gaussian,
weights,
prior = normal(),
prior_intercept = normal(),
prior_aux = cauchy(0, 5),
prior_covariance = lkj(),
prior_PD = FALSE,
algorithm = c("sampling", "meanfield", "fullrank"),
adapt_delta = NULL,
max_treedepth = 10L,
init = "random",
QR = FALSE,
sparse = FALSE,
...
)

formula 
A twosided linear formula object describing both the
fixedeffects and randomeffects parts of the longitudinal submodel
similar in vein to formula specification in the lme4 package
(see 
data 
A data frame containing the variables specified in

family 
The family (and possibly also the link function) for the
GLM submodel(s). See 
weights 
Same as in 
prior, prior_intercept, prior_aux 
Same as in 
prior_covariance 
Cannot be 
prior_PD 
A logical scalar (defaulting to 
algorithm 
A string (possibly abbreviated) indicating the
estimation approach to use. Can be 
adapt_delta 
Only relevant if 
max_treedepth 
A positive integer specifying the maximum treedepth
for the nonUturn sampler. See the 
init 
The method for generating initial values. See

QR 
A logical scalar defaulting to 
sparse 
A logical scalar (defaulting to 
... 
Further arguments passed to the function in the rstan
package ( 
The stan_mvmer
function can be used to fit a multivariate
generalized linear model (GLM) with groupspecific terms. The model consists
of distinct GLM submodels, each which contains groupspecific terms; within
a grouping factor (for example, patient ID) the groupingspecific terms are
assumed to be correlated across the different GLM submodels. It is
possible to specify a different outcome type (for example a different
family and/or link function) for each of the GLM submodels.
Bayesian estimation of the model is performed via MCMC, in the same way as
for stan_glmer
. Also, similar to stan_glmer
,
an unstructured covariance matrix is used for the groupspecific terms
within a given grouping factor, with priors on the terms of a decomposition
of the covariance matrix.See priors
for more information about
the priors distributions that are available for the covariance matrices,
the regression coefficients and the intercept and auxiliary parameters.
A stanmvreg object is returned.
stan_glmer
, stan_jm
,
stanregobjects
, stanmvregmethods
,
print.stanmvreg
, summary.stanmvreg
,
posterior_predict
, posterior_interval
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  #####
# A multivariate GLM with two submodels. For the grouping factor 'id', the
# groupspecific intercept from the first submodel (logBili) is assumed to
# be correlated with the groupspecific intercept and linear slope in the
# second submodel (albumin)
f1 < stan_mvmer(
formula = list(
logBili ~ year + (1  id),
albumin ~ sex + year + (year  id)),
data = pbcLong,
# this next line is only to keep the example small in size!
chains = 1, cores = 1, seed = 12345, iter = 1000)
summary(f1)
#####
# A multivariate GLM with one bernoulli outcome and one
# gaussian outcome. We will artificially create the bernoulli
# outcome by dichotomising log serum bilirubin
pbcLong$ybern < as.integer(pbcLong$logBili >= mean(pbcLong$logBili))
f2 < stan_mvmer(
formula = list(
ybern ~ year + (1  id),
albumin ~ sex + year + (year  id)),
data = pbcLong,
family = list(binomial, gaussian),
chains = 1, cores = 1, seed = 12345, iter = 1000)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.