Hello guys,
I would like to know if there is any way to run a cross validaiton estiamte for an autoregressive model.
For instance, I have a model after using glmselect to run cross validation estimates like this:
I also ran autoreg to generate an autoregressive model, like this:
Now I have two more lag terms here, how can I write a code to generate a cross validation estimates with those two lag terms?
Or is there any other way to keep them in my model?
Thank you.
Lawrence
The AUTOREG procedure cannot do the cross validation directly. If you wanted to crossvalidate the way GLMSELECT does you would have to split up the sample and invoke PROC AUTOREG multiple times. The AR terms would be handled just like any non autoregressive parameters in the model.
I think an alternative way is to create lagged varaibles manually and run the regression, but the thing is that how do we create lagged values for error terms?
Thank you.
Anybody knows how to do it ...?
The AUTOREG procedure cannot do the cross validation directly. If you wanted to crossvalidate the way GLMSELECT does you would have to split up the sample and invoke PROC AUTOREG multiple times. The AR terms would be handled just like any non autoregressive parameters in the model.
Thank you for your reply. Could you please elaborate more on how to split up sample and run AUTORET multiple times? I appreciate your time.
In a data step you need to subsample the data to create the fitting (training) and validation subsamples. In your case you would repeat this process ten times to get random subsamples. The training subsample will be used to fit the model while the validation one will be used to validate it. You can assemble a similar table to the one from GLMSELECT using the AUTOREG results. I am not sure what kind of cross validation you would like to do but you can use the OUTPUT statement in the AUTOREG procedure to get predicted values used in the calculation. You would likely have to append the validation data to the training dataset with the dependent variable missing (trick to exclude these from the estimation but get predictions for them) to get predicted values for them.
Another convinient way to do this: proc surveyselect reps=10;
Then you can use: proc autoreg ; by replicate;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.