Good morning everybody,
I would like to create a kind of loop to perform and out-of-sample analysis for my monthly data adding one more observation each time for the forecats (one step ahead forecats). This is what I am doing:
First, I am running a baseline regression for a variable on itself lagged one period and then I am adding some other variables to check if the forecast improves. So, my baseline model is like this:
reg variable_x l.variable_x
Then I would like to run that regression model (I guess that I can use the command Arima as well) until a specific date, like this,
reg variable_x l.variable_x if date<tm(2012m01)
And after that I want to predict the observation for the next month
predict p_variable_x if date==tm(2012m01)
Then I repeat the previous steps adding one month in each regression and predicting the next month:
reg variable_x l.variable_x if date<tm(2012m02)
predict p_variable_x if date==tm(2012m02)
reg variable_x l.variable_x if date<tm(2012m03)
predict p_variable_x if date==tm(2012m03)
.......
And so on...
I have about 120 months to forecast, so it is quite tedious to do it one by one. So I would like to know if there is a way to create a kind of loop to perform that forecasts.
Thanks for your help
I would like to create a kind of loop to perform and out-of-sample analysis for my monthly data adding one more observation each time for the forecats (one step ahead forecats). This is what I am doing:
First, I am running a baseline regression for a variable on itself lagged one period and then I am adding some other variables to check if the forecast improves. So, my baseline model is like this:
reg variable_x l.variable_x
Then I would like to run that regression model (I guess that I can use the command Arima as well) until a specific date, like this,
reg variable_x l.variable_x if date<tm(2012m01)
And after that I want to predict the observation for the next month
predict p_variable_x if date==tm(2012m01)
Then I repeat the previous steps adding one month in each regression and predicting the next month:
reg variable_x l.variable_x if date<tm(2012m02)
predict p_variable_x if date==tm(2012m02)
reg variable_x l.variable_x if date<tm(2012m03)
predict p_variable_x if date==tm(2012m03)
.......
And so on...
I have about 120 months to forecast, so it is quite tedious to do it one by one. So I would like to know if there is a way to create a kind of loop to perform that forecasts.
Thanks for your help
Comment