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

 

Hello Everyone,

 

In one-way firm fixed effect panel regressioin, how can I get heteroskadasticity-robust standard errors clustered by quarter? I would like the standard errors to be clustered by quarter, but based on the SAS support (link) it seems I can only get heteroskadasticity-robust standard errors clustered by firm, not by quarter. The code I have in mind is

 

proc panel data=have plot=all PRINTFIXED;
id firm quarter;
model Y = x1 x2  / fixone noint HCCME=3 cluster;
output out=est_panel residual=residual predicted=predicted;
run;

and when I run this code, I believe the standard error I get is clustered by firm, and I canot find a way to cluster it by quarter. In Stata, I can specify by which variable I would like the standard errors to be clustered but I can't find the similar option in SAS. Could anyone help?

 

All the best,

Minsoo

1 ACCEPTED SOLUTION

Accepted Solutions
bobby_sas
SAS Employee

Try the following code, which 

 

1.  Runs the model as pooled regression with dummy variables for firm.  Because you specified the PRINTFIXED option I figured the number of firms as small to moderate, and thus the dummy variable approach would not be a problem.

 

2.  Switches the order of the id variables so that quarter is now picked up as the main cluster.

 

3.  Makes a copy of the firm variable so that firm can be both an ID variable and a CLASS variable (That you need to do this is a quirk of current PROC PANEL, something we intend to change).

 

data have; 
   set have;
   cfirm = firm;
run;

proc sort data = have; 
   by quarter firm;
run;

proc panel data=have plot=all;
   id quarter firm;
   class cfirm;
   model Y = x1 x2 cfirm / pooled noint HCCME=3 cluster;
run;

Please email me at Bobby.Gutierrez@sas.com if you have any questions.  In the future, we hope to add general clustering ability to PROC PANEL, which would not require this workaround.

 

--Bobby

View solution in original post

1 REPLY 1
bobby_sas
SAS Employee

Try the following code, which 

 

1.  Runs the model as pooled regression with dummy variables for firm.  Because you specified the PRINTFIXED option I figured the number of firms as small to moderate, and thus the dummy variable approach would not be a problem.

 

2.  Switches the order of the id variables so that quarter is now picked up as the main cluster.

 

3.  Makes a copy of the firm variable so that firm can be both an ID variable and a CLASS variable (That you need to do this is a quirk of current PROC PANEL, something we intend to change).

 

data have; 
   set have;
   cfirm = firm;
run;

proc sort data = have; 
   by quarter firm;
run;

proc panel data=have plot=all;
   id quarter firm;
   class cfirm;
   model Y = x1 x2 cfirm / pooled noint HCCME=3 cluster;
run;

Please email me at Bobby.Gutierrez@sas.com if you have any questions.  In the future, we hope to add general clustering ability to PROC PANEL, which would not require this workaround.

 

--Bobby

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 5840 views
  • 0 likes
  • 2 in conversation