predict.gamselBayes {gamselBayes} | R Documentation |
Obtain predictions from a gamselBayes()
fit
Description
The estimated non-linear components of the generalized additive model selected via gamselBayes
are plotted.
Usage
## S3 method for class 'gamselBayes'
predict(object,newdata,type = "response",...)
Arguments
object |
A |
newdata |
A two-component list the following components: |
type |
A character string for specifying the type of prediction, with the following options: "link", "response" or "terms", which leads to the value as described below. |
... |
A place-holder for other prediction parameters. |
Value
A vector or data frame depending on the value of type
:
If type
="link" then the value is a vector of linear predictor-scale fitted values.
If type
="response" and family
="binomial" then the value is a vector of probability-scale fitted values.
Otherwise (i.e. family
="binomial") the value is the vector of predictor-scale fitted values.
If type
="terms" then the value is a a data frame with number of columns equal to the total number of predictors. Each column is the contribution to the vector of linear predictor-scale fitted values from each predictor. These contributions do not include the intercept predicted value. The intercept predicted value is included as an attribute of the returned data frame.
Author(s)
Virginia X. He virginia.x.he@student.uts.edu.au and Matt P. Wand matt.wand@uts.edu.au
Examples
library(gamselBayes)
# Generate some simple regression-type data:
n <- 1000 ; x1 <- rbinom(n,1,0.5) ; x2 <- runif(n) ; x3 <- runif(n) ; x4 <- runif(n)
y <- x1 + sin(2*pi*x2) - x3 + rnorm(n)
Xlinear <- data.frame(x1) ; Xgeneral <- data.frame(x2,x3,x4)
names(Xlinear) <- c("x1") ; names(Xgeneral) <- c("x2","x3","x4")
# Obtain and summarise a gamselBayes() fit for the data:
fit <- gamselBayes(y,Xlinear,Xgeneral)
summary(fit)
# Obtain some new data:
nNew <- 10
x1new <- rbinom(nNew,1,0.5) ; x2new <- runif(nNew) ; x3new <- runif(nNew)
x4new <- runif(nNew)
XlinearNew <- data.frame(x1new) ; names(XlinearNew) <- "x1"
XgeneralNew <- data.frame(x2new,x3new,x4new)
names(XgeneralNew) <- c("x2","x3","x4")
newdataList <- list(XlinearNew,XgeneralNew)
# Obtain predictions at the new data:
predObjDefault <- predict(fit,newdata=newdataList)
print(predObjDefault)