Posterior predictive samples from models fit by bayesGAM, but with new data
Posterior predictive samples from models fit by bayesGAM, but with new data
Draw from the posterior predictive distribution applied to new data
## S4 method for signature 'bayesGAMfit'predict(object, newdata, draws =NULL,...)
Arguments
object: Object of type bayesGAMfit generated from bayesGAM.
newdata: A data frame with new data applied to the bayesGAMfit object
draws: An integer indicating the number of draws to return. The default and maximum number of draws is the size of the posterior sample.
...: Additional arguments for postrior_predict
Returns
a list of D by N matrices, where D is the number of draws from the posterior predictive distribution and N is the number of data points being predicted per draw.
Examples
set.seed(432)f <- bayesGAM(weight ~ np(height), data = women, family = gaussian, iter=500, chains =1)newheights <- with(women, rnorm(10, mean = mean(height)), sd=sd(height))women2 <- data.frame(height=newheights)pred <- predict(f, women2, draws=100)
References
Goodrich B, Gabry J, Ali I & Brilleman S. (2020). rstanarm: Bayesian applied regression modeling via Stan. R package version 2.19.3 https://mc-stan.org/rstanarm.