plot.rgam {relgam} | R Documentation |
Make a plot of rgam model fit
Description
Produces plots of the estimated functions for specified variables at a given value of lambda.
Usage
## S3 method for class 'rgam'
plot(x, newx, index, which = NULL, rugplot = TRUE,
grid_length = 100, names, ...)
Arguments
x |
Fitted |
newx |
Matrix of values of each predictor at which to plot. |
index |
Index of lambda value for which plotting is desired. Default is
the last lambda value in |
which |
Which features to plot. Default is the first 4 or |
rugplot |
If |
grid_length |
The number of points to evaluate the estimated function at. Default is 100. |
names |
Vector of variable names of features in |
... |
Optional graphical parameters to plot. |
Details
A plot of the specified fitted functions is produced. Nothing is returned.
Examples
set.seed(1)
n <- 100; p <- 12
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(c(rep(2, 3), rep(0, 9)), ncol = 1)
y <- x %*% beta + x[, 4]^2 + rnorm(n)
fit <- rgam(x, y)
# default: print functions for first 4 variables
opar <- par(mfrow = c(2, 2))
plot(fit, newx = x, index = 20)
par(opar)
# print for variables 5 to 8
opar <- par(mfrow = c(2, 2))
plot(fit, newx = x, index = 20, which = 5:8)
par(opar)
[Package relgam version 1.0 Index]