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

I compare the results of a two-way fixed effects panel data regression returned by SAS and Stata and find the they are completely different.

Here below are my SAS code and result screen shot, where bHHIs is my variable of interest.

proc panel data=ASSD.province_quarter_2015_12;
id Province TimeID;
model LoanNum = bHHIs population GDP deltaFIL_GDP / fixtwo;
run;

e7a8a7961d6e3b4f362a0dd95d77414.png

Here below are screen shots of my stata settings and results, as currently I have not learned any codes of stata.

I choose Statistics -> Longitudinal/panel data -> Linear models -> Linear regression(FE, RE, PA, BE).

屏幕截图 2022-01-08 100547.png

Regression settings:

屏幕截图 2022-01-08 100306.png

Panel settings:

屏幕截图 2022-01-08 100353.png

Automatically generated codes after submission:

屏幕截图 2022-01-08 100626.png

And results:

屏幕截图 2022-01-08 100645.png

As you can see, the coefficient of bHHIs flips the sign. Coefficients of other variables also change.

 

Note: in SAS I use "province_quarter_2015_12" whereas in Stata  I use "province_quarter_2015_14". It's just because Stata does not accept string Panel ID so I change it into numbers.

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASCom1
SAS Employee

Hello,

 

The two way fixed effects model parameter estimates can be replicated by running a regression with dummy variables on both cross sections and time periods. You can verify the results from PROC PANEL by specifying the two way fixed effects model using PROC MIXED or PROC GLM. An example is given at the end of this message.  I do not have knowledge about STATA command to comment on whether you are specifying the same two way fixed effects model in STATA, but one thing you may want to check first is whether your STATA command is fitting a one way fixed effects model or a two way fixed effects model. In PROC PANEL, you can use PRINTFIXED option in the MODEL statement to print out the fixed effects estimates on the cross sections and time periods dummies. Two way fixed effects model should produce fixed effects estimates for both cross sections and time periods. If you can do the same in STATA and print out the fixed effects estimates as well, that may be helpful for you to verify your model specified in STATA, and how they compare with the fixed effects estimates in PROC PANEL. 

 

In any case, the following is an example replicating two way fixed effects model estimates from PROC PANEL using PROC MIXED and PROC GLM. 

 

data a ;
  do cs = 1 to 5 ;
     do ts = 1 to 15 ;
         x = normal(1) ;
         y = 2+3*x + 2*cs + 0.5*ts + rannor(32);
         output;
      end;
  end;
run;

 

ods graphics off;

 

proc panel data =a ;
   id cs ts;
   model y = x /fixtwo printfixed ;
run;

 

proc mixed data = a ;
    class cs ts ;
    model y = x cs ts /solution;
run;


proc glm data = a ;
    class cs ts ;
    model y = x cs ts /solution;
run;

 

 

I hope this helps.

 

 

View solution in original post

3 REPLIES 3
sbxkoenk
SAS Super FREQ

Hello,

 

I have moved your question to this "Econometrics" board.

Over here you have a better chance for an appropriate answer.

 

Calling for help by @SASCom1 .

 

Cheers,

Koen

SASCom1
SAS Employee

Hello,

 

The two way fixed effects model parameter estimates can be replicated by running a regression with dummy variables on both cross sections and time periods. You can verify the results from PROC PANEL by specifying the two way fixed effects model using PROC MIXED or PROC GLM. An example is given at the end of this message.  I do not have knowledge about STATA command to comment on whether you are specifying the same two way fixed effects model in STATA, but one thing you may want to check first is whether your STATA command is fitting a one way fixed effects model or a two way fixed effects model. In PROC PANEL, you can use PRINTFIXED option in the MODEL statement to print out the fixed effects estimates on the cross sections and time periods dummies. Two way fixed effects model should produce fixed effects estimates for both cross sections and time periods. If you can do the same in STATA and print out the fixed effects estimates as well, that may be helpful for you to verify your model specified in STATA, and how they compare with the fixed effects estimates in PROC PANEL. 

 

In any case, the following is an example replicating two way fixed effects model estimates from PROC PANEL using PROC MIXED and PROC GLM. 

 

data a ;
  do cs = 1 to 5 ;
     do ts = 1 to 15 ;
         x = normal(1) ;
         y = 2+3*x + 2*cs + 0.5*ts + rannor(32);
         output;
      end;
  end;
run;

 

ods graphics off;

 

proc panel data =a ;
   id cs ts;
   model y = x /fixtwo printfixed ;
run;

 

proc mixed data = a ;
    class cs ts ;
    model y = x cs ts /solution;
run;


proc glm data = a ;
    class cs ts ;
    model y = x cs ts /solution;
run;

 

 

I hope this helps.

 

 

NaomiSerrato
Calcite | Level 5

Thanks for the solution.

a

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 3 replies
  • 1419 views
  • 3 likes
  • 4 in conversation