Skip to content

psotob91/qresid

Stata tests Version Stata License: MIT Install

qresid logo

qresid

Randomized quantile residuals for regression diagnostics in Stata

qresid implements randomized quantile residuals (Dunn-Smyth residuals) for regression diagnostics in supported independent regression models in Stata. The package is intended for generalized linear and related models where conventional residuals may be difficult to interpret.

In practice, qresid gives applied users one graphical language for a broad range of fitted probability models: Gaussian and positive continuous GLMs, Bernoulli and binomial responses, Poisson and negative-binomial counts, and selected extensions for zero inflation, truncation, censoring, hurdle structures, frequency weights, and fixed-dispersion CDF replay.

Installation

qresid is available from SSC. The recommended installation command is:

ssc install qresid

After installation:

which qresid
help qresid

The GitHub repository is the public source, documentation, issue-tracking, and development home for the package. Users who want the current GitHub source can install with:

net install qresid, from("https://raw.githubusercontent.com/psotob91/qresid/main/") replace

Then check the installation in the same way:

which qresid
help qresid

Quick Start

Gaussian regression:

sysuse auto, clear
regress price mpg
qresid rq
qnorm rq
predict double muhat, xb
scatter rq muhat, yline(0)

Poisson regression:

sysuse auto, clear
poisson rep78 mpg if rep78 < .
qresid rq_pois, seed(12345)
qnorm rq_pois

Tutorials

Tutorial What you will learn
Continuous outcomes Compare Gaussian, Gamma, and inverse-Gaussian fits when positive continuous outcomes make ordinary residual plots hard to read.
Binary and binomial outcomes Diagnose Bernoulli and binomial-count models on a normal-score residual scale instead of reading bands of Pearson or deviance residuals.
Link and functional-form checks Detect link-function mistakes, nonlinear covariate effects, and seasonal patterns that can be subtle in binary or discrete data.
Count outcomes Move beyond a generic "not Poisson" conclusion by comparing Poisson, negative-binomial, and generalized-Poisson alternatives graphically.
Zero-inflated, truncated, and censored counts Separate lack of fit due to extra zeros, restricted support, censoring intervals, and count-tail behavior.
Hurdle count models Compare hurdle and zero-inflated interpretations when zeros and positive counts may arise from different mechanisms.
Weights and dispersion replay Understand how frequency weights and fixed-dispersion CDF replay affect residual diagnostics without changing the fitted model.

Additional documentation

Reference What it covers
Manual index Full tutorial sequence, reproduction notes, and links to generated figures and output excerpts.
Markdown reference GitHub-friendly version of the installed Stata help, including syntax, options, stored results, and formulas.
Features and diagnostic workflow Documented model classes and a concise workflow for Q-Q plots and residual-versus-fitted or covariate plots.
Statistical background PIT/RQR formulas, special count-model CDFs, and methodological references.
Validation and benchmarking Validation principles, independent benchmark references, and Stata 15.0 compatibility checks.
Supported specifications Public support scope for this release, including weights, dispersion, and optional external estimators.
Validation evidence Summary table of validation approaches and links to public test entry points.
Project scope Current boundaries and future extensions.
News and changelog Release notes and documentation changes.

Contributing

Contributions, bug reports, reproducible examples, and methodological discussion are welcome. Please read the contributing guide and code of conduct before opening a pull request.

Citation

If you use qresid in academic work, please cite:

Soto-Becerra, P. 2026. qresid: Quantile and randomized quantile residuals for Stata models. Version 1.0.0. Available from https://github.com/psotob91/qresid

Maintainer

Role Name Affiliation Contact
Maintainer Percy Soto-Becerra, MD, MSc, PhD(c) Universidad Privada del Norte, Lima, Peru percy.soto@upn.edu.pe; percys1991@gmail.com

License

MIT