BookmarkSubscribeRSS Feed
aka2
Calcite | Level 5

I am using CRSP data which has firms(permnos) and monthly data for returns for a long time period and the Fama French 3 factors. I created a time column which equals to 0 if January 1963 and goes up 1 each month. Counter is counting the months for each permno(resets to 1 when a new permno comes in). So my data looks like this;

 

Permno    Date            TIme  Counter    exret    SMB    HML   MKT_RF    

10001      19630131      0             1                                                          (There are obviously numbers in exret through mkt_rf)

10001      19630228      1             2

10001      19630331      2             3

...                                                                                              (the dots here are not missing values but I put them to show there are  

....                                                                                                other values inbetween) 

10001      19830131     240         241

10002     19860131      276          1

10002    19860228       277          2

...

10002    20100728      570         295 

10003.   20030430      483          1

10003.   20030531      484          2

 

and so on.

 

What I want to do is to use an "expanding window of data" or in other words use only the data in months 1 through t-1 in whatever procedure is being used. I heard this can either be done with a macro or a data step. Any method would be fine with me. The procedure I am using is an EGARCH model (below) but please do not be discouraged from answering if you are not familiar with this model, because what I am interested is only the data step or macro that will allow me to select my sample to include upto month t-1 for each month t, you can answer by showing how to use this macro/data step with another procedure you are familiar with such as PROC REG. 

 

My code:

proc autoreg data= test ;
model exret = mkt_rf smb hml /  garch=( q=1, p=1 , type = exp) maxit=500 ;
output out=out cev=vhat ;
by permno;
run;

I am trying to 1)avoid the look ahead bias that arises from using whole sample 2)avoid having the return for month t(exret) from getting into the equation when calculating estimates fro month t.

 

What I want is that for each permno, if it is month 30 I want this code to use the data available upto 29 to give an estimate for month 30, in month 31 use data upto month 30 to give an estimate for month 31 and so on until however many months there is for that permno. (I am interested in the estimates of cev(conditional variance) 

 

I created the counter variable for this purpose if it helps. I thought to write something like " if counter = x do above procedure using data between counter= 1 to counter= x-1 for each permno"

 

As I said it doesnt necessarily have to be for the above procedure you can give an example of how to do this with another regression model you are familiar with.

 

I thank everyone who will reply for their help in advance.

 

Best Regards

3 REPLIES 3
Reeza
Super User

Something along the lines of the following:

 

where date < %sysfunc(intnx('month', %sysfunc(today()), -1, 'b');

 

 

DavyJones
Obsidian | Level 7

You may want to check the paper by Guo, Kassa, and Ferguson (2014), as they explain the look ahead bias in estimating the condition variance of time t using the return of time t per se. The authors offer two approaches to avoid the look ahead bias:

1- To estimate the EGARCH model parameters, set the sample from month 1 to month t-1. Then put the parameter estimates into Equation 8 of the paper (expected variance).

2- "Set the sample over the period from month 1 to month t and arbitrarily set the month t return to be a missing observation".

 

marianafalcao
Calcite | Level 5

Dear aka2,

 

I am currently working on my thesis and I am trying to do the exact same code, but i am strugling a bit. Can you please help me.

Could you do it in the end. I am new to SAS and have been having a bit of trouble constructing the code. But I am using a macro and started by modifying a code for a rolling window from WHarton Website.

 

But I also have a doubt. Because, given the model you were trying to estimate, and that I am also trying to estimate.(it is the same) the prediction for t, will be out-of -sample prediction. But I have been trying to undertsand the difference between the differen output options CEV and CPEV, and I understood the CEV would be in sample prediction no?

 

Best,

 

Mariana

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1498 views
  • 0 likes
  • 4 in conversation