predict.rgam: Make predictions from a "rgam" object

Description Usage Arguments Value See Also Examples

View source: R/predict.rgam.R

Description

This function returns the predictions from a "rgam" object for a new data matrix.

Usage

1
2
## S3 method for class 'rgam'
predict(object, xnew, ...)

Arguments

object

Fitted "rgam" object.

xnew

Matrix of new values for x at which predictions are to be made.

...

Any other arguments to be passed to predict.glmnet().

Value

Predictions of which the model object makes at xnew. The type of predictions depends on whether a type argument is passed. By default it givs the linear predictors for the regression model.

If an offset is used in the fit, then one must be supplied via the newoffset option.

See Also

rgam.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
set.seed(1)
n <- 100; p <- 20
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(c(rep(2, 5), rep(0, 15)), ncol = 1)
y <- x %*% beta + rnorm(n)
fit <- rgam(x, y)

# predict for full lambda path
predict(fit, xnew = x[1:5, ])

# predict for specific lambda values
predict(fit, xnew = x[1:5, ], s = 0.1)

# predictions for binomial family
bin_y <- ifelse(y > 0, 1, 0)
fit2 <- rgam(x, bin_y, family = "binomial")
# linear predictors
predict(fit2, xnew = x[1:5, ], s = 0.05)
# probabilities
predict(fit2, xnew = x[1:5, ], type = "response", s = 0.05)

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