effect_draw: Make predictive draws from baggr model

View source: R/trt_effects.R

effect_drawR Documentation

Make predictive draws from baggr model


This function takes the samples of hyperparameters from a baggr model (typically hypermean and hyper-SD, which you can see using treatment_effect) and draws values of new realisations of treatment effect, i.e. an additional draw from the "population of studies". This can be used for both prior and posterior draws, depending on baggr model.


  transform = NULL,
  summary = FALSE,
  message = TRUE,
  interval = 0.95



A baggr class object.


How many values to draw? The default is as long as the number of samples in the baggr object (see Details).


a transformation (an R function) to apply to the result of a draw.


logical; if TRUE returns summary statistics rather than samples from the distribution;


logical; use to disable messages prompted by using with no pooling models


uncertainty interval width (numeric between 0 and 1), if summary=TRUE


The predictive distribution can be used to "combine" heterogeneity between treatment effects and uncertainty in the mean treatment effect. This is useful both in understanding impact of heterogeneity (see Riley et al, 2011, for a simple introduction) and for study design e.g. as priors in analysis of future data (since the draws can be seen as an expected treatment effect in a hypothetical study).

The default number of samples is the same as what is returned by Stan model implemented in baggr, (depending on such options as iter, chains, thin). If n is larger than what is available in Stan model, we draw values with replacement. This is not recommended and warning is printed in these cases.

Under default settings in baggr, a posterior predictive distribution is obtained. But effect_draw can also be used for prior predictive distributions when setting ppd=T in baggr. The two outputs work exactly the same way.


A vector (with n values) for models with one treatment effect parameter, a matrix (n rows and same number of columns as number of parameters) otherwise.


Riley, Richard D., Julian P. T. Higgins, and Jonathan J. Deeks. "Interpretation of Random Effects Meta-Analyses". BMJ 342 (10 February 2011)..

See Also

treatment_effect returns samples of hypermean and hyper-SD which are used by this function

baggr documentation built on March 18, 2022, 7:02 p.m.