Default VGAM Plotting
plotvgam.RdComponent functions of a vgam-class object can
be plotted with plotvgam(). These are on the scale of
the linear/additive predictor.
Usage
plotvgam(x, newdata = NULL, y = NULL, residuals = NULL,
rugplot = TRUE, se = FALSE, scale = 0, raw = TRUE,
offset.arg = 0, deriv.arg = 0, overlay = FALSE,
type.residuals = c("deviance", "working", "pearson", "response"),
plot.arg = TRUE, which.term = NULL, which.cf = NULL,
control = plotvgam.control(...), varxij = 1, ...)Arguments
- x
A fitted VGAM object, e.g., produced by
vgam,vglm, orrrvglm.- newdata
Data frame. May be used to reconstruct the original data set.
- y
Unused.
- residuals
Logical. If
TRUEthen residuals are plotted. Seetype.residuals- rugplot
Logical. If
TRUEthen a rug plot is plotted at the foot of each plot. These values are jittered to expose ties.- se
Logical. If
TRUEthen approximate \(\pm 2\) pointwise standard error bands are included in the plot.- scale
Numerical. By default, each plot will have its own y-axis scale. However, by specifying a value, each plot's y-axis scale will be at least
scalewide.- raw
Logical. If
TRUEthen the smooth functions are those obtained directly by the algorithm, and are plotted without having to premultiply with the constraint matrices. IfFALSEthen the smooth functions have been premultiply by the constraint matrices. Therawargument is directly fed intopredict.vgam().- offset.arg
Numerical vector of length \(r\). These are added to the component functions. Useful for separating out the functions when
overlayisTRUE. IfoverlayisTRUEand there is one covariate then using the intercept values as the offsets can be a good idea.- deriv.arg
Numerical. The order of the derivative. Should be assigned an small integer such as 0, 1, 2. Only applying to
s()terms, it plots the derivative.- overlay
Logical. If
TRUEthen component functions of the same covariate are overlaid on each other. The functions are centered, sooffset.argcan be useful whenoverlayisTRUE.- type.residuals
if
residualsisTRUEthen the first possible value of this vector, is used to specify the type of residual.- plot.arg
Logical. If
FALSEthen no plot is produced.- which.term
Character or integer vector containing all terms to be plotted, e.g.,
which.term = c("s(age)", "s(height"))orwhich.term = c(2, 5, 9). By default, all are plotted.- which.cf
An integer-valued vector specifying which linear/additive predictors are to be plotted. The values must be from the set {1,2,...,\(r\)}. By default, all are plotted.
- control
Other control parameters. See
plotvgam.control.- ...
Other arguments that can be fed into
plotvgam.control. This includes line colors, line widths, line types, etc.- varxij
Positive integer. Used if
xijofvglm.controlwas used, this chooses which inner argument the component is plotted against. This argument is related toraw = TRUEand terms such asNS(dum1, dum2)and constraint matrices that have more than one column. The default would plot the smooth againstdum1but settingvarxij = 2could mean plotting the smooth againstdum2. See the VGAM website for further information.
Details
In this help file \(M\) is the number of linear/additive predictors, and \(r\) is the number of columns of the constraint matrix of interest.
Many of plotvgam()'s options can be found in
plotvgam.control, e.g., line types, line widths,
colors.
Value
The original object, but with the preplot slot of the object
assigned information regarding the plot.
Note
While plot(fit) will work if class(fit)
is "vgam", it is necessary to use plotvgam(fit)
explicitly otherwise.
plotvgam() is quite buggy at the moment.
See also
vgam,
plotvgam.control,
predict.vgam,
plotvglm,
vglm.
Examples
coalminers <- transform(coalminers, Age = (age - 42) / 5)
fit <- vgam(cbind(nBnW, nBW, BnW, BW) ~ s(Age),
binom2.or(zero = NULL), data = coalminers)
if (FALSE) par(mfrow = c(1,3))
plot(fit, se = TRUE, ylim = c(-3, 2), las = 1)
#> Error in eval(predvars, data, env): object 'Age' not found
plot(fit, se = TRUE, which.cf = 1:2, lcol = "blue", scol = "orange",
ylim = c(-3, 2))
#> Error in eval(predvars, data, env): object 'Age' not found
plot(fit, se = TRUE, which.cf = 1:2, lcol = "blue", scol = "orange",
overlay = TRUE) # \dontrun{}
#> Error in eval(predvars, data, env): object 'Age' not found