0
votes

Is there a way to create a holdout/back test sample in following ARIMA model with exogenous regressors. Lets say I want to estimate the following model using the first 50 observations and then evaluate model performance on the remaining 20 observations where the x-variables are pre-populated for all 70 observations. What I really want at the end is a graph that plots actual and fitted values in development period and validation/hold out period (also known as Back Testing in time series)

library(TSA)

xreg <- cbind(GNP, Time_Scaled_CO)  # two time series objects 

fit_A <- arima(Charge_Off,order=c(1,1,0),xreg) # Charge_Off is another TS object

plot(Charge_Off,col="red")

lines(predict(fit_A, Data),col="green")  #Data contains Charge_Off, GNP, Time_Scaled_CO  
1

1 Answers

0
votes

You don't seem to be using the TSA package at all, and you don't need to for this problem. Here is some code that should do what you 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 for an intro to using R with these models.