*! version 2.0.0 31mar2026

Title

midas subgroup -- Stratified subgroup analysis with comparative SROC for DTA meta-analysis

Syntax

midas subgroup tp fp fn tn
, id(varname) by(varname)
[options]

Required
id(varname) study identifier variable

by(varname) subgroup variable (2-10 levels)

Estimation
estimator(name) estimation method; default mle

name is one of mle, qrsim, hmc, or inla

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

HMC options (when estimator(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

covariance(name) prior covariance family for HMC

Output
level(#) confidence level; default 95

hetstats include heterogeneity statistics

hsroc include HSROC parameterization

nograph suppress the comparative SROC plot

savetable(filename) save comparison table as LaTeX

plottype(name) plot type; default sroc

Description

midas subgroup performs stratified subgroup analysis by fitting a
separate bivariate random-effects model within each level of by().
It produces:

1. A summary comparison table (console + optional LaTeX)

2. A comparative SROC plot with summary operating points, 95%
confidence ellipses (solid lines), and 95% prediction ellipses
(dashed lines) for each subgroup

3. An embedded summary table in the graph note

The confidence ellipses are computed on the logit scale using the
Cholesky decomposition of the fixed-effects variance-covariance
matrix, then mapped to probability space via the inverse logit
transform. The prediction ellipses add between-study heterogeneity
(tau-squared) to the confidence variance, reflecting the expected
range of a new study.

Options

Estimation

estimator(name) specifies the method for fitting the bivariate
model within each subgroup. mle (default) uses maximum likelihood
via meglm. qrsim uses quasi-random simulated likelihood.
inla uses integrated nested Laplace approximation via R-INLA.
hmc uses Hamiltonian Monte Carlo via CmdStan.

rpath(string) specifies the full path to the Rscript
executable. Required when estimator(inla) is specified.
Example: rpath("C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe").

standir(string) specifies the path to the CmdStan installation
directory. Required when estimator(hmc) is specified.

covariance(name) specifies the prior covariance family for HMC.
Options include cholesky, iwishart, spherical, etc.

Output

nograph suppresses the comparative SROC plot.

savetable(filename) saves the subgroup comparison table as a
LaTeX file that can be included in an Overleaf document via
\input{tables/filename}.

Stored results

midas subgroup stores the following in r():

Scalars

r(ngroups) number of subgroups

Macros

r(groups) subgroup level values

r(grpnames) subgroup label names

r(by) name of the subgroup variable

r(estimator) estimation method used

Matrices

r(subgroup) k x 7 matrix: N, Se, Sp, LR+, LR-, DOR per group

Examples

Setup:

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

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

. label values blinded lblblinded

Subgroup by blinding (MLE):

. midas subgroup tp fp fn tn, id(author) by(blinded) estimator(mle)

Subgroup by blinding (INLA, better for small k):

. midas subgroup tp fp fn tn, id(author) by(blinded) estimator(inla) rpath("C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe")

Subgroup by blinding (HMC):

. midas subgroup tp fp fn tn, id(author) by(blinded) estimator(hmc) standir("C:/Users/dwame/.cmdstan/cmdstan-2.38.0") modelfile("midas.stan") outputfile("sg") covariance(cholesky)

Save LaTeX table:

. midas subgroup tp fp fn tn, id(author) by(blinded) estimator(mle) savetable(tables/tab_sg_blind.tex)

Also see

midas, midas_metareg, midas_mle, midas_inla, midas_hmc

Author

Ben Adarkwa Dwamena, MD

University of Michigan / BennyBeauBooks