Skip to content

Commit

Permalink
Version 2.5-0; html vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
pbreheny committed Feb 26, 2018
1 parent 8f63307 commit c81b83d
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 93 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: visreg
Title: Visualization of Regression Models
Version: 2.4-1
Date: 2017-06-23
Version: 2.5-0
Date: 2018-02-26
Author: Patrick Breheny, Woodrow Burchett
Maintainer: Patrick Breheny <[email protected]>
Imports: lattice
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import("grDevices")
export(visreg, visreg2d, visregList)
S3method(plot, visreg)
S3method(plot, visregList)
S3method(plot, visreg2d)
S3method(subset, visreg)
14 changes: 13 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2.5-0 (2018-02-26)
* New: Overlay now works for gg plots
* New: gg option for visreg2d
* New: Improved support for betareg models
* New: Support for polr models
* Changed: visreg2d now split into calculation and plotting functions
* Changed: vignette now HTML instead of PDF
* Fixed: Formula parser now handles nested parentheses
* Fixed: Multi-reponse models with missing residuals() methods
* Fixed: Rugs now work with gg plots
* Fixed: Formula parsing for strata() in coxph models

2.4-1 (2017-06-23)
* New: Can now specify reference level for contrast plots by including x
variable in 'cond' list (thank you GitHub@jealie for implementing this!)
Expand All @@ -21,7 +33,7 @@
control/options
* New: Added option to use ggplot2 instead of lattice to produce multi-panel
plots
* New: Support for glmmADMB models.
* New: Support for glmmADMB models
* Documentation: Added quick-start vignette
* Fixed: Bug in which user options were not being passed to axis() when
the horizontal axis was a factor
Expand Down
35 changes: 0 additions & 35 deletions inst/faq/santiago1.R

This file was deleted.

21 changes: 0 additions & 21 deletions inst/faq/santiago2.R

This file was deleted.

