Description Usage Arguments Details Examples
Produces plots of the estimated functions for specified variables at a given value of lambda.
1 2 3 |
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. |
A plot of the specified fitted functions is produced. Nothing is returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.