BookmarkSubscribeRSS Feed
Nieves
Quartz | Level 8

Hi SAS expert, I'm trying to calculate idiosyncratic skewness of residual in a rolling regression using past 6 months data. The regression is regress individaul stock return on market return:

reg ret mktret

 

For each month t, I run the regression using t-1 to t-6 data, and get the residual and calculate skewness of residual

2 REPLIES 2
mkeintz
PROC Star

Please show a sample of the data, in the form of a working data step - so that proposed code can be tested.  

 

In particular, how are you constructing data to be submitted for rolling window regressions?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Rick_SAS
SAS Super FREQ

1. Are you using forward, backward, or centered windows?

2. For the regression, do you want a least-squares regression for k=6 time points, or do you want a moving average?

3. Do you have access to SAS IML software?

 

You can review common moving-window statistics by reading the article, "Compute a moving average in SAS."
Since the skewness of residuals for a moving regression is not built into any SAS procedure, I suggest you program it yourself in the SAS IML Language. The basic ideas are shown in the article, "Rolling Statistics in SAS/IML". A second article on rolling medians shows how to extract the data from a rolling window.

 

I would tackle this problem in two steps:

  1. Extract the data from the rolling window, solve the normal equations to get the parameter estimates, and construct the residuals (which gives you a NEW series!).
  2. Compute the rolling skewness of the residuals.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 786 views
  • 0 likes
  • 3 in conversation