| metareg | R Documentation |
Performs inverse-variance weighted fixed- and random-effects meta-analysis across multiple studies supplied in wide format.
metareg(data, N, verbose = FALSE, prefixb = "b", prefixse = "se")
data |
A data frame containing regression coefficients and standard errors in wide format. |
N |
Integer. Number of studies included in the meta-analysis. |
verbose |
Logical. If |
prefixb |
Character. Prefix for regression coefficients.
Default is |
prefixse |
Character. Prefix for standard errors.
Default is |
The function is designed for high-throughput settings (e.g. GWAS), where each row represents an independent meta-analysis.
The function accepts wide-format input with estimates
b_1,\ldots,b_N and standard errors se_1,\ldots,se_N.
Missing values are automatically ignored on a per-row basis.
For k studies, inverse-variance weights are defined as
w_i = 1 / se_i^2
The pooled estimate is
\beta_f = \frac{\sum_i b_i w_i}{\sum_i w_i}
with standard error
se_f = \sqrt{1 / \sum_i w_i}
and test statistic
z_f = \beta_f / se_f
with p-value
p_f = 2\,\Phi(-|z_f|)
.
Cochran's Q statistic:
Q = \sum_i w_i (b_i - \beta_f)^2
Between-study variance:
\tau^2 = \max\left(0, \frac{Q - (k-1)}{\sum w_i - \sum w_i^2 / \sum w_i}\right)
Corrected weights:
w_i^* = 1 / (1/w_i + \tau^2)
Random-effects pooled estimate:
\beta_r = \frac{\sum_i b_i w_i^*}{\sum_i w_i^*}
with standard error
se_r = \sqrt{1/\sum_i w_i^*}
and p-value
p_r = 2\,\Phi(-|z_r|)
.
Heterogeneity p-value:
p_{heter} = P(\chi^2_{k-1} > Q)
.
The heterogeneity statistic is reported as
I^2 = \max(0, (Q-(k-1))/Q)
.
A data frame with one row per meta-analysis containing:
beta_f Fixed-effects pooled estimate
se_f Standard error of fixed-effects estimate
z_f Z statistic (fixed effects)
p_f P value (fixed effects)
beta_r Random-effects pooled estimate
se_r Standard error of random-effects estimate
z_r Z statistic (random effects)
p_r P value (random effects)
p_heter Cochran's Q heterogeneity test p-value
i2 I^2 heterogeneity statistic
k Number of studies contributing to each row
eps Smallest double-precision number used for stability
ChatGPT
higgins03gap
## Not run:
df <- data.frame(
b1 = 1, se1 = 2,
b2 = 2, se2 = 6,
b3 = 3, se3 = 8
)
metareg(df, 3)
df2 <- data.frame(
b1 = c(1,2), se1 = c(2,4),
b2 = c(2,3), se2 = c(4,6),
b3 = c(3,4), se3 = c(6,8)
)
metareg(df2, 3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.