Surrogate Residuals for Ordinal and General Regression Models
An implementation of the surrogate approach to residuals and
diagnostics for ordinal and general regression models; for details, see Liu
and Zhang (2018) and Greenwell et al.
(2018) . These residuals can be used to construct
standard residual plots for model diagnostics (e.g., residual-vs-fitted
value plots, residual-vs-covariate plots, Q-Q plots, etc.). The package also
provides 'plot' methods for producing standard diagnostic plots using
lightweight base R graphics (via 'tinyplot'). The package currently
supports cumulative link models from packages 'MASS', 'ordinal', 'rms', and
'VGAM', binary and other generalized linear models fit with 'glm', and
multinomial models or general classifiers via a matrix of predicted class
probabilities.
sure 

Surrogate residuals and diagnostics for ordinal and general regression
models, based on the approach of Liu and Zhang
(2018).
- Surrogate residuals for cumulative link models from MASS,
ordinal, rms, and VGAM, and for
glm() fits.
- Multinomial models and general classifiers via a matrix of predicted
class probabilities.
- Latent-variable and jittering methods, with bootstrap replicates.
- Q-Q, residual-vs-fitted, and residual-vs-covariate plots built on
tinyplot; no non-base hard dependencies.
Installation
# From CRAN (recommended)
install.packages("sure")
# Latest development version, from r-universe
install.packages("sure", repos = c("https://bgreenwell.r-universe.dev", "https://cloud.r-project.org"))
Quick start
library(sure)
# Simulate an ordinal response with a quadratic true relationship
set.seed(101)
df <- sim_data(n = 500, type = "quadratic")
# Fit a (misspecified) proportional odds model
fit <- MASS::polr(y ~ x, data = df)
# Compute surrogate-based residuals and plot the diagnostics
res <- resids(fit)
plot(res, what = "covariate", covariate = df$x, xlab = "x")
Documentation
- Package website: https://bgreenwell.github.io/sure/
- Introductory vignette:
vignette("sure", package = "sure")
- Greenwell, B. M., McCarthy, A. J., Boehmke, B. C., and Liu, D. (2018).
Residuals and diagnostics for binary and ordinal regression models: An
introduction to the sure package. The R Journal, 10(1).
https://doi.org/10.32614/RJ-2018-004
- Liu, D. and Zhang, H. (2018). Residuals and diagnostics for ordinal
regression models: A surrogate approach. Journal of the American
Statistical Association, 113(522), 845-854.
https://doi.org/10.1080/01621459.2017.1292915
Development
devel is the default branch and holds ongoing development; main holds
stable releases only. Please open pull requests against devel and report
bugs at https://github.com/bgreenwell/sure/issues.