Visualization of Regression Models

Provides a convenient interface for constructing plots to visualize the fit of regression models arising from a wide variety of models in R ('lm', 'glm', 'coxph', 'rlm', 'gam', 'locfit', 'lmer', 'randomForest', etc.)


GitHub version CRAN version downloads R-CMD-check codecov.io

visreg: Visualization of Regression Models

visreg is an R package for displaying the results of a fitted model in terms of how a predictor variable x affects an outcome y. The implementation of visreg takes advantage of object-oriented programming in R, meaning that it works with virtually any type of formula-based model in R provided that the model class provides a predict() method: lm, glm, gam, rlm, nlme, lmer, coxph, svm, randomForest and many more.

Installation

To install the latest release version from CRAN:

install.packages("visreg")

To install the latest development version from GitHub:

remotes::install_github("pbreheny/visreg")

Note that version 3.0 of visreg introduced a number of breaking changes; if you wish to install the "legacy" version of visreg, version 2.8.1 was the final CRAN release before these changes took place:

remotes::install_version("visreg", "2.8.1")

Usage

The basic usage is that you fit a model, for example:

fit <- lm(Ozone ~ Solar.R + Wind + Temp, data=airquality)

and then you pass it to visreg:

visreg(fit, "Wind")

img

A more complex example, which uses the gam() function from mgcv:

airquality$Heat <- cut(airquality$Temp, 3, labels=c("Cool", "Mild", "Hot"))
fit <- gam(Ozone ~ s(Wind, by=Heat, sp=0.1), data=airquality)
visreg(fit, "Wind", "Heat") + ylab("Ozone")

img

More information

For more information on visreg syntax and how to use it, see:

The website focuses more on syntax, options, and user interface, while the paper goes into more depth regarding the statistical details.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("visreg")

3.0.0 by Patrick Breheny, 2 months ago


https://pbreheny.github.io/visreg/, https://github.com/pbreheny/visreg


Report a bug at https://github.com/pbreheny/visreg/issues


Browse source code at https://github.com/cran/visreg


Authors: Patrick Breheny [aut, cre] (ORCID: , Woodrow Burchett [ctb]


Documentation:   PDF Manual  


GPL-3 license


Imports rlang, ggplot2

Suggests glmmTMB, knitr, lattice, lme4, MASS, Matrix, quarto, rgl, survival, tinytest

Enhances nlme

System requirements: Quarto command line tool


Suggested by MASSExtra, bregr, casebase, sdmTMB, stdmod, tinyVAST.


See at CRAN