plot.rgam: Make a plot of rgam model fit

Description Usage Arguments Details Examples

View source: R/plot.rgam.R

Description

Produces plots of the estimated functions for specified variables at a given value of lambda.

Usage

1
2
3
## S3 method for class 'rgam'
plot(x, newx, index, which = NULL, rugplot = TRUE,
  grid_length = 100, names, ...)

Arguments

x

Fitted rgam object.

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 x$lambda.

which

Which features to plot. Default is the first 4 or nvars variables, whichever is smaller.

rugplot

If TRUE (default), adds a rugplot showing the values of x at the bottom of each fitted function plot.

grid_length

The number of points to evaluate the estimated function at. Default is 100.

names

Vector of variable names of features in which. By default, name of the jth variable is xj.

...

Optional graphical parameters to plot.

Details

A plot of the specified fitted functions is produced. Nothing is returned.

Examples

 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)

relgam documentation built on Jan. 13, 2020, 5:06 p.m.