plot.gam(x, residuals, rugplot, se, scale, ask = FALSE,...)
preplot.gam(object, newdata, terms,...)
gam
object, or a preplot.gam
object. The first thing plot.gam()
does is check if x
has a component called preplot
; if not, it computes one using preplot.gam()
. Either way, it x
TRUE
, partial deviance residuals are plotted along with the fitted terms---default is FALSE
. If residuals
is a vector with the same length as each fitted term in x
, then these are taken to be the overTRUE
(the default), a univariate histogram or rugplot
is displayed along the base of each plot, showing the occurrence of each `x'; ties are broken by jittering.TRUE
, upper and lower pointwise twice-standard-error curves are included for each plot. The default is FALSE
.scale=0
, in which case each plot uses the range of the functions being plotted to create their ylim
. By setting scale
TRUE
, plot.gam()
operates in interactive mode.preplot.gam
, the preplot object is
based on them rather than the original.x
. The function currently knows how to plot all main-effect functions of one or two predictors. So in particular, interactions are not plotted. An appropriate `x-y' is produced to display each of the terms, adorned with residuals, standard-error curves, and a rugplot, depending on the choice of options. The form of the plot is different, depending on whether the `x'-value for each plot is numeric, a factor, or a matrix.
When ask=TRUE
, rather than produce each plot sequentially, plot.gam()
displays a menu listing all the terms that can be plotted, as well as switches for all the options.
A preplot.gam
object is a list of precomputed terms. Each such
term (also a preplot.gam
object) is a list with components
x
, y
and others---the basic ingredients needed for each
term plot. These are in turn handed to the specialized plotting function
gplot()
, which has methods for different classes of the leading
x
argument. In particular, a different plot is produced if
x
is numeric, a category or factor, a matrix, or a
list. Experienced users can extend this range by creating more
gplot()
methods for other classes. Graphical parameters (see
par
) may also be supplied as arguments to this function.
This function is a method for the generic function plot()
for
class "gam"
.
It can be invoked by calling plot(x)
for an
object x
of the appropriate class, or directly by
calling plot.gam(x)
regardless of the
class of the object.
Hastie, T. and Tibshirani, R. (1990) Generalized Additive Models. London: Chapman and Hall.
preplot
, predict.gam
data(gam.data)
gam.object <- gam(y ~ s(x,6) + z,data=gam.data)
plot(gam.object,se=TRUE)
data(gam.newdata)
preplot(gam.object,newdata=gam.newdata)
Run the code above in your browser using DataLab