| predict.brma | R Documentation |
predict.brma predicts values
## S3 method for class 'brma'
predict(
object,
newdata = NULL,
type = "terms",
as_measure = TRUE,
output_measure = NULL,
transform = NULL,
probs = c(0.025, 0.975),
bias_adjusted = FALSE,
quiet = FALSE,
conditional = FALSE,
...
)
object |
a fitted brma object |
newdata |
specification for prediction data. Defaults to
|
type |
type of prediction to be performed. Options are:
|
as_measure |
logical; whether to convert GLMM response predictions from
simulated counts to continuity-corrected effect-size estimators (logOR for
binomial, logIRR for Poisson). Defaults to |
output_measure |
effect-size measure for location/effect predictions.
Defaults to the fitted measure. Supported conversions are among |
transform |
optional display transformation. Currently |
probs |
quantiles of the posterior samples to be displayed when the
returned |
bias_adjusted |
whether predictions should adjust for publication bias.
Defaults to
When
|
quiet |
logical; whether to suppress informational messages about prediction scale and bias adjustment. |
conditional |
whether to return conditional posterior predictions for
RoBMA product-space objects. For location predictions, samples are conditioned
on the effect component; for |
... |
additional arguments |
Type hierarchy:
"terms": mu (fixed effects only)
"cluster": mu + gamma (adds cluster-level random effect)
"estimate": mu + gamma + theta (adds estimate-level random effect)
"response": mu + gamma + theta + epsilon (adds sampling error)
For existing normal observations, type = "estimate" reports the
conditional BLUP mean E(\theta_i \mid y_i, \mu_i, \tau_i) for each
posterior draw. It is therefore an empirical-Bayes summary, not a draw from
the full latent-effect posterior \theta_i \mid y_i. For new data,
estimate-level random effects are sampled from their model distribution.
For RoBMA product-space objects, conditional posterior predictions subset
posterior rows according to model indicators. This removes the original
chain structure, so returned brma_samples objects are intentionally
stored as one flattened chain.
Note that in contrast to predict, the type = "response" produces
predictions for the new effect size estimates. To obtain results corresponding to
metafor's predict function, use type = "terms" for the mean effect size
and type = "estimate" for true effects (prediction interval).
Likelihood weights: If the model was fitted with weights,
the weights affect the posterior fit, log-likelihood, LOO/WAIC, and
existing-data conditional diagnostics such as BLUP shrinkage and leverage.
They do not change the observation-level sampling error used by
type = "response" for normal models: response predictions simulate
raw future effect-size estimates with the supplied sei, not
sei / sqrt(weight).
A brma_samples object containing posterior samples. When printed,
displays a summary table via BayesTools::ensemble_estimates_table. The
underlying samples matrix can be accessed directly (the object inherits from matrix)
or via summary() to obtain the summary table. The samples can also be converted
to posterior draws formats using as_draws() and related functions.
pooled_effect(), pooled_heterogeneity(), blup()
## Not run:
if (requireNamespace("metadat", quietly = TRUE) &&
requireNamespace("metafor", quietly = TRUE)) {
data(dat.bcg, package = "metadat")
dat <- metafor::escalc(
measure = "RR",
ai = tpos,
bi = tneg,
ci = cpos,
di = cneg,
data = dat.bcg
)
fit <- brma(
yi = yi,
vi = vi,
mods = ~ ablat + year,
data = dat,
measure = "RR",
seed = 1,
silent = TRUE
)
predict(fit, type = "terms")
predict(fit, newdata = TRUE, type = "terms")
predict(fit, type = "estimate")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.