r - Back Test ARIMA model with Exogenous Regressors -


is there way create holdout/back test sample in following arima model exogenous regressors. lets want estimate following model using first 50 observations , evaluate model performance on remaining 20 observations x-variables pre-populated 70 observations. want @ end graph plots actual , fitted values in development period , validation/hold out period (also known testing in time series)

library(tsa)  xreg <- cbind(gnp, time_scaled_co)  # 2 time series objects   fit_a <- arima(charge_off,order=c(1,1,0),xreg) # charge_off ts object  plot(charge_off,col="red")  lines(predict(fit_a, data),col="green")  #data contains charge_off, gnp, time_scaled_co   

you don't seem using tsa package @ all, , don't need problem. here code should want.

library(forecast) xreg <- cbind(gnp, time_scaled_co) training <- window(charge_off, end=50) test <- window(charge_off, start=51) fit_a <- arima(training,order=c(1,1,0),xreg=xreg[1:50,]) fc <- forecast(fit_a, h=20, xreg=xreg[51:70,]) plot(fc) lines(test, col="red") accuracy(fc, test) 

see http://otexts.com/fpp/9/1 intro using r these models.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -