| brm_multiple {brms} | R Documentation |
Run the same brms model on multiple datasets and then combine the results into one fitted model object. This is useful in particular for multiple missing value imputation, where the same model is fitted on multiple imputed data sets.
brm_multiple(formula, data, family = gaussian(), prior = NULL,
autocor = NULL, cov_ranef = NULL, sample_prior = c("no", "yes",
"only"), sparse = FALSE, knots = NULL, stanvars = NULL,
stan_funs = NULL, combine = TRUE, seed = NA, file = NULL, ...)
formula |
An object of class |
data |
A list of data.frames each of which will
be used to fit a separate model. Alternatively, a
|
family |
A description of the response distribution and link function to
be used in the model. This can be a family function, a call to a family
function or a character string naming the family. Every family function has
a |
prior |
One or more |
autocor |
An optional |
cov_ranef |
A list of matrices that are proportional to the (within)
covariance structure of the group-level effects. The names of the matrices
should correspond to columns in |
sample_prior |
Indicate if samples from all specified proper priors
should be drawn additionally to the posterior samples (defaults to
|
sparse |
Logical; indicates whether the population-level design matrices
should be treated as sparse (defaults to |
knots |
Optional list containing user specified knot values to be used
for basis construction of smoothing terms. See
|
stanvars |
An optional |
stan_funs |
(Deprecated) An optional character string containing
self-defined Stan functions, which will be included in the functions
block of the generated Stan code. It is now recommended to use the
|
combine |
Logical; Indicates if the fitted models
should be combined into a single fitted model object
via |
seed |
The seed for random number generation to make results
reproducible. If |
file |
Either |
... |
Further arguments passed to |
The combined model may issue false positive
convergence warnings, as the MCMC chains corresponding
to different datasets may not necessarily overlap, even
if each of the original models did converge.
To find out whether each of the original models converged,
investigate fit$rhats, where fit
denotes the output of brm_multiple.
If combine = TRUE a brmsfit_multiple object,
which inherits from class brmsfit and behaves essentially
the same. If combine = FALSE a list of brmsfit objects.
## Not run: library(mice) imp <- mice(nhanes2) # fit the model using mice and lm fit_imp1 <- with(lm(bmi~age+hyp+chl), data = imp) summary(pool(fit_imp1)) # fit the model using brms fit_imp2 <- brm_multiple(bmi~age+hyp+chl, data = imp, chains = 1) summary(fit_imp2) plot(fit_imp2, pars = "^b_") # investigate convergence of the original models fit_imp2$rhats ## End(Not run)