| Title: | Aggregate-Data Meta-Analysis with Generalized Linear Mixed Models |
|---|---|
| Description: | Extends traditional random-effects meta-analysis by embedding it within a generalized linear mixed-effects model framework. The package supports covariate adjustment and non-normal responses using aggregate data, and provides likelihood-based inference with computationally efficient likelihood evaluation. The underlying methodology is described in Hanada and Sugimoto (2026) <doi:10.1093/biomtc/ujag148>. |
| Authors: | Keisuke Hanada [aut, cre] |
| Maintainer: | Keisuke Hanada <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-10-13 13:14:22 UTC |
| Source: | https://github.com/keisuke-hanada/metaglmm |
metafor WorkflowsCreate Study-Level Data for metafor Workflows
as_metafor_data(object, estimate = NULL, vi = NULL, labels = NULL)as_metafor_data(object, estimate = NULL, vi = NULL, labels = NULL)
object |
A fitted |
estimate |
Optional study-level estimates on the link scale. |
vi |
Optional study-level sampling variances on the link scale. |
labels |
Optional study labels. |
forest.metaGLMM() uses this conversion for its study rows.
Automatic conversion is conservative; supply display estimates explicitly
when the arm-level data do not identify one unambiguous study effect.
A plain data frame with columns yi, vi, and slab. No metafor
model class is assigned.
metaGLMM Fit to Aggregate-Row DataConvert a metaGLMM Fit to Aggregate-Row Data
## S3 method for class 'metaGLMM' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'metaGLMM' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
A fitted |
row.names |
Optional row names. |
optional |
Unused. |
... |
Unused. |
A data frame containing the model frame and standardized diagnostic columns prefixed with a dot.
dataset of Chu et al. (2020)
chu2020chu2020
A data.frame for binary distributed outcome with 7 studies:
Study ID
COVID-19 events in the longer-distance group
Number of participants in the longer-distance group
COVID-19 events in the shorter-distance group
Number of participants in the shorter-distance group
Chu, D. K., Akl, E. A., Duda, S., Solo, K., Yaacoub, S., Schuenemann, H. J., et al. (2020). Physical distancing, face masks, and eye protection to prevent person-to-person transmission of SARS-CoV-2 and COVID-19: a systematic review and meta-analysis. The Lancet, 395(10242), 1973-1987. Data used under the terms of the Creative Commons Attribution IGO 3.0 License (CC BY 3.0 IGO): https://creativecommons.org/licenses/by/3.0/igo/
Legacy Confidence-Interval Dispatcher
ci_metaGLMM( object, parm = .default_ci_parm(object), method = "PLSBC", level = 0.95, renge.c = 30, correction = c("corrected", "noma"), ... )ci_metaGLMM( object, parm = .default_ci_parm(object), method = "PLSBC", level = 0.95, renge.c = 30, correction = c("corrected", "noma"), ... )
object |
A fitted |
parm |
Parameter names. |
method |
One of |
level |
Confidence level. |
renge.c |
Maximum profile bracket expansions. |
correction |
SBC correction option. |
... |
Additional low-level arguments. |
A confidence-interval matrix.
Wald Confidence Intervals
confint_AN(object, parm = .default_ci_parm(object), level = 0.95, ...)confint_AN(object, parm = .default_ci_parm(object), level = 0.95, ...)
object |
A fitted |
parm |
Parameter names. |
level |
Confidence level. |
... |
Unused. |
A two-column confidence-interval matrix.
This low-level method is retained for compatibility and remains
experimental. It is intentionally not available through confint.metaGLMM().
confint_GSBC( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, ... )confint_GSBC( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, ... )
object |
A fitted |
parm |
Parameter names. |
level |
Confidence level. |
renge.c |
Maximum number of geometric bracket expansions. |
silent |
Logical; return infinite endpoints instead of warning when a profile root cannot be bracketed. |
... |
Unused. |
A two-column confidence-interval matrix.
Profile-Likelihood Confidence Intervals
confint_PL( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, ... )confint_PL( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, ... )
object |
A fitted |
parm |
Parameter names. |
level |
Confidence level. |
renge.c |
Maximum number of geometric bracket expansions. |
silent |
Logical; return infinite endpoints instead of warning when a profile root cannot be bracketed. |
... |
Unused. |
A two-column confidence-interval matrix.
Simple Bartlett-Corrected Confidence Intervals
confint_SBC( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, correction = c("corrected", "noma"), ... )confint_SBC( object, parm = .default_ci_parm(object), level = 0.95, renge.c = 30, silent = FALSE, correction = c("corrected", "noma"), ... )
object |
A fitted |
parm |
Parameter names. |
level |
Confidence level. |
renge.c |
Maximum number of geometric bracket expansions. |
silent |
Logical; return infinite endpoints instead of warning when a profile root cannot be bracketed. |
correction |
Either |
... |
Unused. |
A two-column confidence-interval matrix.
metaGLMM FitConfidence Intervals for a metaGLMM Fit
## S3 method for class 'metaGLMM' confint( object, parm = names(stats::coef(object)), level = 0.95, method = "wald", ... )## S3 method for class 'metaGLMM' confint( object, parm = names(stats::coef(object)), level = 0.95, method = "wald", ... )
object |
A fitted |
parm |
Fixed-effect parameter names. The default is all fixed effects. |
level |
Confidence level. |
method |
One of |
... |
Additional arguments passed to the low-level interval method. |
SBC is available for built-in and custom families with estimated
heterogeneity. The correction uses the supplied study-level variances and
the heterogeneity estimate under the profile constraint, so vi must
represent an appropriate sampling variance on the link scale. Profile and
SBC intervals can be substantially more computationally expensive than
Wald intervals.
A matrix with lower and upper columns.
metaGLMM FitsForest Plots for metaGLMM Fits
forest(x, ...)forest(x, ...)
x |
A fitted |
... |
Arguments passed to a method. |
The value returned by the dispatched method. For a metaGLMM
object, the function draws a forest plot as a side effect and invisibly
returns the plotting data described in forest.metaGLMM().
Draw a Forest Plot
## S3 method for class 'metaGLMM' forest( x, estimate = NULL, vi = NULL, labels = NULL, parm = NULL, contrast = NULL, random_scale = 1, level = 0.95, type = c("link", "exp"), ci_methods = NULL, prediction = TRUE, ci_args = list(), annotate = TRUE, digits = 2L, header = NULL, xlab = NULL, pch = 15, cex = 0.9, summary_cex = max(1.1, cex * 1.2), diamond_height = 0.18, left_margin = NULL, right_margin = NULL, ... )## S3 method for class 'metaGLMM' forest( x, estimate = NULL, vi = NULL, labels = NULL, parm = NULL, contrast = NULL, random_scale = 1, level = 0.95, type = c("link", "exp"), ci_methods = NULL, prediction = TRUE, ci_args = list(), annotate = TRUE, digits = 2L, header = NULL, xlab = NULL, pch = 15, cex = 0.9, summary_cex = max(1.1, cex * 1.2), diamond_height = 0.18, left_margin = NULL, right_margin = NULL, ... )
x |
A fitted |
estimate |
Optional study-level estimates on the link scale. |
vi |
Optional study-level sampling variances on the link scale. |
labels |
Optional study labels. |
parm |
Fixed-effect name for the pooled result. |
contrast |
Optional fixed-effect contrast; used instead of |
random_scale |
Loading of heterogeneity for the pooled prediction interval. |
level |
Confidence and prediction level. |
type |
Either |
ci_methods |
One or more fixed-effect confidence-interval methods:
|
prediction |
Logical; include a prediction interval? |
ci_args |
Optional list of additional arguments passed to
|
annotate |
Logical; show forest-plot-style column headers and formatted estimates with confidence limits in the right margin? |
digits |
Number of digits after the decimal point in annotations. |
header |
Optional two-element character vector for the left and right column headers. |
xlab |
Optional horizontal-axis label. |
pch |
Plotting symbol for studies. |
cex |
Expansion factor for study labels and symbols. |
summary_cex |
Expansion factor for pooled and prediction labels and symbols. |
diamond_height |
Half-height of the pooled confidence-interval diamond in plot-row units. |
left_margin |
Optional left margin in inches. The default measures the rendered labels and enlarges the current device margin when necessary. |
right_margin |
Optional right margin in inches. The default measures
the formatted annotations when |
... |
Additional arguments passed to |
With omitted display vectors, study estimates and variances are
obtained through as_metafor_data(). Automatic extraction is used only
when the fitted data unambiguously define one estimate per independent
study. Otherwise, estimate, vi, and optionally labels must be
supplied. For a grouped treatment-slope model, the pooled coefficient is
selected automatically when exactly one model-matrix column represents
the random-effect treatment loading. Display estimates are conceptually
separate from the likelihood used for fitting.
Selected fixed-effect confidence intervals and the plug-in prediction
interval are drawn as filled diamonds. Profile and SBC intervals require
parm; arbitrary contrast values are supported only for Wald intervals.
The prediction interval is the package's Wald-type plug-in interval, not a
profile- or Bartlett-corrected prediction interval. Plot margins are
enlarged automatically for labels, headers, and numeric annotations.
Invisibly, a data frame containing the data used to draw the plot,
with one row for each study, requested pooled confidence interval, and
optional prediction interval. The columns are kind (the row type:
"study", "pooled", or "prediction"), label (the displayed row
label), estimate (the point estimate), lower and upper (the interval
limits), and method (the confidence-interval method, "prediction", or
NA for study rows). Estimates and limits are on the link scale when
type = "link" and are exponentiated when type = "exp". The forest plot
is drawn as a side effect.
Evaluate the aggregate-data GLMM negative log likelihood.
likelihood( formula, data, vi, ni, beta, tau2, family = stats::binomial(link = "logit"), tau2.min = 1e-06, re_group = NULL, trt = NULL, rstdnorm = stats::qnorm((qrng::sobol(5000, d = 1, scrambling = 1) * 4999 + 0.5)/5000) )likelihood( formula, data, vi, ni, beta, tau2, family = stats::binomial(link = "logit"), tau2.min = 1e-06, re_group = NULL, trt = NULL, rstdnorm = stats::qnorm((qrng::sobol(5000, d = 1, scrambling = 1) * 4999 + 0.5)/5000) )
formula |
Model formula. |
data |
Data frame or model frame containing the response and covariates. |
vi |
Sampling variances. |
ni |
Information multipliers (sample sizes for binomial/Poisson aggregate data). |
beta |
Fixed-effect coefficient vector. |
tau2 |
Between-row/group variance. |
family |
A stats family or |
tau2.min |
Lower numerical bound used while estimating tau2. |
re_group |
Optional grouping variable for a shared random slope. |
trt |
Optional name of a binary treatment/loading column. |
rstdnorm |
Standard-normal quadrature or quasi-Monte Carlo draws. |
A scalar negative log likelihood.
dataset of Long et al. (2020)
long2020long2020
A data.frame for gamma distributed outcome with 5 studies:
Study ID
Mean of intensive care unit (ICU) length of stay (LoS)
Standard deviation of ICU LoS
Number of subjects
Treatment indicator: 1 for treatment and 0 for control
Long, R., Tian, J., Wu, S., Li, Y., Yang, X., & Fei, J. (2020). Clinical efficacy of surgical versus conservative treatment for multiple rib fractures: a meta-analysis of randomized controlled trials. International Journal of Surgery, 83, 79-88. Data used under the terms of the Creative Commons Attribution 4.0 International License (CC BY 4.0): https://creativecommons.org/licenses/by/4.0/
metaGLMM().The formal argument names are exactly the columns of model.matrix() (plus
tau2 when it is estimated), which makes factor and interaction models safe
for optimizers such as bbmle::mle2().
make_ll_fun( formula, data, vi, ni, tau2, family, tau2_var = FALSE, tau2.min = 1e-06, re_group = NULL, trt = NULL, rstdnorm = stats::qnorm((qrng::sobol(5000, d = 1, scrambling = 1) * 4999 + 0.5)/5000), ... )make_ll_fun( formula, data, vi, ni, tau2, family, tau2_var = FALSE, tau2.min = 1e-06, re_group = NULL, trt = NULL, rstdnorm = stats::qnorm((qrng::sobol(5000, d = 1, scrambling = 1) * 4999 + 0.5)/5000), ... )
formula |
Model formula. |
data |
Model data. |
vi |
Sampling variances. |
ni |
Information multipliers. |
tau2 |
Fixed or starting between-study variance. |
family |
A stats family or |
tau2_var |
Whether tau2 is an optimizer parameter. |
tau2.min |
Numerical lower bound for estimated tau2. |
re_group |
Optional grouping variable. |
trt |
Optional binary loading column name. |
rstdnorm |
Standard-normal quasi-Monte Carlo draws. |
... |
Additional compatibility arguments (including |
A function suitable for bbmle::mle2().
Custom families intentionally use the QMC path (fast = FALSE) so their
callback remains the single source of truth for the likelihood.
make_ll_fun.fast( formula, data, vi, ni, tau2, family, tau2_var = FALSE, tau2.min = 1e-06, re_group = NULL, trt = NULL, ghq_Q = 1000L, ... )make_ll_fun.fast( formula, data, vi, ni, tau2, family, tau2_var = FALSE, tau2.min = 1e-06, re_group = NULL, trt = NULL, ghq_Q = 1000L, ... )
formula |
Model formula. |
data |
Model data. |
vi |
Sampling variances. |
ni |
Information multipliers. |
tau2 |
Fixed or starting between-study variance. |
family |
A stats family or |
tau2_var |
Whether tau2 is an optimizer parameter. |
tau2.min |
Numerical lower bound for estimated tau2. |
re_group |
Optional grouping variable. |
trt |
Optional binary loading column name. |
ghq_Q |
Number of Gauss-Hermite quadrature nodes. |
... |
Additional compatibility arguments (including |
A function suitable for bbmle::mle2().
Fits the aggregate-data generalized linear mixed model described by Hanada
and Sugimoto (2026). The optimizer is provided by bbmle::mle2(), but the
returned object has a stable metaGLMM S3 interface.
metaGLMM( formula, data, vi, ni, tau2 = NA_real_, family = stats::gaussian(), tau2_var = TRUE, re_group = NULL, trt = NULL, rstdnorm = NULL, skip.hessian = FALSE, fast = TRUE, ghq_Q = 1000L, method_opt = NULL, start_beta = NULL, start_tau2 = NULL, tau2_param = c("tau2", "log_tau2"), control = NULL, ... )metaGLMM( formula, data, vi, ni, tau2 = NA_real_, family = stats::gaussian(), tau2_var = TRUE, re_group = NULL, trt = NULL, rstdnorm = NULL, skip.hessian = FALSE, fast = TRUE, ghq_Q = 1000L, method_opt = NULL, start_beta = NULL, start_tau2 = NULL, tau2_param = c("tau2", "log_tau2"), control = NULL, ... )
formula |
A model formula. |
data |
A data frame containing the variables in |
vi |
A numeric vector of aggregate-data variances or dispersion values. |
ni |
A numeric vector of sample sizes, denominators, or exposures. |
tau2 |
A fixed between-study variance when |
family |
A supported |
tau2_var |
Logical; estimate the between-study variance? |
re_group |
Optional grouping vector. When supplied, observations in a
group share the scalar random treatment effect defined by |
trt |
Optional single column name in |
rstdnorm |
Optional numeric integration points on the standard-normal scale for quasi-Monte Carlo integration. |
skip.hessian |
Logical; skip calculation of the Hessian? |
fast |
Logical; use closed-form Gaussian integration or compiled Gauss-Hermite quadrature for built-in families? |
ghq_Q |
Positive integer number of Gauss-Hermite quadrature points. |
method_opt |
Optional optimizer name passed to |
start_beta |
Optional numeric vector or list of fixed-effect starts.
Named values must exactly match |
start_tau2 |
Starting value for the between-study variance. |
tau2_param |
Internal parameterization for estimated heterogeneity:
either |
control |
Optional optimizer control list. |
... |
Additional arguments passed to |
Construction fails before optimization for empty, non-finite, or rank-deficient model designs and for invalid grouped random-effect or custom-family contracts. Non-convergence produces a warning; boundary heterogeneity and unavailable Hessian or covariance information remain available as object diagnostics.
An object of class metaGLMM. Its integration component records
the integration method and QMC provenance without storing the integration
vector. Its convergence component records optimizer, Hessian, covariance,
and boundary diagnostics.
Hanada, K. and Sugimoto, T. (2026). Random-effects meta-analysis via generalized linear mixed models: A Bartlett-corrected approach for few studies. Biometrics. doi:10.1093/biomtc/ujag148.
Create a custom aggregate-data family specification.
metaGLMM_family( name, link = "identity", loglik, validate = NULL, initialize = NULL )metaGLMM_family( name, link = "identity", loglik, validate = NULL, initialize = NULL )
name |
Family name used in printed output. |
link |
A link name accepted by |
loglik |
A function with arguments |
validate |
Optional function used to validate response and design inputs. |
initialize |
Optional family-specific initialization function. |
The link callbacks and loglik must be vectorized and free of
side effects. metaGLMM() probes the callbacks at its deterministic
starting linear predictor before optimization and rejects non-numeric,
incorrectly sized, or non-finite results.
An object inheriting from metaGLMM_family and family.
mle2 FitExtract the Internal mle2 Fit
mle2_fit(object)mle2_fit(object)
object |
A fitted |
The internal bbmle::mle2() object.
metaGLMM FitPredict from a metaGLMM Fit
## S3 method for class 'metaGLMM' predict( object, newdata = NULL, type = c("link", "response", "exp"), interval = c("none", "confidence", "prediction"), level = 0.95, contrast = NULL, random_scale = NULL, ... )## S3 method for class 'metaGLMM' predict( object, newdata = NULL, type = c("link", "response", "exp"), interval = c("none", "confidence", "prediction"), level = 0.95, contrast = NULL, random_scale = NULL, ... )
object |
A fitted |
newdata |
Optional data frame of covariate patterns. |
type |
Output scale: |
interval |
One of |
level |
Confidence or prediction level. |
contrast |
Optional numeric contrast vector or matrix against the fixed
effects. It cannot be combined with |
random_scale |
Optional loading of the future scalar random effect. |
... |
Unused. |
A prediction interval targets a future underlying study-specific
true effect. It combines fixed-effect uncertainty with tau2; it does not
add the sampling variance of a future observed estimator.
A numeric vector when interval = "none"; otherwise a data frame
with fit, lower, and upper columns.
Evaluate a Profile-Likelihood Ratio
profile_ll(value, object, parm)profile_ll(value, object, parm)
value |
Numeric parameter values. |
object |
A fitted |
parm |
One fixed-effect parameter name. |
Profile likelihood-ratio statistics.
Evaluate a Simple Bartlett-Corrected Profile Ratio
profile_ll_sbc(value, object, parm, correction = c("corrected", "noma"))profile_ll_sbc(value, object, parm, correction = c("corrected", "noma"))
value |
Numeric parameter values. |
object |
A fitted |
parm |
One fixed-effect parameter name. |
correction |
Either |
Corrected profile likelihood-ratio statistics.
dataset of Rutter et al. (2021)
rutter2021rutter2021
A data.frame for Poisson distributed outcome with 11 studies:
Study ID
Publishing year
Sex (Female or Male)
Number of events
Total observation time
Rutter, M., Bowley, J., Lanyon, P. C., Grainge, M. J., & Pearce, F. A. (2021). A systematic review and meta-analysis of the incidence rate of Takayasu arteritis. Rheumatology, 60(11), 4982-4990. Data used under the terms of the Creative Commons Attribution 4.0 International License (CC BY 4.0): https://creativecommons.org/licenses/by/4.0/
metaGLMM FitSummarize a metaGLMM Fit
## S3 method for class 'metaGLMM' summary(object, ...)## S3 method for class 'metaGLMM' summary(object, ...)
object |
A fitted |
... |
Unused. |
An object of class summary.metaGLMM.