Learn R Programming

gamsel (version 1.8-5)

predict.gamsel: Gamsel Prediction Routine

Description

Make predictions from a gamsel object.

Usage

# S3 method for gamsel
predict(
  object,
  newdata,
  index = NULL,
  type = c("link", "response", "terms", "nonzero"),
  ...
)

Value

Either a vector aor a matrix is returned, depending on type.

Arguments

object

Fitted gamsel object.

newdata

nobs_new x p matrix of new data values at which to predict.

index

Index of model in the sequence for which plotting is desired. Note, this is NOT a lambda value.

type

Type of prediction desired. Type link gives the linear predictors for "binomial", and fitted values for "gaussian". Type response gives fitted probabilities for "binomial" and fitted values for "gaussian". Type "terms" returns a matrix of fitted functions, with as many columns as there are variables. Type nonzero returns a list of the indices of nonzero coefficients at the given lambda index.

...

Not used

Author

Alexandra Chouldechova and Trevor Hastie
Maintainer: Trevor Hastie hastie@stanford.edu

References

Chouldechova, A. and Hastie, T. (2015) Generalized Additive Model Selection

See Also

gamsel, cv.gamsel, summary.gamsel, basis.gen

Examples

Run this code

##data=gamsel:::gendata(n=500,p=12,k.lin=3,k.nonlin=3,deg=8,sigma=0.5)
data = readRDS(system.file("extdata/gamsel_example.RDS", package = "gamsel"))
attach(data)
bases=pseudo.bases(X,degree=10,df=6)
# Gaussian gam
gamsel.out=gamsel(X,y,bases=bases)
preds=predict(gamsel.out,X,index=20,type="terms")

Run the code above in your browser using DataLab