brms (version 0.5.0)

ranef: Extract Random Effects for brmsfit objects

Description

A generic function to extract the random effects of each level from a fitted model object.

Usage

## S3 method for class 'brmsfit'
ranef(x, estimate = "mean", var = FALSE, ...)

Arguments

x
An object of a class of fitted models with random effects, typically a brmsfit object.
estimate
The point estimate to be calculated for the random effects, either "mean" or "median".
var
logical; indicating if the covariance matrix for each random effects should be computed.
...
Further arguments to be passed to the function specified in estimate

Value

  • A list of matrices (one per grouping factor), each with one row per level and one single column for the estimate (either mean or median).

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)
## random effects means with corresponding covariances
rf <- ranef(fit_e, var = TRUE)
attr(rf, "var")
## random effects medians
ranef(fit_e, estimate = "median")

Run the code above in your browser using DataLab