Forecasting using SAS Forecast Server, SAS/ETS, and more

Clustered standard errors in proc panel

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Clustered standard errors in proc panel

[ Edited ]

 

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


Accepted Solutions
Solution
a week ago
SAS Employee
Posts: 17

Re: Clustered standard errors in proc panel

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


All Replies
Solution
a week ago
SAS Employee
Posts: 17

Re: Clustered standard errors in proc panel

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 398 views
  • 0 likes
  • 2 in conversation