Skip to content
bgreenwellPublic

About

Surrogate residuals for cumulative link and general regression models in R

Topics

Resources

Stars

8 stars

Watchers

5 watching

Forks

Repository files navigation

sure

CRAN status r-universe status R-CMD-check codecov Downloads

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

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.

About

Surrogate residuals for cumulative link and general regression models in R

Topics

Resources

Stars

8 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages