predict.gagam: Prediction from GAGAM

Description Usage Arguments Value Examples

View source: R/predict.gagam.R

Description

Predict method for gagam objects.

Usage

1
2
## S3 method for class 'gagam'
predict(object, ..., newdata, reduc = NULL)

Arguments

object

gagam object (result of the gagam() function)

...

Any other arguments to pass to predict.gam.

newdata

Matrix or data frame with explanatory variables. The order of columns and their names must be the same as that used to construct the gagam object. If missing, the function extracts in-sample predictions.

reduc

If prediction should be from one of the reduced models, specify the index of reduction. Specify only one index at a time. Default is NULL.

Value

A vector of predictions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
N <- 1000
set.seed(123)
xdat2 <- matrix(rnorm(N*10,0,1),nrow=N,ncol=10)
ydat2 <- 4*xdat2[,1]+5*xdat2[,2]+6*xdat2[,3]+(xdat2[,4])^2 + 4 + rnorm(N,0,0.25)

xdat <- xdat2[1:500,]
ydat <- ydat2[1:500]

## Not run: 
example_gagam <- gagam(ydat,xdat,Kvar = 6,no_gen = 50)

## End(Not run)

xdat <- xdat2[501:1000,]
ydat <- ydat2[501:1000]

newdata <- as.data.frame(cbind(as.matrix(ydat),xdat))

## Not run: 
predict_gagam(example_gagam,newdata)

## End(Not run)

markcus1/gagam documentation built on April 16, 2020, 11:50 a.m.