BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LawrenceYu01
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
bbridgerb
SAS Employee

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

7 REPLIES 7
LawrenceYu01
Fluorite | Level 6

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. 

LawrenceYu01
Fluorite | Level 6

Anybody knows how to do it ...? 

bbridgerb
SAS Employee

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.

LawrenceYu01
Fluorite | Level 6

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. 

bbridgerb
SAS Employee

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.

LawrenceYu01
Fluorite | Level 6
Thank you very much!
gergely_batho
SAS Employee

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

Then you can use: proc autoreg ;  by replicate;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

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