| tabmeta | R Documentation |
Fits fixed- and/or random-effects meta-analysis and returns a complete,
publication-ready report. tabmeta() accepts a binary 2-by-2 table
(a, b, c, d), event/total data, continuous summaries, rates,
correlations, or study-level effect estimates with standard errors or
confidence intervals. The default profile="auto" adds prediction,
few-study inference, subgroup/moderator results when requested,
small-study-effect diagnostics, sensitivity analyses, and figures.
tabmeta(
data = NULL,
study,
effect = NULL,
se = NULL,
lower = NULL,
upper = NULL,
a = NULL,
b = NULL,
c = NULL,
d = NULL,
event1 = NULL,
n1 = NULL,
event0 = NULL,
n0 = NULL,
mean1 = NULL,
sd1 = NULL,
mean0 = NULL,
sd0 = NULL,
event = NULL,
n = NULL,
time = NULL,
time1 = NULL,
time0 = NULL,
or = FALSE,
rr = FALSE,
rd = FALSE,
hr = FALSE,
irr = FALSE,
md = FALSE,
smd = FALSE,
prop = FALSE,
rate = FALSE,
cor = FALSE,
fixed = FALSE,
random = TRUE,
method = "REML",
hk = NULL,
small = c("auto", "adhoc", "knha", "t", "z"),
prediction = NULL,
by = NULL,
subgroup = NULL,
reg = NULL,
moderator = NULL,
bias = NULL,
bias_methods = "auto",
leaveout = NULL,
influence = NULL,
cumulative = NULL,
transform = NULL,
cc = 0.5,
zero = c("keep", "exclude"),
ci = 0.95,
digit = 2,
p_digit = 3,
profile = c("auto", "brief", "full", "custom"),
full = NULL,
plot = NULL,
plot_display = "forest",
plot_args = list(),
report = FALSE,
interpretation = FALSE,
title = NULL,
show = TRUE,
export = NULL,
file = NULL,
open = FALSE,
strict = FALSE
)
data |
Optional data frame. When omitted, active R4VN data are used. |
study |
Study label variable. |
effect |
Generic study-level effect estimate on the natural scale. |
se |
Standard error on the analysis scale. For ratio measures this is the standard error of the log effect. |
lower, upper |
Lower and upper confidence limits for |
a, b, c, d |
Binary 2-by-2 cells: events and non-events in group 1
( |
event1, n1, event0, n0 |
Events and total sample sizes in groups 1 and 0. |
mean1, sd1, mean0, sd0 |
Group means and standard deviations. |
event, n, time |
Single-group events, sample size, and person-time. |
time1, time0 |
Person-time in groups 1 and 0 for incidence-rate ratios. |
or, rr, rd, hr, irr, md, smd, prop, rate, cor |
Logical effect selectors. With raw binary input, OR is inferred if none is selected; with continuous summaries, MD is inferred. Set a selector to request another measure. |
fixed |
Fit a fixed-effect model in addition to, or instead of, the random-effects model. |
random |
Fit a random-effects model; default |
method |
Random-effects tau-squared estimator; default |
hk |
Backward-compatible logical shortcut. |
small |
Random-effects inference: |
prediction |
Add a prediction interval. |
by, subgroup |
One or more subgroup variables. Use one unquoted variable,
a character vector, or |
reg, moderator |
One or more meta-regression moderators created with
|
bias |
Assess small-study effects/publication bias. |
bias_methods |
One or more of |
leaveout |
Perform leave-one-out sensitivity analysis. |
influence |
Perform influence diagnostics. |
cumulative |
Optional variable defining the ordering for cumulative meta-analysis, usually publication year. |
transform |
Single-proportion transformation: |
cc |
Continuity correction for zero events; default |
zero |
Handling of double-zero binary studies: |
ci |
Confidence level as a proportion. |
digit |
Number of decimals for effect estimates and confidence limits,
including subgroup and meta-regression estimates. Default |
p_digit |
Number of decimals for p-values. |
profile |
Analysis profile. |
full |
Backward-compatible profile shortcut: |
plot |
Create publication-ready plots. |
plot_display |
Plot type(s) also drawn in the interactive R/RStudio Plot
pane when |
plot_args |
Named list of plot options. Supply common options directly,
or nested lists such as |
report |
Add manuscript-style results text. |
interpretation |
Add a detailed, sectioned interpretation covering the
pooled effect, heterogeneity, prediction interval, subgroup differences,
moderators, small-study effects, few-study inference, influence,
leave-one-out robustness, and cumulative evidence whenever available.
Default is |
title |
Report title. |
show |
Open the complete HTML report; default |
export |
Optional direct export format(s): |
file |
Export file or base path. The extension may determine the format. |
open |
Open the exported file. |
strict |
Stop when an optional diagnostic or figure cannot be created.
The default |
Invisibly returns an object of class r4vn_meta and r4vn_tab.
Stable publication components are available in $estimates, $tests,
$diagnostics, $models, $tables, and $metadata. The table
$tables$Statistical_tests gives the pooled-effect and Cochran's Q tests.
Its significance and conclusion columns are added only when
interpretation=TRUE. $tables$Subgroup is the transposed publication
table for the first subgroup variable, $subgroup_tables contains every
transposed subgroup table, and $subgroup_long retains tidy long output.
tabexport, vars
Other R4VN tables:
tab(),
tabexport(),
tabforest(),
tablong(),
tabmulti(),
tabscale(),
tabscore(),
tabsurvey(),
vars()
if (requireNamespace("metafor", quietly = TRUE)) {
dat <- read.csv(
system.file("extdata", "meta_example.csv", package = "R4VN")
)
# 1. Binary outcome from a, b, c, d. OR is inferred automatically.
dat$non_event_treat <- dat$n_treat - dat$event_treat
dat$non_event_control <- dat$n_control - dat$event_control
m_abcd <- tabmeta(
data = dat, study = study,
a = event_treat, b = non_event_treat,
c = event_control, d = non_event_control,
profile = "custom", plot = FALSE, show = FALSE
)
m_abcd$estimates$overall
m_abcd$tables$Binary_2x2
m_abcd$tables$Statistical_tests
m_abcd$tests$overall
m_abcd$tests$heterogeneity
plot(
m_abcd, type = "forest", show_abcd = TRUE,
abcd_titles = c("Events T", "No event T", "Events C", "No event C")
)
# 2. Equivalent event/total syntax; request RR or RD with rr/rd=TRUE.
m_or <- tabmeta(
data = dat, study = study,
event1 = event_treat, n1 = n_treat,
event0 = event_control, n0 = n_control,
or = TRUE, profile = "custom", plot = FALSE, show = FALSE
)
# 3. Complete automatic analysis: report, prediction, diagnostics, plots.
m_all <- tabmeta(
data = dat, study = study,
a = event_treat, b = non_event_treat,
c = event_control, d = non_event_control,
show = FALSE
)
# 4. Subgroup analysis: one or several subgroup variables.
m_sub <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
subgroup = region,
profile = "custom", plot = FALSE, show = FALSE
)
m_sub$tables$Subgroup
m_sub$subgroup_long
m_sub$tables$Subgroup_test
# Each subgroup row includes its effect test and heterogeneity test.
names(m_sub$tables$Subgroup)
# If the subgroup variable carries value labels, R4VN prints those labels
# instead of numeric codes. With plot=TRUE, both Viewer and Plot history
# contain the overall plot and one clearly titled plot per subgroup level.
dat$risk_group <- rep(c(1, 2), length.out = nrow(dat))
attr(dat$risk_group, "label") <- "Baseline risk"
attr(dat$risk_group, "labels") <- c("Lower risk" = 1, "Higher risk" = 2)
m_labelled <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
subgroup = risk_group, profile = "custom",
plot = TRUE, plot_display = "forest", show = FALSE
)
m_labelled$plot_titles
# Multiple subgroup analyses can be requested together.
dat$period <- ifelse(dat$year < median(dat$year), "Earlier", "Later")
m_sub2 <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
subgroup = vars(region, period),
profile = "custom", plot = FALSE, show = FALSE
)
# 5. Meta-regression with numeric and categorical moderators.
attr(dat$year, "label") <- "Publication year"
attr(dat$region, "label") <- "Geographic region"
m_reg <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
moderator = vars(c.year, region),
profile = "custom", plot = FALSE, show = FALSE
)
m_reg$tables$Meta_regression
m_reg$tables$Moderator_univariable
# Intercept is written in full; moderator labels are used when available.
# Set digit=4, for example, when four decimal places are required.
# 6. Publication-bias and small-study-effect sensitivity analyses.
m_bias <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
bias = TRUE,
bias_methods = c("egger", "begg", "trimfill", "failsafe"),
profile = "custom", plot = FALSE, show = FALSE
)
m_bias$tables$Publication_bias
m_bias$tables$Publication_bias_adjusted
# 7. Few-study inference. auto uses modified Hartung-Knapp at <=10 studies.
m_few <- tabmeta(
data = dat[1:8, ], study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
small = "auto", profile = "custom", plot = FALSE, show = FALSE
)
m_few$tables$Small_sample_inference
# 8. Generic hazard ratios with confidence intervals.
m_hr <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, hr = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
# 9. Continuous MD/SMD, single proportion/rate, correlation, and IRR.
cont <- data.frame(
study = paste0("C", 1:5),
m1 = c(12, 14, 13, 16, 15), s1 = c(3, 4, 3, 5, 4), n1 = rep(60, 5),
m0 = c(15, 15, 16, 18, 16), s0 = c(4, 4, 5, 5, 4), n0 = rep(60, 5)
)
m_md <- tabmeta(
cont, study, mean1 = m1, sd1 = s1, n1 = n1,
mean0 = m0, sd0 = s0, n0 = n0, md = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
m_smd <- tabmeta(
cont, study, mean1 = m1, sd1 = s1, n1 = n1,
mean0 = m0, sd0 = s0, n0 = n0, smd = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
one <- data.frame(
study = paste0("P", 1:5), events = c(8, 12, 15, 10, 14),
total = c(100, 110, 120, 90, 105), person_time = c(80, 90, 95, 75, 88),
correlation = c(.20, .28, .15, .31, .24)
)
m_prop <- tabmeta(
one, study, event = events, n = total, prop = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
m_rate <- tabmeta(
one, study, event = events, time = person_time, rate = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
m_cor <- tabmeta(
one, study, effect = correlation, n = total, cor = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
m_irr <- tabmeta(
dat[1:5, ], study,
event1 = event_treat, time1 = n_treat,
event0 = event_control, time0 = n_control, irr = TRUE,
profile = "custom", plot = FALSE, show = FALSE
)
# 10. Cumulative meta-analysis ordered by publication year.
m_cum <- tabmeta(
data = dat, study = study,
effect = OR, lower = LCI, upper = UCI, or = TRUE,
cumulative = year,
profile = "custom", plot = FALSE, show = FALSE
)
m_cum$tables$Cumulative
# 11. Draw or save individual publication figures.
if (interactive()) {
# plot=TRUE keeps all figures in the HTML Viewer and also draws the
# selected figures in the R/RStudio Plot pane and Plot history.
m_publication <- tabmeta(
data = dat, study = study,
a = event_treat, b = non_event_treat,
c = event_control, d = non_event_control,
interpretation = TRUE,
plot = TRUE,
plot_display = c("forest", "funnel", "trimfill"),
plot_args = list(
all = list(
font_family = "Arial", background = "white",
title_color = "#17365D", title_size = 1.1,
text_size = 0.86, axis_size = 0.92
),
forest = list(
subtitle = "Random-effects model with 95% confidence intervals",
caption = "Square size reflects study weight; diamond is pooled effect.",
margins = c(5.5, 4.2, 5.0, 2.0),
point_color = "#1F4E79", ci_color = "#5B9BD5",
summary_color = "#C00000", summary_border = "#7F0000",
point_shape = 15, row_shade = "zebra",
shade_color = "#F5F7FA", show_weights = TRUE,
weight_title = "Weight", estimate_title = "OR (95% CI)",
show_prediction = FALSE,
ref_color = "#666666", ref_type = 2,
xlim = c(0.2, 2.0), ticks = c(0.25, 0.5, 1, 1.5, 2)
),
funnel = list(
point_shape = 21, point_color = "#1F4E79",
point_bg = "#D9EAF7", point_size = 1.1,
contour_levels = c(90, 95, 99),
contour_colors = c("#FFF2CC", "#FCE4D6", "#E2F0D9"),
funnel_label = "out", funnel_legend = "topright"
)
)
)
m_publication$tables$Interpretation
# Any figure can be redrawn or saved independently.
plot(m_publication, type = "forest")
plot(m_publication, type = "funnel", contour = TRUE)
plot(m_publication, type = "trimfill", contour = TRUE)
plot(m_reg, type = "bubble", moderator = "year")
plot(
m_publication, type = "forest", file = "forest_publication.tiff",
width = 2400, height = 1800, res = 300,
font_family = "Arial", point_color = "#1F4E79",
ci_color = "#5B9BD5", summary_color = "#C00000",
show_weights = TRUE, show_prediction = FALSE,
xlim = c(0.5, 1.5), ticks = c(0.5, 0.75, 1, 1.25, 1.5)
)
# Values outside xlim remain exact in the Estimate (95% CI) column;
# the graphical confidence interval is clipped with an arrow.
m_publication$overall[c("pi_lower", "pi_upper")]
tabmeta(
data = dat, study = study,
a = event_treat, b = non_event_treat,
c = event_control, d = non_event_control,
export = c("docx", "xlsx"), file = "meta_report",
show = FALSE
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.