*! version 2.0.0 31mar2026

Title

midas metareg -- Bivariate meta-regression for DTA meta-analysis

Syntax

midas metareg tp fp fn tn
, id(varname) covariates(varlist)
[options]

Required
id(varname) study identifier variable

covariates(varlist) study-level covariate(s)

Covariate targets
senonly covariates affect sensitivity only

speonly covariates affect specificity only

default covariates affect both Se and Sp

Binary SROC subgroup estimator
subestimator(name) estimator for subgroup fits; default mle

name is one of mle, inla, or hmc

INLA options (when subestimator(inla))
rpath(string) full path to Rscript executable

HMC options (when subestimator(hmc))
standir(string) path to CmdStan installation

modelfile(string) Stan model filename

outputfile(string) HMC output file prefix

chains(#) number of MCMC chains; default 4

warmup(#) warmup iterations per chain; default 1000

iter(#) total iterations per chain; default 10000

thin(#) thinning interval; default 10

seed(#) random seed; default 12345

subcovariance(name) prior covariance family for HMC

Output
level(#) confidence level; default 95

nograph suppress graphical output

savetable(filename) save results as LaTeX

noisily show meglm iteration output

senonly and speonly are mutually exclusive.

Description

midas metareg extends the bivariate random-effects model by adding
study-level covariates:

logit(Sei) = mu1 + beta1 * Xi + u1i

logit(Spi) = mu2 + beta2 * Xi + u2i

The joint model is fitted via meglm with binomial family, logit link,
and unstructured random effects. This is the natural extension of
Reitsma et al. (2005).

Graphical output depends on the covariate type:

Continuous covariates: Bubble plot with study-level Se/Sp
points sized by sample size, overlaid with predicted regression lines.

Binary covariates (exactly 2 levels): Comparative SROC plot
with summary operating points, 95% confidence ellipses (solid), and 95%
prediction ellipses (dashed) for each subgroup. The prediction ellipses
use the residual between-study heterogeneity (tau-squared) from the joint
meta-regression model.

The binary SROC plot fits a separate bivariate model per subgroup to
obtain subgroup-specific summary points and confidence regions. By
default these use meglm (MLE), but for small subgroups where MLE
may not converge, you can specify subestimator(inla) or
subestimator(hmc) to use R-INLA or CmdStan instead.

Options

Covariate targets

senonly restricts covariates to affect sensitivity only.
The specificity equation retains only its intercept.

speonly restricts covariates to affect specificity only.

Binary SROC subgroup estimator

subestimator(name) specifies the estimation method for the
per-subgroup fits in the binary SROC plot. This does NOT affect the
joint meta-regression (which always uses meglm).

mle (default) fits each subgroup via meglm. Fast but
may fail for small k (< 8 studies).

inla fits each subgroup via midas inla. Robust for
small k; requires R + R-INLA.

hmc fits each subgroup via midas hmc. Robust for
small k; requires CmdStan.

rpath(string) specifies the full path to the Rscript
executable. Required when subestimator(inla) is specified.

standir(string) specifies the CmdStan installation path.
Required when subestimator(hmc) is specified.

subcovariance(name) specifies the prior covariance family for
HMC subgroup fits (e.g., cholesky, iwishart).

Output

nograph suppresses both bubble plots and SROC plots.

savetable(filename) writes a LaTeX table with regression
coefficients, standard errors, z-statistics, p-values, and 95% CIs.

Stored results

midas metareg stores the following in e():

Scalars

e(ll) log-likelihood

e(AIC) Akaike information criterion

e(BIC) Bayesian information criterion

e(N) number of studies

e(ncov) number of covariates

Macros

e(covariates) covariate variable names

e(estimator) metareg

e(package) midas

e(cmd) midas_metareg

Examples

Setup:

. use http://fmwww.bc.edu/repec/bocode/m/midas_example_data.dta, clear

. label define lbl 0 "Not blinded" 1 "Blinded"

. label values blinded lbl

Continuous covariate (bubble plot):

. midas metareg tp fp fn tn, id(author) covariates(year)

Binary covariate (comparative SROC with MLE subgroups):

. midas metareg tp fp fn tn, id(author) covariates(blinded)

Binary covariate with INLA subgroup fits (small-k robust):

. midas metareg tp fp fn tn, id(author) covariates(patient) subestimator(inla) rpath("C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe")

Binary covariate with HMC subgroup fits:

. midas metareg tp fp fn tn, id(author) covariates(period) subestimator(hmc) standir("C:/Users/dwame/.cmdstan/cmdstan-2.38.0") modelfile("midas.stan") outputfile("mr")

Sensitivity-only regression:

. midas metareg tp fp fn tn, id(author) covariates(qscore) senonly

Multiple covariates (no graph):

. midas metareg tp fp fn tn, id(author) covariates(year qscore pmet) nograph

Save LaTeX table:

. midas metareg tp fp fn tn, id(author) covariates(blinded) savetable(tables/tab_metareg_blind.tex)

Likelihood ratio test (metareg vs base MLE):

. midas mle tp fp fn tn, id(author)

. estimates store base

. midas metareg tp fp fn tn, id(author) covariates(blinded)

. di "LRT chi2 = " 2*(e(ll) - el("base","ll")) " (df=2, p=" chi2tail(2, 2*(e(ll)-el("base","ll"))) ")"

Methods

The meta-regression model adds fixed covariate effects to the bivariate
GLMM. The joint model is:

yij | ui ~ Binomial(nij, piij)

logit(piij) = muj + betaj*Xi + uij

(ui1, ui2)' ~ N(0, Sigma)

where j=1 for sensitivity, j=2 for specificity. The residual
heterogeneity tau-squared is the variance of u after adjusting for X.

For the binary SROC plot, confidence ellipses use the fixed-effects VCE
of (logit Se, logit Sp) per subgroup. Prediction ellipses add the
residual tau-squared from the joint model. Both are computed on the
logit scale via Cholesky decomposition with chi-squared(2, 0.95) = 5.991
scaling, then transformed to probability/FPR space through invlogit.

References

Reitsma JB, et al. (2005). Bivariate analysis of sensitivity and
specificity produces informative summary measures in diagnostic reviews.
Journal of Clinical Epidemiology 58:982-990.

Harbord RM, et al. (2007). A unifying model for meta-analysis of
diagnostic accuracy studies. Biostatistics 8:239-251.

Also see

midas, midas_subgroup, midas_mle, meglm

Author

Ben Adarkwa Dwamena, MD

University of Michigan / BennyBeauBooks