brms (version 0.5.0)

VarCorr: Extract variance and correlation components

Description

This function calculates the estimated standard deviations, correlations and covariances of the random-effects terms in a mixed-effects model of class brmsfit. For linear models, the residual standard deviations, correlations and covariances are also returned.

Usage

## S3 method for class 'brmsfit'
VarCorr(x, estimate = "mean", as.list = TRUE, ...)

Arguments

x
An object of class brmsfit.
estimate
A character vector specifying which coefficients (e.g., "mean", "median", "sd", or "quantile") should be calculated for the random effects.
as.list
logical; Indicates if covariance and correlation matrices should be returned as lists of matrices (the default), or as 3-dimensional arrays.
...
Further arguments to be passed to the functions specified in estimate

Value

  • A list of lists (one per grouping factor), each containing 3 elements: a matrix containing the standard deviations, a list of correlation matrices, and a list of covariance matrices.

Examples

Run this code
fit_e <- brm(count ~ log_Age_c + log_Base4_c * Trt_c + (1+Trt_c|visit),
             data = epilepsy, family = "poisson", n.chains = 1)
## return the means of random effects covariances
VarCorr(fit_e)
## return 2.5% and 97.5% quantiles of random effects covariances
VarCorr(fit_e, estimate = "quantile", probs = c(0.025, 0.975))

Run the code above in your browser using DataLab