Hello, I am using the R2Bayesx package to fit a GAM to time-series data and then using this model to extrapolate beyond the extent of the time-series. The prediction.bayesx function works quite well to predict the series, but does not seem to provide uncertainty estimates for the prediction. The usual se.fit=TRUE argument to the predict() function does not seem to apply here. I also tried predict.bayesx(... type='terms'), but in this case the predicted trend did not seem to approximate my response data. Predict.bayesx(...type='response') provides a predicted trend which approximates my response data, but does not provide uncertainty estimates. An example of this issue is provided as follows:

library(BayesX)
library(R2BayesX)

#SIMULATE A TIMESERIES
e=arima.sim(model=list(ar=c(.9,-.2)),n=100)
x<-seq(1,100,1)
dat<-data.frame(x=x,x2=x^3,e=e)
dat$y<-dat$x2+(dat$e*50000)
dat<-subset(dat,select=c('x','y'))
mod<-bayesx(y~sx(x,knots=30),family='gaussian',method='MCMC',data=dat,iterations=10000,burnin=2000,step=10)

#EXAMPLE 1: PREDICT ON RESPONSE SCALE - APPROXIMATES THE TIMESERIES WELL BUT NO OPTION TO CALCULATE UNCERTAINTY ESTIMATES
xpred<-seq(1,120,1)#COVARIATE DATA TO BE USED TO PREDICT (EXTRAPOLATE) OVER
ypred<-predict(mod,newdata=data.frame(x=xpred),se.fit=TRUE,type='response')
plot(xpred,ypred,type='l')
points(dat$x,dat$y,pch=16)

#EXAMPLE 1: PREDICT ON RESPONSE SCALE - APPROXIMATES THE TIMESERIES POORLY
ypred<-predict(mod,newdata=data.frame(x=xpred),se.fit=TRUE,type='terms')
plot(xpred,ypred$Mean,type='l')
lines(xpred,ypred[,6],lty=3)
lines(xpred,ypred$Mean-(ypred[,6]-ypred$Mean),lty=3)
points(dat$x,dat$y,pch=16)

Any suggestions or comments are appreciated.

Thanks.





--
View this message in context: http://r.789695.n4.nabble.com/Re-Confidence-intervals-for-prediction-with-R2Bayesx-tp4683516.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

