Performs inverse-variance weighted fixed- and random-effects meta-analysis across multiple studies supplied in wide format.
Arguments
- 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
TRUE, prints a completion message.- prefixb
Character. Prefix for regression coefficients. Default is
"b"(columnsb1, b2, …, bN).- prefixse
Character. Prefix for standard errors. Default is
"se"(columnsse1, se2, …, seN).
Value
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
Details
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.
Fixed effects model
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|)$$.
Random effects model (DerSimonian–Laird)
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)$$.
References
Higgins JP, Thompson SG, Deeks JJ, Altman DG (2003). “Measuring inconsistency in meta-analyses.” BMJ, 327(7414), 557-60. doi:10.1136/bmj.327.7414.557 .
Examples
if (FALSE) { # \dontrun{
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)
} # }