group_effects: Extract baggr study effects

View source: R/group_effects.R

group_effectsR Documentation

Extract baggr study effects

Description

Given a baggr object, returns the raw MCMC draws of the posterior for each group's effect or a summary of these draws. If there are no covariates in the model, this effect is a single random variable. If there are covariates, the group effect is a sum of effect of covariates (fixed effects) and the study-specific random variable (random effects). This is an internal function currently used as a helper for plotting and printing of results.

Usage

group_effects(
  bg,
  summary = FALSE,
  transform = NULL,
  interval = 0.95,
  random_only = FALSE,
  rename_int = FALSE
)

Arguments

bg

baggr object

summary

logical; if TRUE returns summary statistics as explained below.

transform

a transformation to apply to the result, should be an R function; (this is commonly used when calling group_effects from other plotting or printing functions)

interval

uncertainty interval width (numeric between 0 and 1), if summarising

random_only

logical; for meta-regression models, should fixed_effects be included in the returned group effect?

rename_int

logical; if TRUE then rather than returning median, lci and uci columns they are renamed to e.g. ⁠50%⁠, ⁠2.5%⁠, ⁠97.5%⁠; this only works if summary=TRUE

Details

If summary = TRUE, the returned object contains, for each study or group, the following 5 values: the posterior medians, the lower and upper bounds of the uncertainty intervals using the central posterior credible interval of width specified in the argument interval, the posterior mean, and the posterior standard deviation.

Value

Either an array with MCMC samples (if summary = FALSE) or a summary of these samples (if summary = TRUE). For arrays the three dimensions are: N samples, N groups and N effects (equal to 1 for the basic models).

See Also

fixed_effects for effects of covariates on outcome. To extract random effects when covariates are present, you can use either random_effects or, equivalently, group_effects(random_only=TRUE).

Examples

fit1 <- baggr(schools)
group_effects(fit1, summary = TRUE, interval = 0.5)

baggr documentation built on March 31, 2023, 10:02 p.m.