Skip to content

bgreenwell/sure

Repository files navigation

sure: Surrogate Residuals

r-universe status R-CMD-check codecov

Overview

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).

Installation

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")

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")

References

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

About

Surrogate residuals for cumulative link and general regression models in R

Topics

Resources

Stars

8 stars

Watchers

5 watching

Forks

Packages

 
 
 

Contributors