Forecasting using SAS Forecast Server, SAS/ETS, and more

Run cross validation for an autoregressive model

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Run cross validation for an autoregressive model

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: 

Untitled.png

I also ran autoreg to generate an autoregressive model, like this:

 

2.png

 

 

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


Accepted Solutions
Solution
‎08-03-2016 10:05 AM
SAS Employee
Posts: 7

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

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.

View solution in original post


All Replies
Occasional Contributor
Posts: 11

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

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. 

Occasional Contributor
Posts: 11

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

Anybody knows how to do it ...? 

Solution
‎08-03-2016 10:05 AM
SAS Employee
Posts: 7

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

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.

Occasional Contributor
Posts: 11

Re: Run cross validation for an autoregressive model

Posted in reply to bbridgerb

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. 

SAS Employee
Posts: 7

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

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.

Occasional Contributor
Posts: 11

Re: Run cross validation for an autoregressive model

Posted in reply to bbridgerb
Thank you very much!
SAS Employee
Posts: 340

Re: Run cross validation for an autoregressive model

Posted in reply to LawrenceYu01

Another convinient way to do this: proc surveyselect reps=10;

Then you can use: proc autoreg ;  by replicate;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 635 views
  • 2 likes
  • 3 in conversation