*! version 1.0.1 08apr2026

Title

xtpqcsmc -- Monte Carlo replication for panel quantile
regression with common shocks

Syntax

xtpqcsmc
[, options]

Panel dimensions
n(#) number of cross-sectional units N; default 250

tperiods(#) number of time periods T; default 25

Simulation
reps(#) number of Monte Carlo replications; default 200

quantile(#) quantile index tau in (0,1) to evaluate; default 0.5

seed(#) random-number seed for reproducibility; default 20260220

DGP parameters
betacoef(#) slope coefficient beta; default 1.0

gammacoef(#) heterogeneity parameter gamma; default 0.2

Display
nodots suppress the progress dots

Output
saving(filename) save the replication-level dataset to disk

xtpqcsmc takes no varlist and no data in memory.
It generates its own panel data from the DGP described below.

Description

xtpqcsmc replicates the Monte Carlo experiment in Section 5
of Chiang, Galvao and Wei (2026) to verify the numerical properties
of the xtpqcs estimator. It:

1. Generates reps() independent panels from the location-scale DGP
with common shocks (see DGP details below).

2. Estimates the FEQR model using xtpqcs at the specified quantile.

3. Records the estimated coefficient, both SE types, and both rejection
indicators.

4. Reports the bias, RMSE, and 95% coverage rate for
both the robust and classical covariance estimators.

The expected outcome (matching Tables 1 and 2 of the paper):

Robust coverage should be close to 0.95 (nominal level).

Classical coverage should be below 0.95, often markedly so,
illustrating the size distortion from ignoring common shocks.

Options

Panel dimensions

n(#) sets the number of cross-sectional units.
Default is 250. Must be >= 5.

tperiods(#) sets the number of time periods.
Default is 25. Must be >= 5. Larger T improves the approximation
quality.

Simulation

reps(#) sets the number of Monte Carlo replications.
Default is 200. For publishable results use reps(1000) or more.
For a quick check, reps(30) is sufficient.

quantile(#) specifies the quantile index tau
to estimate. Must lie strictly between 0 and 1. Default is 0.5
(median). To replicate the full set of paper results, run the
command at 0.25, 0.50, and 0.75.

seed(#) sets the random-number seed for
exact reproducibility. Default is 20260220.

DGP parameters

betacoef(#) the slope parameter in the
location-scale DGP. Default is 1.0.

gammacoef(#) the heterogeneity parameter gamma
controlling the strength of quantile heterogeneity. Default is 0.2.
The true quantile regression coefficient is:

beta(tau) = betacoef + gammacoef * Phi-1(tau)

where Phi-1 is the standard normal quantile function.

Display

nodots suppresses the progress dots printed every 10
replications. Useful when running in batch mode with log output.

Output

saving(filename) saves the replication-level
dataset (one row per replication, columns: rep, bhat, se_rob, se_cl,
reject_rob, reject_cl) to the specified file. Use
saving(mc_results, replace) to overwrite.

Requirements

Stata version: 14.0 or later.

Dependencies: xtpqcs must be installed.

Data in memory: xtpqcsmc generates its own data, so it
will clear any data currently in memory during execution. The
original data is restored via preserve/restore.

Computation time (approximate):

N=50, T=15, reps=30: ~ 30 seconds (quick check)

N=250, T=25, reps=200: ~ 30 minutes

N=500, T=50, reps=1000: ~ 6+ hours

Warnings and cautions

WARNING: Data in memory will be cleared. xtpqcsmc
uses clear inside the replication loop. It wraps everything
in preserve/restore, so your original data should be safe, but
save your work first as a precaution.

WARNING: Computation time. Each replication runs a full
xtpqcs estimation. With n(500) tperiods(50) reps(1000), the
command may run for many hours. Start with a small run
(n(50) tperiods(15) reps(30)) to verify everything works.

WARNING: Seed sensitivity. The default seed is 20260220.
For robustness, re-run with multiple seeds and verify that the
coverage rates are stable.

CAUTION: Interpreting coverage. With reps(30), the
95% coverage estimate has a standard error of ~4 percentage points.
Report coverage rates from runs with reps >= 200 for reliable
inference.

CAUTION: Small N or T. With N < 30 or T < 10, the
asymptotic approximation may be poor, and coverage rates may deviate
from nominal. This does not indicate a bug; it reflects finite-sample
bias documented in the paper.

Examples

Example 1: Quick validation (30 seconds)

. xtpqcsmc, n(50) tperiods(15) reps(30) quantile(0.50)

Example 2: Replicate paper Table 1 (median, standard design)

. xtpqcsmc, n(250) tperiods(25) reps(500) quantile(0.50)

Example 3: Full replication at three quantiles

. foreach q in 0.25 0.50 0.75 {

. xtpqcsmc, n(250) tperiods(25) reps(500) quantile(`q')

. }

Example 4: Save replication-level data for custom analysis

. xtpqcsmc, n(200) tperiods(20) reps(200) quantile(0.50) saving(mc_results)

. use mc_results, clear

. histogram bhat, normal title("Distribution of beta_hat(0.50)")

Example 5: Strong heterogeneity (larger gamma)

. xtpqcsmc, n(200) tperiods(30) reps(200) quantile(0.50) gammacoef(0.5)

Example 6: Large panel, many reps (publishable results)

. xtpqcsmc, n(500) tperiods(50) reps(1000) quantile(0.50) seed(12345)

Stored results

xtpqcsmc stores the following in r():

Scalars

r(bias) mean bias: E[beta_hat] - beta(tau)

r(rmse) root mean squared error of beta_hat

r(cov_robust) empirical 95% coverage rate using the robust CI

r(cov_classical) empirical 95% coverage rate using the classical CI

DGP details

The data-generating process follows Section 5 of Chiang, Galvao and
Wei (2026). For each panel:

1. alphai ~ Uniform(0, 1), i = 1,...,N

2. Xit = chi2(3) + 0.3 * alphai

3. etat ~ N(0,1) -- the common shock shared across all i

4. epsit ~ N(0,1) -- idiosyncratic error

5. Uit = (epsit + etat) / sqrt(2)

6. Yit = alphai + beta * Xit + (1 + gamma * Xit) * Uit

This is a location-scale model. The true quantile regression
slope at quantile tau is:

beta(tau) = beta + gamma * Phi-1(tau)

The common shock etat induces cross-sectional
dependence in the errors. The classical estimator ignores this
dependence and produces SEs that are too small; the robust estimator
accounts for it correctly.

References

Chiang, H. D., A. F. Galvao, and C.-M. Wei. 2026.
Panel Quantile Regression with Common Shocks.
arXiv:2602.19201, Section 5.

Koenker, R. 2004. Quantile regression for longitudinal data.
Journal of Multivariate Analysis 91: 74-89.

Also see

Help: xtpqcs, xtpqcsplot

Author

Dr. Merwan Roudane

Email: merwanroudane920@gmail.com

Stata implementation of Chiang, Galvao and Wei (2026).