*! sim_longmeta.sthlp metaLong for Stata 14.1

sim_longmeta — Simulate a Longitudinal Meta-Analytic Dataset

Syntax

sim_longmeta [,
k()
times()
mu()
tau()
vlow()
vhigh()
missing()
nocovariates
seed()
saving()
replace
clear]

Description

sim_longmeta generates a synthetic long-format dataset of effect sizes
across multiple follow-up time points and studies. It is designed to test and
illustrate all metaLong commands without requiring real data.

The data-generating model is:

theta_it = mu + u_i + epsilon_it

where mu is the true (common) mean effect, u_i ~ N(0, tau²) is a
study-level random effect that induces within-study correlation across time
points, and epsilon_it ~ N(0, vi) is independent sampling error.
Sampling variances vi are drawn uniformly from [vlow(), vhigh()].

Options

k() specifies the number of studies. Default is 20.

times() specifies the follow-up time points as an ascending
numeric list. Default is 0 6 12 24.

mu() specifies the true mean effect, shared across all time
points. Default is 0.4. To simulate a time-varying true effect, generate the
data from sim_longmeta and then manually replace yi values.

tau() specifies the between-study standard deviation.
Default is 0.2.

vlow() and vhigh() specify the lower and
upper bounds for the uniform distribution of sampling variances. Defaults are
0.02 and 0.12.

missing() specifies the proportion of study × time cells to
drop (simulating incomplete follow-up). Must be in [0, 1). Default is 0 (none).

nocovariates suppresses generation of the study-level covariates
pub_year, quality, and n. By default these are generated and
are used by ml_benchmark.

seed() sets the random number seed for reproducibility.
Default is −1 (no seed set). Pass any non-negative integer for a fixed seed.

saving() saves the dataset to filename.dta.

replace allows overwriting an existing saving() file.

clear clears any data currently in memory before generating the new
dataset. If omitted and there is data in memory, the command preserves the
original data (using preserve/restore), which means the generated dataset
is in memory only if saving() is also specified.

Generated variables

study Study identifier string, e.g. "s01", "s02", …

time Follow-up time (numeric)

yi Observed effect size

vi Sampling variance

pub_year Publication year (2000-2022); dropped with nocovariates

quality Study quality score (standard normal); omitted with nocovariates

n Study sample size (uniform 30-500);
omitted with nocovariates

Examples

Basic usage — generate and keep in memory:

. sim_longmeta, k(20) times(0 6 12 24) seed(42) clear

. list in 1/8

Save to file:

. sim_longmeta, k(15) times(0 3 6 12) mu(0.3) tau(0.3) ///

seed(99) saving(simdata) replace clear

With missing data (20% missing study × time cells):

. sim_longmeta, k(30) times(0 6 12 24) missing(0.20) seed(7) clear

. tabulate time, missing

Without covariates:

. sim_longmeta, k(10) nocovariates seed(1) clear

See also

ml_meta, ml_sens, ml_benchmark, metalong