*! version 1.0.0 29may2026

Title

qqdiff -- Difference-of-surfaces and asymmetry diagnostics for QQR

Syntax

qqdiff using drawsfile [, compare(file2) options]

where drawsfile (and the optional file2) are long-format draws
datasets from qqr ..., bsave(...) (variables
rep tau theta beta).

Mode
compare(file2) compare two surfaces; without it, run the asymmetry mode

Heatmap
colormap(name) palette (default redwhitegreen, diverging)

title(string) graph title

noheat skip the heatmap (only write the difference dataset)

name(name) Stata graph name

save(filename) export the graph

saving(filename) save the difference grid as a .dta

replace overwrite the exported file / dataset

twoway_options any extra option passed through to qqheat

Description

qqdiff computes and maps the difference between two
quantile-on-quantile surfaces, with a per-cell significance test, and renders
it as a starred diverging heatmap. It is the surface-level analogue of
testing a contrast: instead of one effect, it shows where two surfaces (or
two halves of one surface) differ and where that difference is
statistically meaningful.

Like qqtest and qqribbon, it reads
joint-bootstrap draws files and does not re-estimate. The default palette is
the diverging redwhitegreen map so that the sign of the difference reads
at a glance: red = negative, white ≈ 0, green = positive.

Two modes

Asymmetry mode (no compare()). Computes
diff(τ,θ) = β(τ,θ) − β(1−τ,θ) from a single draws file: the surface
reflected about the median response quantile, subtracted from itself. A
non-zero, significant cell is direct evidence of tail asymmetry — the
predictor's effect differs between matching lower and upper response
quantiles. The per-cell p-value is a paired two-sided bootstrap p (the two
cells share each resample, so their dependence is honoured).

Compare mode (compare(file2)). Computes
diff(τ,θ) = β₁(τ,θ) − β₂(τ,θ) between two separate draws files that
share the same (τ,θ) grid — e.g. two samples, two sub-periods, two countries,
or two predictors. Because the two files come from independent estimations,
the per-cell p-value uses a normal-approximation z built from the two
bootstrap standard deviations. The grids must match; if they do not,
qqdiff stops with an error.

Options

compare(file2) switches on compare mode and names the second draws
file.

colormap(name) sets the heatmap palette; a diverging map is strongly
recommended for a signed difference (redwhitegreen (default),
redblue, redgreen). See qqheat for the full palette list.

noheat suppresses the graph and only writes the difference grid (use
with saving() to post-process the numbers yourself).

saving(filename) stores the computed difference grid (variables
tau theta coef p) as a dataset. save(filename) exports the
rendered graph. title(), name(), replace and any extra
twoway_options are forwarded to qqheat, which draws the
map with three-tier significance stars.

Reading the map

o Colour encodes the signed difference: green where surface 1
exceeds surface 2 (or the lower-tail exceeds the upper-tail in asymmetry
mode), red where it is smaller, white near zero.

o Stars (* p<0.10, ** p<0.05, *** p<0.01) mark cells where the
difference is significant.

o In asymmetry mode the map is, by construction, anti-symmetric
about τ = 0.5; read the lower half (τ < 0.5) as "lower-tail minus
upper-tail".

o Pair the map with qqtest, test(symmetry) for a
single global p-value on the whole asymmetry surface.

Examples

Asymmetry of one surface

. qqr y x, tau(0.1(0.1)0.9) theta(0.1(0.1)0.9) nboot(500) bsave(draws.dta) replace

. qqdiff using draws.dta, ///

. title("QQR asymmetry: {&beta}({&tau},{&theta}) - {&beta}(1-{&tau},{&theta})") save(asym.png) replace

Difference between two samples

. preserve

. qui keep if period==1

. qqr y x, tau(0.1(0.1)0.9) theta(0.1(0.1)0.9) nboot(500) bsave(draws_sub.dta) replace

. restore

. qqdiff using draws.dta, compare(draws_sub.dta) ///

. title("Full sample - sub-period") save(diff.png) replace

References

Sim, N. and Zhou, H. (2015). Oil prices, US stock return, and the
dependence between their quantiles. Journal of Banking & Finance 55:1-12.

Author

Merwan Roudane. merwanroudane920@gmail.com

See also

qqr, qqtest, qqribbon, qqheat,
qqsurf3d, qqr_package