| funnel.brma | R Documentation |
funnel.brma creates a funnel plot for a fitted brma object.
For intercept-only models without scale regression, the default outcome mode
displays observed effect sizes against the fitted sampling distribution. For
models with location or scale moderators, the default residual mode displays
residuals against a standard-error funnel.
## S3 method for class 'brma'
funnel(
x,
residual,
type = "LOO-PIT",
unit = "estimate",
conditioning_depth = "marginal",
sampling_heterogeneity = TRUE,
sampling_bias = TRUE,
max_samples = 10000,
plot_type = "base",
...
)
x |
a fitted brma object |
residual |
whether to use residual mode. Defaults to not specified, which means the function automatically determines the mode:
|
type |
the type of residuals to use when in residual mode. Options are:
Only used when funnel is in residual mode. |
unit |
output unit for residual mode. Only |
conditioning_depth |
residual conditioning depth for residual mode.
Options are |
sampling_heterogeneity |
whether heterogeneity should be incorporated
into the sampling distribution funnel. Defaults to |
sampling_bias |
whether publication bias should be incorporated into the
sampling distribution funnel. Defaults to |
max_samples |
maximum number of posterior samples used for
model-averaged publication-bias funnel contours. Defaults to |
plot_type |
whether to use a base plot |
... |
additional graphical arguments to customize the plot appearance:
|
The funnel plot has two modes. If residual is not specified, the mode
is chosen automatically from the fitted model: intercept-only models without
scale regression use outcome mode, whereas models with location or scale
moderators use residual mode.
Outcome mode (intercept-only models without scale regression):
Displays observed effect sizes on the x-axis and standard errors on the
y-axis. The reference line follows the center of the fitted sampling
distribution. When sampling_bias = FALSE, this center is the pooled
effect; when PET/PEESE bias adjustment is incorporated, the center line can
vary with the standard error. The funnel region represents the central 95\
region of the sampling distribution, optionally incorporating heterogeneity
and publication bias.
Residual mode (models with moderators or scale regression):
Displays residuals on the x-axis and standard errors on the
y-axis. The funnel region represents the central 95\
N(0, \mathrm{SE}^2). With type = "LOO-PIT", the plotted
residuals and standard errors are the raw-scale LOO predictive companions
returned by rstudent.brma; the PIT-normalized z values
are used by qqnorm.brma and influence diagnostics. With
type = "rstandard", the plotted values are internally standardized
residual companions from rstandard.brma. With
type = "outcome", these are raw outcome residuals. Under a correctly
specified model, most points should fall within this region.
The type argument controls how residuals are computed in residual
mode. See residuals.brma for details on each type.
The sampling_heterogeneity and sampling_bias arguments are
ignored in residual mode.
For GLMM models, observed effect sizes are computed from the raw frequency
data using formulas equivalent to metafor::escalc. Residual-mode
GLMM funnels use approximate effect-size-scale residual/PIT companions, not
exact PIT diagnostics for the raw count likelihood.
If as_data = TRUE, funnel.brma returns a list with the
data used for plotting, including the plotted points, funnel polygons,
plotting limits, labels, and reference line. Otherwise, it returns
NULL invisibly if plot_type = "base" or a ggplot object if
plot_type = "ggplot".
residuals.brma(), rstandard.brma(), rstudent.brma(),
predict.brma()
## 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, data = dat, measure = "RR")
funnel(fit)
funnel(fit, pch = 19, col = "blue", bg = "lightblue")
fit_reg <- brma(
yi = yi,
vi = vi,
mods = ~ ablat + year,
data = dat,
measure = "RR"
)
fit_reg <- add_loo(fit_reg)
funnel(fit_reg)
funnel(fit_reg, type = "outcome")
funnel_data <- funnel(fit, as_data = TRUE)
funnel(fit, plot_type = "ggplot")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.