Description Usage Arguments Value Examples
View source: R/predict.gagam.R
Predict method for gagam
objects.
1 2 |
object |
|
... |
Any other arguments to pass to |
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. |
A vector of predictions.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.