BookmarkSubscribeRSS Feed
ZhaoJin
Calcite | Level 5

Hi, I would like to know how to add time fixed effect as well as newey west t stat together when dealing with time series data regression. To be specified, I now have a 10-year daily data which is autocorrelated as y variable, and several time series x variables. I want to add year dummies (as fixed effects) and also use newey west t stat (or other t stat that adjusts for autocorrelation). I know "proc model " can deal with newey west t stat, but it cannot add time fixed effects neatly as "proc glm" by using "class" or "absorb" statement, and now I can only add year dummies mannually, which is not feasible when dealing with hundreds or thousands levels of fixed effect.

I wonder:

(1) is there any way to add year fixed effect dummies conviniently using proc model?

(2) if not, is there any other statement rather than "proc model" that support a autocorrelated adjusted t stat (eg. newey west t stat) as well as neat time fixed effect?

Thanks!

3 REPLIES 3
SteveDenham
Jade | Level 19

Moved to Forecasting and Econometrics, in hope of attracting answers from those familiar with SAS/ETS.

 

SteveDenham

dw_sas
SAS Employee

Hi @ZhaoJin , 

 

Assuming your data is strictly time series (rather than panel data), one approach that provides the most flexibility is to use PROC GLMSELECT to define the year dummy variables and then use PROC AUTOREG to fit the regression model with the fixed-effect dummies and the Newey-West correction.  Following, please find an example to illustrate:

data workers;
  set sashelp.workers;
  year=year(date);  /* create YEAR variable from SAS date variable */
run;

proc glmselect data=workers noprint outdesign(addinputvars)=workers2;
  class year;
  model electric=year / noint selection=none;
run;

  /*
proc print data=workers2;
run;
  */

proc autoreg data=workers2;
  model electric = masonry year_1977-year_1981 / covest=hac(kernel=bartlett, bandwidth=7);
  title 'With HAC correction';
run;
title;

The above model omits the dummy variable associated with the last level of YEAR (year_1982).

 

For more details on using PROC GLMSELECT to create dummy variables, please see the following blog posting by Rick Wicklin:

 

https://blogs.sas.com/content/iml/2020/08/31/best-generate-dummy-variables-sas.html 

 

For more details on the Heteroscedasticity and Autocorrelation-consistent covariance matrix estimators supported in PROC AUTOREG, including Newey-West, please see the documentation and SAS Note links below:

 

https://support.sas.com/documentation/cdl/en/etsug/68148/HTML/default/viewer.htm#etsug_autoreg_detai... 

 

https://support.sas.com/kb/40/098.html 

 

I hope this helps!

DW

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 984 views
  • 1 like
  • 3 in conversation