*! version 1.0.0 12jun2026

Title

mmqrtest canay -- Validity test of Canay's (2011)
location-shift assumption (MM-QR vs Canay contrast)

Syntax

mmqrtest canay [depvar indepvars] [if] [in]
[, id(panelvar) quantile(numlist) reps(#)
seed(#) pvar(varname) graph name(string)
nodots noheader]

Description

Canay (2011) builds a simple two-step panel quantile estimator on the
assumption that the fixed effects alpha_i are pure location shift
variables -- they move every conditional quantile by the same
amount. The assumption is maintained, not tested, in his paper. Machado
and Santos Silva (2019, fn. 17) document what happens when it fails: with
scale-relevant fixed effects, Canay's estimator deteriorates sharply while
MM-QR remains consistent.

mmqrtest canay turns that comparison into a formal Hausman-type
test. Under H0 (location shift only) the Canay two-step slopes
theta_C(tau) and the MM-QR slopes beta(tau) estimate the same
object; under the alternative they diverge. The contrast
Delta(tau) = theta_C(tau) - beta(tau) is evaluated with a
covariance matrix obtained from a pairs cluster bootstrap that resamples
whole units (neither paper provides the joint limiting distribution of the
two estimators, so the bootstrap is the appropriate route).

Because the structural reason for failure of H0 is heterogeneity of the
scale fixed effects, mmqrtest distfe is the natural
companion: run both, and read rejection in either as evidence against
location-shift estimators for your data.

Methods and formulas

Canay two-step (Canay 2011, sec. 4): (1) within (fixed-effects) OLS
of Y on X gives theta-hat; alpha_i-hat is the unit mean
of Y - X'theta-hat; (2) standard quantile regression of
Y - alpha_i-hat on X at each tau.

MM-QR: the sequential algorithm of Machado and Santos Silva (2019,
sec. 3.1), giving beta(tau) = beta-hat + q(tau)-hat
gamma-hat.

Bootstrap: units are resampled with replacement (bsample,
cluster() idcluster()); both estimators are recomputed in every
replication; V[Delta(tau)] is the bootstrap covariance. The per-
tau statistic Delta'V^(-1)Delta is chi-squared with rank(V)
degrees of freedom under H0; the overall p-value is Bonferroni across
tau. Slopes only are compared (intercepts are not separately
identified under the two normalizations).

Options

id(panelvar), quantile(numlist) -- see mmqrtest.

reps(#) sets bootstrap replications; default 200, minimum 50. Use
500+ for publication results.

seed(#) sets the random-number seed for reproducibility.

pvar(varname) chooses the regressor displayed in the comparison
graph (default: the first regressor).

graph draws the MM-QR and Canay coefficient paths across tau
with bootstrap 95% confidence intervals.

name(string) names the graph (default mmqrt_canay).

nodots suppresses the bootstrap progress dots;
noheader suppresses the title box.

Examples

. mmqreg ln_wage tenure ttl_exp, absorb(idcode) quantile(25 50 75)

. mmqrtest canay, reps(500) seed(12345) pvar(tenure) graph

Standalone:

. mmqrtest canay ln_wage tenure ttl_exp, id(idcode) quantile(10 50 90)

Stored results

Scalars

r(p) overall p-value (Bonferroni across tau)

r(reps) successful bootstrap replications

r(G) number of units

Matrices

r(htests) per-tau results (tau, chi2, df, p)

r(b_mmqr) MM-QR slope path, rows = quantiles

r(b_canay) Canay slope path, rows = quantiles

Macros

r(verdict) REJECT or NOT REJECTED

References

Canay, I. A. 2011. A simple approach to quantile regression for panel
data. The Econometrics Journal 14: 368-386.
https://doi.org/10.1111/j.1368-423X.2011.00349.x

Machado, J. A. F., and J. M. C. Santos Silva. 2019. Quantiles via moments.
Journal of Econometrics 213: 145-173.
https://doi.org/10.1016/j.jeconom.2019.04.009

Author

Merwan Roudane --
merwanroudane920@gmail.com
-- https://github.com/merwanroudane