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)
Run the code above in your browser using DataLab