\Header{termplot}{Plot regression terms}
\alias{plot.gam}{termplot}
\keyword{hplot}{termplot}
\keyword{regression}{termplot}
\begin{Description}\relax
Plots regression terms against their predictors, optionally with
standard errors and partial residuals added.\end{Description}
\begin{Usage}
\begin{verbatim}
termplot(model, data=model.frame(model), partial.resid=FALSE, rug=FALSE,
         terms=NULL, se=FALSE, xlabs=NULL, ylabs=NULL, main = NULL,
         col.term = 2, lwd.term = 1.5,
         col.se = "orange", lty.se = 2, lwd.se = 1,
         col.res = "gray", cex = 1, pch = par("pch"),
         ask = interactive() && nb.fig < n.tms && .Device != "postscript",
         ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{model}] fitted model object
\item[\code{data}] data frame in which the variables in \code{model} can be found
\item[\code{partial.resid}] logical; should partial residuals be plotted?
\item[\code{rug}] add \link{rug}plots (jittered 1-d histograms) to the axes?
\item[\code{terms}] which terms to plot (default \code{NULL} means all terms)
\item[\code{se}] plot pointwise standard errors?
\item[\code{xlabs}] vector of labels for the x axes
\item[\code{ylabs}] vector of labels for the y axes
\item[\code{main}] logical, or vector of main titles;  if \code{TRUE}, the
model's call is taken as main title, \code{NULL} or \code{FALSE} mean
no titles.
\item[\code{col.term, lwd.term}] color and line width for the ``term curve'',
see \code{\Link{lines}}.
\item[\code{col.se, lty.se, lwd.se}] color, line type and line width for the
``twice-standard-error curve'' when \code{se = TRUE}.
\item[\code{col.res, cex, pch}] color, plotting character expansion and type
for partial residuals, when \code{partial.resid = TRUE}, see
\code{\Link{points}}.
\item[\code{ask}] logical; if \code{TRUE}, the user is \emph{ask}ed before
each plot, see \code{\Link{par}(ask=.)}.
\item[\code{...}] other graphical parameters
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The model object must have a \code{predict} method that accepts
\code{type=terms}, eg \code{\Link{glm}} in the base package,
\code{\Link{coxph}} and \code{\Link{survreg}} in the
\code{survival} package.

For the \code{partial.resid=TRUE} option it must have a
\code{\Link{residuals}} method that accepts \code{type="partial"},
which \code{\Link{lm}} and \code{\Link{glm}} do.

It is often necessary to specify the \code{data} argument, because it is
not possible to reconstruct eg \code{x} from a model frame containing
\code{sin(x)}.  The \code{data} argument must have exactly the same
rows as the model frame of the model object so, for example, missing
data must  have been removed in the same way.\end{Details}
\begin{SeeAlso}\relax
For (generalized) linear models, \code{\Link{plot.lm}} and
\code{\Link{predict.glm}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
rs <- require(splines)
x <- 1:100
z <- factor(rep(1:4,25))
y <- rnorm(100,sin(x/10)+as.numeric(z))
model <- glm(y ~ ns(x,6) + z)

par(mfrow=c(2,2)) ## 2 x 2 plots for same model :
termplot(model, main = paste("termplot( ", deparse(model$call)," ...)"))
termplot(model, rug=TRUE)
termplot(model, partial=TRUE, rug= TRUE,
         main="termplot(..., partial = TRUE, rug = TRUE)")
termplot(model, partial=TRUE, se = TRUE, main = TRUE)
if(rs) detach("package:splines")
\end{ExampleCode}
\end{Examples}

