The R Project SVN R

Rev

Rev 65999 | Rev 66444 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65999 Rev 66105
Line 1... Line 1...
1
% File src/library/stats/man/termplot.Rd
1
% File src/library/stats/man/termplot.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2013 R Core Team
3
% Copyright 1995-2014 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{termplot}
6
\name{termplot}
7
\alias{termplot}
7
\alias{termplot}
8
\title{Plot Regression Terms}
8
\title{Plot Regression Terms}
Line 30... Line 30...
30
  \item{envir}{environment in which variables in \code{model} can be found}
30
  \item{envir}{environment in which variables in \code{model} can be found}
31
  \item{partial.resid}{logical; should partial residuals be plotted?}
31
  \item{partial.resid}{logical; should partial residuals be plotted?}
32
  \item{rug}{add \link{rug}plots (jittered 1-d histograms) to the axes?}
32
  \item{rug}{add \link{rug}plots (jittered 1-d histograms) to the axes?}
33
  \item{terms}{which terms to plot (default \code{NULL} means all
33
  \item{terms}{which terms to plot (default \code{NULL} means all
34
    terms); a vector passed to
34
    terms); a vector passed to
35
    \code{\link{predict}(.., term = "terms", terms = *)}.}
35
    \code{\link{predict}(.., type = "terms", terms = *)}.}
36
  \item{se}{plot pointwise standard errors?}
36
  \item{se}{plot pointwise standard errors?}
37
  \item{xlabs}{vector of labels for the x axes}
37
  \item{xlabs}{vector of labels for the x axes}
38
  \item{ylabs}{vector of labels for the y axes}
38
  \item{ylabs}{vector of labels for the y axes}
39
  \item{main}{logical, or vector of main titles;  if \code{TRUE}, the
39
  \item{main}{logical, or vector of main titles;  if \code{TRUE}, the
40
    model's call is taken as main title, \code{NULL} or \code{FALSE} mean
40
    model's call is taken as main title, \code{NULL} or \code{FALSE} mean
Line 58... Line 58...
58
     a range sufficient for all the plot will be computed, or
58
     a range sufficient for all the plot will be computed, or
59
     \code{"free"} when limits are computed for each plot.}
59
     \code{"free"} when limits are computed for each plot.}
60
   \item{plot}{if set to \code{FALSE} plots are not produced: instead a
60
   \item{plot}{if set to \code{FALSE} plots are not produced: instead a
61
     list is returned containing the data that would have been plotted.}
61
     list is returned containing the data that would have been plotted.}
62
   \item{transform.x}{logical vector; if an element (recycled as necessary)
62
   \item{transform.x}{logical vector; if an element (recycled as necessary)
63
     is \code{TRUE}, partial residuals for the corresponding term are 
63
     is \code{TRUE}, partial residuals for the corresponding term are
64
     plotted against transformed values. 
64
     plotted against transformed values.
65
     The model response is then a straight line, allowing a
65
     The model response is then a straight line, allowing a
66
     ready comparison against the data or against the curve
66
     ready comparison against the data or against the curve
67
     obtained from \code{smooth-panel.smooth}.}
67
     obtained from \code{smooth-panel.smooth}.}
68
   \item{\dots}{other graphical parameters.}
68
   \item{\dots}{other graphical parameters.}
69
}
69
}
70
\details{
70
\details{
71
  The \code{model} object must have a \code{predict} method that accepts
71
  The \code{model} object must have a \code{predict} method that accepts
72
  \code{type = terms}, e.g., \code{\link{glm}} in the \pkg{stats} package,
72
  \code{type = "terms"}, e.g., \code{\link{glm}} in the \pkg{stats} package,
73
  \code{\link[survival]{coxph}} and \code{\link[survival]{survreg}} in
73
  \code{\link[survival]{coxph}} and \code{\link[survival]{survreg}} in
74
  the \CRANpkg{survival} package.
74
  the \CRANpkg{survival} package.
75
 
75
 
76
  For the \code{partial.resid = TRUE} option \code{model} must have a
76
  For the \code{partial.resid = TRUE} option \code{model} must have a
77
  \code{\link{residuals}} method that accepts \code{type = "partial"},
77
  \code{\link{residuals}} method that accepts \code{type = "partial"},
Line 117... Line 117...
117
termplot(model, partial.resid = TRUE, smooth = panel.smooth, span.smth = 1/4)
117
termplot(model, partial.resid = TRUE, smooth = panel.smooth, span.smth = 1/4)
118
if(!had.splines && rs) detach("package:splines")
118
if(!had.splines && rs) detach("package:splines")
119
 
119
 
120
if (require(MASS)) {
120
if (require(MASS)) {
121
    hills.lm <- lm(log(time) ~ log(climb)+log(dist), data=hills)
121
    hills.lm <- lm(log(time) ~ log(climb)+log(dist), data=hills)
122
    termplot(hills.lm, partial.resid = TRUE, smooth = panel.smooth, 
122
    termplot(hills.lm, partial.resid = TRUE, smooth = panel.smooth,
123
             terms = "log(dist)", main = "Original")
123
             terms = "log(dist)", main = "Original")
124
    termplot(hills.lm, transform.x = TRUE, partial.resid = TRUE, 
124
    termplot(hills.lm, transform.x = TRUE, partial.resid = TRUE,
125
	     terms = "log(dist)", main = "Transformed",
125
	     terms = "log(dist)", main = "Transformed",
126
	     smooth=panel.smooth)
126
	     smooth=panel.smooth)
127
}
127
}
128
}
128
}
129
\keyword{hplot}
129
\keyword{hplot}