88 changes: 88 additions & 0 deletions man/plot.visreg2d.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
\name{plot.visreg2d}
\alias{plot.visreg2d}
\title{Visualization of regression functions for two variables}
\description{Plot method for visualizing how two variables interact to
affect the response in regression models.}
\usage{
\method{plot}{visreg2d}(x, plot.type=c("image","persp","rgl", "gg"),
xlab, ylab, zlab, color, print.cond=FALSE, whitespace=0.2, ...)
}
\arguments{
\item{x}{
A \code{\link{visreg2d}} object.
}
\item{plot.type}{
The style of plot to be produced. The following three options are
supported:
\itemize{
\item \code{'image'}, a filled contour plot.
\item \code{'gg'}, a filled contour plot using \code{ggplot2}.
\item \code{'persp'}, a 3 dimensional perspective plot.
\item \code{'rgl'}, a version of the perspective plot that can be
rotated. Note: requires the rgl package to use.
}
}
\item{xlab}{
Axis label for x variable}
\item{ylab}{
Axis label for y variable}
\item{zlab}{
Axis label for outcome}
\item{color}{
For {\code{plot.type='persp'}} or {\code{plot.type='rgl'}}, the
color of the surface. For {\code{plot.type='image'}} or
{\code{plot.type='gg'}}, a vector of colors used to establish a
color palette.}
\item{print.cond}{
If \code{print.cond==TRUE}, the explanatory variable values
conditioned on in a conditional plot are printed to the console
(default: \code{FALSE}). If \code{print.cond==TRUE} and
\code{type=="contrast"}, the conditions will still be printed, but
they have no bearing on the plot unless interactions are present.
}
\item{whitespace}{
When \code{xvar} or \code{yvar} is a factor, whitespace determines
the amount of space in between the factors. Default is 0.2, meaning
that 20 percent of the axis is whitespace.
}
\item{\dots}{
Graphical parameters can be passed to the function to customize the
plots.
}
}
\references{
\itemize{
\item \url{http://pbreheny.github.io/visreg}
\item Breheny, P. and Burchett, W. (2017), Visualizing regression
models using visreg.
\url{https://journal.r-project.org/archive/2017/RJ-2017-046/index.html}
}
}
\author{
Patrick Breheny and Woodrow Burchett
}
\seealso{
\url{http://pbreheny.github.io/visreg/surface.html}
\code{\link{visreg}}
}
\examples{
fit <- lm(Ozone ~ Solar.R + Wind + Temp + I(Wind^2) + I(Temp^2) +
I(Wind*Temp)+I(Wind*Temp^2) + I(Temp*Wind^2) + I(Temp^2*Wind^2),
data=airquality)

visreg2d(fit, x="Wind", y="Temp", plot.type="image")
visreg2d(fit, x="Wind", y="Temp", plot.type="image",
color=c("purple", "green", "red"))
visreg2d(fit, x="Wind", y="Temp", plot.type="persp")

## Requires the rgl package
\dontrun{
visreg2d(fit,x="Wind",y="Temp",plot.type="rgl")
}

## Requires the ggplot2 package
\dontrun{
visreg2d(fit, x="Wind", y="Temp", plot.type="gg")
}

}
55 changes: 21 additions & 34 deletions man/visreg2d.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ A function used to visualize how two variables interact to affect the
response in regression models.
}
\usage{
visreg2d(fit, xvar, yvar, type=c("conditional", "contrast", "effect"),
trans=I, scale=c("linear", "response"),
plot.type=c("image", "persp", "rgl"), nn=ifelse(plot.type=="persp", 49,
99),
cond=list(), print.cond=FALSE, whitespace=0.2, ...)
visreg2d(fit, xvar, yvar, type=c("conditional", "contrast"), trans=I,
scale=c("linear", "response"), nn=99, cond=list(), plot=TRUE, ...)
}
\arguments{
\item{fit}{
Expand Down Expand Up @@ -51,16 +48,6 @@ cond=list(), print.cond=FALSE, whitespace=0.2, ...)
function will be applied so that the model is plotted on the scale
of the original response.
}
\item{plot.type}{
The style of plot to be produced. The following three options are
supported:
\itemize{
\item \code{'image'}, a filled contour plot.
\item \code{'persp'}, a 3 dimensional perspective plot.
\item \code{'rgl'}, a version of the perspective plot that can be
rotated. Note: requires the rgl package to use.
}
}
\item{nn}{
Resolution of the three dimensional plot. Higher values will
results in a smoother looking plot.
Expand All @@ -73,27 +60,22 @@ cond=list(), print.cond=FALSE, whitespace=0.2, ...)
can be overridden by specifying their values using \code{cond} (see
examples).
}
\item{print.cond}{
If \code{print.cond==TRUE}, the explanatory variable values
conditioned on in a conditional plot are printed to the console
(default: \code{FALSE}). If \code{print.cond==TRUE} and
\code{type=="contrast"}, the conditions will still be printed, but
they have no bearing on the plot unless interactions are present.
}
\item{whitespace}{
When \code{xvar} or \code{yvar} is a factor, whitespace determines
the amount of space in between the factors. Default is 0.2, meaning
that 20 percent of the axis is whitespace.
\item{plot}{
Send the calculations to \code{\link{plot.visreg2d}}, producing a
plot? Default is TRUE.
}
\item{\dots}{
Graphical parameters can be passed to the function to customize the
plots.
Graphical parameters (e.g., \code{ylab}) can be passed to the
function to customize the plots.
}
}
\value{
In addition to providing plots, the \code{visreg2d} function also
invisibly returns the x, y, and Z values used in the creation of its
plots.
A \code{visreg2d} object consisting of:
\item{x}{Values of \code{xvar} to be plotted}
\item{y}{Values of \code{yvar} to be plotted}
\item{z}{Values of outcome to be plotted}
\item{meta}{Meta-information needed to construct plots, such as the
name of the x and y variables.}
}
\references{
\itemize{
Expand All @@ -115,12 +97,17 @@ fit <- lm(Ozone ~ Solar.R + Wind + Temp + I(Wind^2) + I(Temp^2) +
I(Wind*Temp)+I(Wind*Temp^2) + I(Temp*Wind^2) + I(Temp^2*Wind^2),
data=airquality)

visreg2d(fit,x="Wind",y="Temp",plot.type="image")
visreg2d(fit,x="Wind",y="Temp",plot.type="persp")
visreg2d(fit, x="Wind", y="Temp", plot.type="image")
visreg2d(fit, x="Wind", y="Temp", plot.type="persp")

## Requires the rgl package
\dontrun{
visreg2d(fit,x="Wind",y="Temp",plot.type="rgl")
visreg2d(fit, x="Wind", y="Temp", plot.type="rgl")
}

## Requires the ggplot2 package
\dontrun{
visreg2d(fit, x="Wind", y="Temp", plot.type="gg")
}

}
115 changes: 115 additions & 0 deletions vignettes/quick-start.html

Large diffs are not rendered by default.

0 comments on commit c81b83d

Please sign in to comment.