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

Hello everyone,

 

I would like to run a 2-stage least squares regression (2SLS) on my panel data, so I choose to use PROC CPANEL.

In my model, I need to include two fixed effects (firm and year) and cluster standard errors at firm level at the same time, so I run the following code:

proc cpanel data=casuser.entire;
id CUSIP year;
model elimat = early_refin firm_controls interest_controls / ivfixtwo hccme=3 cluster;
endogenous early_refin;  /*early_refin is a dummy variable*/
instruments turn_call;  /*turn_call is a dummy variable*/
run;

However, the log tells me "ERROR: The HCCME option is not allowed for this model."

If I take out either IVFIXTWO or HCCME, it works, so I was wondering if there is an alternative for me to meet all the requirements in my model.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
SASCom1
SAS Employee

Hello,

 

While the CPANEL procedure supports 2SLS estimation method for panel data, the HCCME option as well as the CLUSTER option in the procedure are not supported for instrumental variable estimation method(the same for dynamic panel estimation method), and that is the reason why you get the error message that HCCME is not allowed for this model when you specify both the IVFIXONE and HCCME/CLUSTER option. For instrumental variable estimation method (and dynamic panel estimation method as well), you can use the ROBUST option instead to obtain robust covariance matrix:

 

ROBUST

 

The robust covariance matrix is robust to both heteroscedasticity and serial correlation, hence it is already clustered at cross sectional level. The formulas for robust covariance matrix for instrumental variable estimation method are discussed in the following section of documentation:

 

Instrumental Variables Regression

 

 

In addition to the above, another thing I would like to point out is that, I noticed that in your code you commented that the endogenous variable early_refin is a dummy variable:

endogenous early_refin;  /*early_refin is a dummy variable*/

Do you intend to treat the endogenous variable early-refin as continuous in your instrumental variable estimation, or do you want to treat this variable as binary discrete as it is? PROC PANEL (as well as PROC SYSLIN) is designed for continuous dependent variable models, and the endogenous variables in the 2SLS estimation are all treated as continuous. If you wanted to treat the endogenous variable on the right hand side of the equation as binary, then you may consider using PROC QLIM. PROC QLIM is designed for qualitative and limited dependent variable models, and it can address endogeneity by estimating joint likelihood of the structural model together with the reduced form model for the binary endogenous variable. You can specify fixed effects in PROC QLIM using the CLASS statement. PROC QLIM also supports tests for endogeneity with TEST statement and ENDOTEST option in the MODEL statement. The following section of PROC QLIM documentation discusses endogeneity and instrumental variables in models involving discrete and limited dependent and endogenous variables and tests for endogeneity supported in the QLIM procedure:

 

Endogeneity and Instrumental Variables

 

And specifically, for a discussion on endogenous dummy variable models:

 

Endogenous Dummy Variable Models--Treatment Effects Regression

 

However, please note that the joint likelihood estimation method in PROC QLIM is not a 2SLS estimation method. PROC QLIM also does not support HCCME and CLUSTER option, but it does support COVEST = QML option in PROC QLIM statement to provide quasi-maximum likelihood estimates of covariance matrix, a sandwich estimator that is robust to some form of misspecification:

 

COVEST = OP|HESSIAN|QML 

 

 

I hope the above information is helpful. If you have further questions, please let me know. 

View solution in original post

4 REPLIES 4
SASCom1
SAS Employee

Hello,

 

While the CPANEL procedure supports 2SLS estimation method for panel data, the HCCME option as well as the CLUSTER option in the procedure are not supported for instrumental variable estimation method(the same for dynamic panel estimation method), and that is the reason why you get the error message that HCCME is not allowed for this model when you specify both the IVFIXONE and HCCME/CLUSTER option. For instrumental variable estimation method (and dynamic panel estimation method as well), you can use the ROBUST option instead to obtain robust covariance matrix:

 

ROBUST

 

The robust covariance matrix is robust to both heteroscedasticity and serial correlation, hence it is already clustered at cross sectional level. The formulas for robust covariance matrix for instrumental variable estimation method are discussed in the following section of documentation:

 

Instrumental Variables Regression

 

 

In addition to the above, another thing I would like to point out is that, I noticed that in your code you commented that the endogenous variable early_refin is a dummy variable:

endogenous early_refin;  /*early_refin is a dummy variable*/

Do you intend to treat the endogenous variable early-refin as continuous in your instrumental variable estimation, or do you want to treat this variable as binary discrete as it is? PROC PANEL (as well as PROC SYSLIN) is designed for continuous dependent variable models, and the endogenous variables in the 2SLS estimation are all treated as continuous. If you wanted to treat the endogenous variable on the right hand side of the equation as binary, then you may consider using PROC QLIM. PROC QLIM is designed for qualitative and limited dependent variable models, and it can address endogeneity by estimating joint likelihood of the structural model together with the reduced form model for the binary endogenous variable. You can specify fixed effects in PROC QLIM using the CLASS statement. PROC QLIM also supports tests for endogeneity with TEST statement and ENDOTEST option in the MODEL statement. The following section of PROC QLIM documentation discusses endogeneity and instrumental variables in models involving discrete and limited dependent and endogenous variables and tests for endogeneity supported in the QLIM procedure:

 

Endogeneity and Instrumental Variables

 

And specifically, for a discussion on endogenous dummy variable models:

 

Endogenous Dummy Variable Models--Treatment Effects Regression

 

However, please note that the joint likelihood estimation method in PROC QLIM is not a 2SLS estimation method. PROC QLIM also does not support HCCME and CLUSTER option, but it does support COVEST = QML option in PROC QLIM statement to provide quasi-maximum likelihood estimates of covariance matrix, a sandwich estimator that is robust to some form of misspecification:

 

COVEST = OP|HESSIAN|QML 

 

 

I hope the above information is helpful. If you have further questions, please let me know. 

YIN_YI_JEN
Obsidian | Level 7

Hello @SASCom1 

 

This helps me a lot. Thank you so much for your detailed and clear explanation.

 

I want to treat the endogenous variable (early_refin) as binary discrete. It seems that PROC QLIM is the closest one to what I need, but it is not a 2SLS estimation method. So is there any SAS procedure that can fulfill the following requirements at the same time?

(1) perform a 2SLS regression with a binary endogenous variable

(2) fix two effects

(3) cluster standard errors

 

If there isn't, is there any alternative to do so in SAS?

SASCom1
SAS Employee

Hi @YIN_YI_JEN 

 

You are welcome. I am glad the information was helpful to you.

I am afraid PROC QLIM does not provide 2SLS method for models involving binary endogenous variables with a probit equation. Within SAS procedures, you only have these two choices, either use linear 2SLS method with ROBUST covariance matrix in PROC CPANEL, or use PROC QLIM to specify probit equation for the binary endogenous variable and use maximum likelihood method with quasi-maximum likelihood covariance matrix. The linear 2SLS method essentially is specifying a linear probability model for the binary endogenous variable, i.e., prob(y2 = 1) = x*beta, while the probit equation in PROC QLIM specifies prob(y2=1) = Phi(x*beta), where Phi( ) is the normal cdf function.  

 

 

YIN_YI_JEN
Obsidian | Level 7

Hello @SASCom1 

 

I see. Thank you so much for your explanation.

I've been working so hard to find out the answer to this question. I am so happy that you tell me about this.

I think your first reply is very clear and highly informative, so I would like to take it as the solution to this post.

Thank you once again for your time 😊

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
  • 4 replies
  • 1728 views
  • 6 likes
  • 2 in conversation