Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • fixed effects model have not the same results as GLS

    Hi,
    I need your help please, actually i run a linear panel data model with OLS and the sign of the coefficient of my independent variable X2 is negative (like i want ), then i run the fixed effect and random effect models and hausman test tell me that the fixed effect modele is more suitable. but in the fixed effect , the sign of independent variable become positive and in the random still negative like OLS. then i run heteroscedasticity test and pesaran's test and the results of GLS model show me that the sign of the coef of the independent variable is negative and significative as opposed to fixed effect and like i want exactly, but i am confused about if there's a problem with my model. it's normal that fixed effect model show a positive sign of the coef and then in GLS this coef become negative? should i take the results of GLS and ignore that fixed effects show me another sign ? i mentioned the out put of OLS, xtreg fe, xtreg re, and xtgls , the variable that i talked about is X2.
    i will be glad if you accept to help me,
    thank you in advance,
    regards,


    Click image for larger version

Name:	REGRESS.PNG
Views:	1
Size:	15.7 KB
ID:	1470526

    Click image for larger version

Name:	xtregfe.PNG
Views:	1
Size:	20.4 KB
ID:	1470527


    Click image for larger version

Name:	xtgls.PNG
Views:	1
Size:	18.8 KB
ID:	1470530

    Attached Files
    Last edited by nour nour; 15 Nov 2018, 04:54.

  • #2
    Nour:
    welcome to this forum.
    Assuming that you've used -xtreg-, please note that:
    - random and fixed effect specification are not equivalent;
    - if you detected heteroskedasticity and/or aoutocorrelation in your data, you should have imposed cluster robust standard errors, which is not allowed with -hausman- (see the user-written command -xtoverid- instead; type -search xtoverid- from within Stata to spot and install it);
    - it is hard to reply more positively without looking at what Stata gave you back (please see the FAQ about CODE delimiters to post what you typed and what Stata gave you back). Thanks.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      The random effects model assumes that the unobserved effect is uncorrelated with the error term, the fixed effect assumes that the unobserved effect is correlated with the error term.

      If the two are different as in your case, it turns out that in fact the unobserved effect is correlated with the error term.

      So the fixed effects model is the appropriate one in this case.

      Comment


      • #4
        thank you for your response, please take a look to the images that i have posted already , so can i take the results of GLS after testing for heteroscadasticity and autocorrelation ?

        Comment


        • #5
          Nour:
          - you have a N>T panel dataset: hence -xtgls- is not the way to go, as it is conceived for T>N panel datasets;
          - pooled OLS is out of debate too, as the F-test of -xtreg,fe- reaches statistical significance. Even if pooled OLS were the way to go, you should not run it without clustering the standard errors on -panelid-, as your observations are not independent, due to the panel structure of your data;
          - if you detected heteroskedasticity and/or autocorrelation in your data, you should have imposed cluster robust standard errors, which is not allowed with -hausman- (see the user-written command -xtoverid- instead; type -search xtoverid- from within Stata to spot and install it);
          - for the future, please invest a bit of your time to learn how to post your Stata codes and results via CODE delimiters (see the # toggle in the Advanced editor) rather than sharing snapshots. Thanks.
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            Dear Carlo, please take a look on the output below, i run a pooled OLS regression with clustering the standard errors on panelid as you tell mee but my variable of interest become not significant in the random and fixed modele i want to know if there's another method to try it and have better results

            Code:
            . regress Y X1 X2 X3 X4 X5 X6 , vce(robust)
            
            Linear regression                                      Number of obs =     556
                                                                   F(  6,   549) =  167.75
                                                                   Prob > F      =  0.0000
                                                                   R-squared     =  0.7545
                                                                   Root MSE      =  1.1606
            
            ------------------------------------------------------------------------------
                         |               Robust
                       Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                      X1 |   .1550526   .0418541     3.70   0.000     .0728389    .2372664
                      X2 |  -.0736862   .0401798    -1.83   0.067    -.1526112    .0052387
                      X3 |   1.062109   .6390877     1.66   0.097    -.1932472    2.317466
                      X4 |  -.5536783   .2555499    -2.17   0.031    -1.055654    -.051703
                      X5 |   .0911415   .0550308     1.66   0.098    -.0169551    .1992381
                      X6 |   .8782043   .0347027    25.31   0.000     .8100379    .9463706
                   _cons |  -1.879854      .3383    -5.56   0.000    -2.544375   -1.215333
            ------------------------------------------------------------------------------
            
            . xtreg Y X1 X2 X3 X4 X5 X6 ,fe vce(robust)
            
            Fixed-effects (within) regression               Number of obs      =       556
            Group variable: numero                          Number of groups   =       139
            
            R-sq:  within  = 0.0610                         Obs per group: min =         4
                   between = 0.4888                                        avg =       4.0
                   overall = 0.4571                                        max =         4
            
                                                            F(6,138)           =      3.63
            corr(u_i, Xb)  = 0.4672                         Prob > F           =    0.0022
            
                                           (Std. Err. adjusted for 139 clusters in numero)
            ------------------------------------------------------------------------------
                         |               Robust
                       Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                      X1 |   .0440436   .0527394     0.84   0.405    -.0602382    .1483254
                      X2 |   .0255237     .07931     0.32   0.748    -.1312961    .1823436
                      X3 |    1.34536   1.390556     0.97   0.335    -1.404191    4.094911
                      X4 |  -1.825682   .5163659    -3.54   0.001    -2.846694   -.8046699
                      X5 |  -.0057704   .0480447    -0.12   0.905    -.1007693    .0892286
                      X6 |   .2535031    .153419     1.65   0.101    -.0498529    .5568591
                   _cons |   3.667648   1.177663     3.11   0.002     1.339051    5.996245
            -------------+----------------------------------------------------------------
                 sigma_u |  1.8408088
                 sigma_e |  .64893245
                     rho |  .88946258   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            
            . xtreg Y X1 X2 X3 X4 X5 X6 ,re vce(robust) re
            option re not allowed
            r(198);
            
            . xtreg Y X1 X2 X3 X4 X5 X6 ,re vce(robust)
            
            Random-effects GLS regression                   Number of obs      =       556
            Group variable: numero                          Number of groups   =       139
            
            R-sq:  within  = 0.0368                         Obs per group: min =         4
                   between = 0.7958                                        avg =       4.0
                   overall = 0.7481                                        max =         4
            
                                                            Wald chi2(6)       =    246.32
            corr(u_i, X)   = 0 (assumed)                    Prob > chi2        =    0.0000
            
                                           (Std. Err. adjusted for 139 clusters in numero)
            ------------------------------------------------------------------------------
                         |               Robust
                       Y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                      X1 |    .055486   .0530801     1.05   0.296    -.0485491    .1595211
                      X2 |  -.0103497   .0566156    -0.18   0.855    -.1213142    .1006148
                      X3 |   1.227583    1.13826     1.08   0.281    -1.003365    3.458532
                      X4 |  -.9820847   .3699955    -2.65   0.008    -1.707262    -.256907
                      X5 |  -.1037713   .0278576    -3.73   0.000    -.1583711   -.0491715
                      X6 |   .8467315   .0586731    14.43   0.000     .7317344    .9617287
                   _cons |  -1.241585   .5009912    -2.48   0.013     -2.22351   -.2596603
            -------------+----------------------------------------------------------------
                 sigma_u |  .95223877
                 sigma_e |  .64893245
                     rho |  .68286603   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            Last edited by nour nour; 15 Nov 2018, 09:20.

            Comment


            • #7
              Here's another way to look at the opposite signs from -xtreg, fe- and -reg- or -xtgls-. Fixed effects regression looks only at the effects of variables within a panel. -regress- and -xtgls- look at a combination of within-panel and between-panel effects. These can be different, even in opposite directions. Run this, and take a look at the -regress- and -xtreg, fe- outputs, and then study the graph.

              Code:
              clear
              set obs 5
              gen panel_id = _n
              expand 3
              
              set seed 1234
              by panel_id , sort: gen y = 4*panel_id - _n + 3 + rnormal(0, 0.5)
              by panel_id: gen x = panel_id + _n
              
              xtset panel_id 
              
              xtreg y x, fe
              regress y x
              
              //    GRAPH THE DATA TO SHOW WHAT'S HAPPENING
              separate y, by(panel_id)
              
              graph twoway connect y? x || lfit y x

              Comment


              • #8
                sorry this is the right output


                Code:
                . regress Y X1 X2 X3 X4 X5 X6 , vce(cluster numero)
                
                Linear regression                                      Number of obs =     556
                                                                       F(  6,   138) =   62.82
                                                                       Prob > F      =  0.0000
                                                                       R-squared     =  0.7545
                                                                       Root MSE      =  1.1606
                
                                               (Std. Err. adjusted for 139 clusters in numero)
                ------------------------------------------------------------------------------
                             |               Robust
                           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                          X1 |   .1550526   .0650253     2.38   0.018     .0264778    .2836275
                          X2 |  -.0736862   .0640085    -1.15   0.252    -.2002504     .052878
                          X3 |   1.062109   .9083669     1.17   0.244    -.7340078    2.858226
                          X4 |  -.5536783   .3879912    -1.43   0.156    -1.320855    .2134981
                          X5 |   .0911415   .0786565     1.16   0.249    -.0643862    .2466692
                          X6 |   .8782043   .0652809    13.45   0.000     .7491241    1.007284
                       _cons |  -1.879854   .6263758    -3.00   0.003    -3.118389   -.6413187
                ------------------------------------------------------------------------------
                
                . xtreg Y X1 X2 X3 X4 X5 X6 , fe vce(cluster numero)
                
                Fixed-effects (within) regression               Number of obs      =       556
                Group variable: numero                          Number of groups   =       139
                
                R-sq:  within  = 0.0610                         Obs per group: min =         4
                       between = 0.4888                                        avg =       4.0
                       overall = 0.4571                                        max =         4
                
                                                                F(6,138)           =      3.63
                corr(u_i, Xb)  = 0.4672                         Prob > F           =    0.0022
                
                                               (Std. Err. adjusted for 139 clusters in numero)
                ------------------------------------------------------------------------------
                             |               Robust
                           Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                          X1 |   .0440436   .0527394     0.84   0.405    -.0602382    .1483254
                          X2 |   .0255237     .07931     0.32   0.748    -.1312961    .1823436
                          X3 |    1.34536   1.390556     0.97   0.335    -1.404191    4.094911
                          X4 |  -1.825682   .5163659    -3.54   0.001    -2.846694   -.8046699
                          X5 |  -.0057704   .0480447    -0.12   0.905    -.1007693    .0892286
                          X6 |   .2535031    .153419     1.65   0.101    -.0498529    .5568591
                       _cons |   3.667648   1.177663     3.11   0.002     1.339051    5.996245
                -------------+----------------------------------------------------------------
                     sigma_u |  1.8408088
                     sigma_e |  .64893245
                         rho |  .88946258   (fraction of variance due to u_i)
                ------------------------------------------------------------------------------
                
                . xtreg Y X1 X2 X3 X4 X5 X6 , re vce(cluster numero)
                
                Random-effects GLS regression                   Number of obs      =       556
                Group variable: numero                          Number of groups   =       139
                
                R-sq:  within  = 0.0368                         Obs per group: min =         4
                       between = 0.7958                                        avg =       4.0
                       overall = 0.7481                                        max =         4
                
                                                                Wald chi2(6)       =    246.32
                corr(u_i, X)   = 0 (assumed)                    Prob > chi2        =    0.0000
                
                                               (Std. Err. adjusted for 139 clusters in numero)
                ------------------------------------------------------------------------------
                             |               Robust
                           Y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                          X1 |    .055486   .0530801     1.05   0.296    -.0485491    .1595211
                          X2 |  -.0103497   .0566156    -0.18   0.855    -.1213142    .1006148
                          X3 |   1.227583    1.13826     1.08   0.281    -1.003365    3.458532
                          X4 |  -.9820847   .3699955    -2.65   0.008    -1.707262    -.256907
                          X5 |  -.1037713   .0278576    -3.73   0.000    -.1583711   -.0491715
                          X6 |   .8467315   .0586731    14.43   0.000     .7317344    .9617287
                       _cons |  -1.241585   .5009912    -2.48   0.013     -2.22351   -.2596603
                -------------+----------------------------------------------------------------
                     sigma_u |  .95223877
                     sigma_e |  .64893245
                         rho |  .68286603   (fraction of variance due to u_i)
                ------------------------------------------------------------------------------
                
                .

                Comment


                • #9
                  sorry but i didn't understand what this graph mean ?


                  Click image for larger version

Name:	graph1.PNG
Views:	1
Size:	18.6 KB
ID:	1470591

                  Comment


                  • #10
                    The red line is the linear regression of y on x (i.e. -regress y x-). As you can see it has a strongly positive slope. The other colored lines with dots between them show the y-x relationship within panels. These relationships are what is summarized by -xtreg, fe-. As you can see, within every panel (xtreg, fe) the y x relationship has negative slope, whereas the overall relationship between y and x (regress) has positive slope. Because the data are simple, you can easily see the difference and get a grasp of how this sort of thing can happen.

                    Comment


                    • #11
                      i understand thank you so much Sir, i want to know please if it make a problem to use the results obtained from xtgls (in my model that i mentionned above) with my panel data of 139 firms and 4 years?

                      Comment


                      • #12
                        Nour:
                        your variable -x2- is simply not significant; hence you cannot be 95% confident that its true, fixed and unknown value is actually 0<, =0 or >0.
                        This comment holds for all the regression model you've performed.
                        Hence, you probably do not have to worry about that coefficient.
                        Kind regards,
                        Carlo
                        (Stata 18.0 SE)

                        Comment

                        Working...
                        X