An R package for constructing SUrrogate-based REsiduals and diagnostics for ordinal and general regression models; based on the approach described in Dungang and Zhang (2017).
sure is no longer available on CRAN due to CRAN's stringent and ever-changing policies. It is now hosted on r-universe, which provides a reliable alternative for distributing R packages.
# Install from r-universe (recommended):
install.packages("sure", repos = c("https://bgreenwell.r-universe.dev", "https://cloud.r-project.org"))
# Install the latest development version from GitHub:
if (!requireNamespace("pak")) {
install.packages("pak")
}
pak::pak("bgreenwell/sure")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")Liu, D. and Zhang, H. Residuals and Diagnostics for Ordinal Regression Models: A Surrogate Approach. Journal of the American Statistical Association (accepted). URL http://www.tandfonline.com/doi/abs/10.1080/01621459.2017.1292915?journalCode=uasa20
Greenwell, B.M., McCarthy, A.J., Boehmke, B.C. & Dungang, L. (2018) “Residuals and diagnostics for binary and ordinal regression models: An introduction to the sure package.” The R Journal (pre-print). URL https://journal.r-project.org/archive/2018/RJ-2018-004/index.html
