12.01.2015 Views

Package 'visreg'

Package 'visreg'

Package 'visreg'

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Title Visualization of regression models<br />

Version 1.1-1<br />

Date 2012-11-14<br />

Author Patrick Breheny, Woodrow Burchett<br />

<strong>Package</strong> ‘visreg’<br />

November 14, 2012<br />

Maintainer Patrick Breheny <br />

Depends lattice<br />

Suggests rgl, survival, MASS<br />

Description Provides convenient interface for constructing plots to<br />

visualize the fit of regression models arising from a wide<br />

variety of models in R (lm, glm, coxph, rlm, gam, locfit, etc.)<br />

License GPL-2<br />

URL http://web.as.uky.edu/statistics/users/pbreheny/publications/visreg.pdf<br />

Repository CRAN<br />

Date/Publication 2012-11-14 21:09:16<br />

R topics documented:<br />

visreg-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2<br />

visreg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<br />

visreg2d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

Index 8<br />

1


2 visreg-package<br />

visreg-package<br />

Visualization of regression functions<br />

Description<br />

Details<br />

visreg provides a number of plotting functions for visualizing fitted regression models: regression<br />

functions, confidence bands, partial residuals, interactions, and more.<br />

<strong>Package</strong>: visreg<br />

Type: <strong>Package</strong><br />

Version: 1.0-0<br />

Date: 2011-08-09<br />

License: GPL-2<br />

LazyLoad: yes<br />

This package allows the use of visreg and visreg2d, both R functions used to visualize regression<br />

functions. See the examples below for some basic uses and look in the help pages for each function<br />

for a much more detailed look.<br />

Author(s)<br />

Patrick Breheny and Woodrow Burchett<br />

Maintainer: Patrick Breheny <br />

References<br />

Breheny, P. and Burchett, W. (2012), Visualizing regression models using visreg. http://web.as.<br />

uky.edu/statistics/users/pbreheny/publications/visreg.pdf<br />

See Also<br />

visreg visreg2d<br />

Examples<br />

ozone


visreg 3<br />

visreg<br />

Visualization of regression functions for a single variable<br />

Description<br />

A function used to visualize regression models quickly and easily. Default plots contain a confidence<br />

band, prediction line, and partial residuals. Factors, transformations, conditioning, interactions,<br />

and a variety of other options are supported.<br />

Usage<br />

visreg(fit, xvar, by, breaks=4, type=c("conditional","effect"), trans=I, scale=c("linear","response"<br />

Arguments<br />

fit<br />

xvar<br />

by<br />

breaks<br />

type<br />

trans<br />

scale<br />

xtrans<br />

alpha<br />

nn<br />

This is the fitted model object you wish to visualize. lm, glm, gam, rlm, and<br />

coxph data classes are all supported.<br />

This is the variable to be put on the x-axis of your plot. Both continuous variables<br />

and factors are supported.<br />

An option to use if you wish to divide your plot by a third variable. Uses the<br />

lattice package. Both continuous variables and factors are supported.<br />

If a continuous variable is used for the ’by’ option, the ’breaks’ argument determines<br />

how many quantiles will be divided to be used for panels.<br />

The type of plot to be produced. The following options are supported:<br />

• If ’conditional’ is selected, the plot returned shows the value of the variable<br />

on the x-axis and the change in response on the y-axis, holding all<br />

other variables constant (median for numeric variables and most common<br />

category for factors, by default). For more detail, see references.<br />

• If ’effect’ is selected, the plot returned shows the effect on the expected<br />

value of the response by moving the x variable away from a reference point<br />

on the x-axis (median for numeric variables and most common category for<br />

factors, by default). For more detail, see references.<br />

Allows transformations to the response. A function should be passed (see examples).<br />

If response is selected and a glm is passed as the fit parameter, the response will<br />

automatically be transformed.<br />

Allows transformations to the x-axis. A function should be passed. Note that<br />

inverse transformations to explanatory variables are performed automatically<br />

byvisreg.<br />

Alpha level for the confidence band displayed in the plot.<br />

Controls the smoothness of the line and confidence band. The higher the number,<br />

the smoother they will appear.


4 visreg<br />

Value<br />

cond<br />

whitespace<br />

partial<br />

jitter<br />

strip.names<br />

line.par<br />

fill.par<br />

points.par<br />

Used to set variables to specific values. Can also be used to select the reference<br />

point for an effect plot. Named lists should be passed. All variables left unspecified<br />

will be filled in with the median/most common category (see examples).<br />

When xvar is a factor, whitespace determines the ammount of space in between<br />

factors on the x-axis.<br />

Determines if partial residuals are shown on the plot.<br />

Adds a small amount of noise to xvar. Potentially useful if many observations<br />

have exactly the same value. Default is FALSE.<br />

When by=TRUE, adds the name of the by variable to the strip at the top of each<br />

panel. Default is FALSE.<br />

List of parameters (see par) to pass to lines(...) when lines are drawn in the<br />

plots.<br />

List of parameters (see par) to pass to polygon(...) when shaded confidence<br />

regions are drawn in the plots.<br />

List of parameters (see par) to pass to points(...) when partial residuals are<br />

drawn in the plots.<br />

... Graphical parameters can be passed to the function to customize the plots. If<br />

by=TRUE, lattice parameters can be passed, such as layout (see examples below).<br />

In addition to providing plots, the visreg function also invisibly returns the data frames, estimates,<br />

confidence intervals, and residuals used in the creation of its plots (see last example).<br />

Author(s)<br />

Patrick Breheny and Woodrow Burchett<br />

References<br />

Breheny, P. and Burchett, W. (2012), Visualizing regression models using visreg. http://web.as.<br />

uky.edu/statistics/users/pbreheny/publications/visreg.pdf<br />

See Also<br />

visreg2d<br />

Examples<br />

## Linear models<br />

## Basic<br />

fit


visreg 5<br />

## Factors<br />

airquality$Heat


6 visreg2d<br />

visreg(fit,"Wind",cond=list(Heat="Mild"))<br />

v


visreg2d 7<br />

Value<br />

cond<br />

whitespace<br />

Used to set variables to specific values. Can also be used to select the reference<br />

point for an effect plot. Named lists should be passed. All variables left unspecified<br />

will be filled in with the median/most common category (see examples).<br />

When x (or y) is a factor, whitespace determines the ammount of space in between<br />

factors on the x (or y) axis.<br />

... Graphical parameters can be passed to the function to customize the plots.<br />

In addition to providing plots, the visreg function also invisibly returns the data frames and estimates<br />

used in the creation of its plots.<br />

Author(s)<br />

Patrick Breheny and Woodrow Burchett<br />

References<br />

Breheny, P. and Burchett, W. (2012), Visualizing regression models using visreg. http://web.as.<br />

uky.edu/statistics/users/pbreheny/publications/visreg.pdf<br />

See Also<br />

visreg<br />

Examples<br />

ozone


Index<br />

∗Topic graphics<br />

visreg, 3<br />

visreg2d, 6<br />

∗Topic models<br />

visreg, 3<br />

visreg2d, 6<br />

∗Topic package<br />

visreg-package, 2<br />

∗Topic regression<br />

visreg, 3<br />

visreg2d, 6<br />

visreg, 2, 3<br />

visreg-package, 2<br />

visreg2d, 2, 6<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!