Announcement

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

  • different results from " xtscc and reghdfe" in panel data analysis.

    Hello, I am working in a panel data of 142 countries from 1996-2019. I want to check the standard error of my estimation .
    in one approaches , I used :

    Code:
    reghdfe f0.ltotalfertility l(0/2)dum_recession l(1/2)ltotalfertility , absorb( i.ifscode i.year) vce(cluster ifscode)
    and the results is :

    Code:
    HDFE Linear regression                            Number of obs   =      3,124
    Absorbing 2 HDFE groups                           F(   5,    141) =    7434.23
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.9988
                                                      Adj R-squared   =     0.9987
                                                      Within R-sq.    =     0.9564
    Number of clusters (ifscode) =        142         Root MSE        =     0.0186
    
                                     (Std. err. adjusted for 142 clusters in ifscode)
    ---------------------------------------------------------------------------------
                    |               Robust
    ltotalfertility | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
      dum_recession |
                --. |  -.0012024   .0015606    -0.77   0.442    -.0042876    .0018828
                L1. |  -.0012549   .0011189    -1.12   0.264     -.003467    .0009572
                L2. |   .0008398    .001071     0.78   0.434    -.0012775    .0029571
                    |
    ltotalfertility |
                L1. |   1.285425   .0510561    25.18   0.000     1.184491     1.38636
                L2. |  -.3306986    .049356    -6.70   0.000     -.428272   -.2331253
                    |
              _cons |   .0388123   .0051032     7.61   0.000     .0287236    .0489009
    ---------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
         ifscode |       142         142           0    *|
            year |        22           0          22     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation

    but when I use the "xtscc" instead of "reghdfe" the results is different, I mean the point estimates is different.

    Code:
    xi: xtscc f0.ltotalfertility l(0/2)ldum_recession l(1/2) ltotalfertility i.year, fe
    and the results:

    Code:
    Regression with Driscoll-Kraay standard errors   Number of obs     =      2982
    Method: Fixed-effects regression                 Number of groups  =       142
    Group variable (i): ifscode                      F( 25,    20)     =   3645.11
    maximum lag: 2                                   Prob > F          =    0.0000
                                                     within R-squared  =    0.9648
    
    ---------------------------------------------------------------------------------
                    |             Drisc/Kraay
    ltotalfertility | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
     ldum_recession |
                --. |  -.0015698   .0013767    -1.14   0.268    -.0044415    .0013018
                L1. |   .0008508   .0013986     0.61   0.550    -.0020667    .0037682
                L2. |  -.0021429   .0018071    -1.19   0.250    -.0059124    .0016266
                    |
    ltotalfertility |
                L1. |    1.26128   .0551342    22.88   0.000     1.146272    1.376288
                L2. |  -.3098519   .0555952    -5.57   0.000    -.4258213   -.1938824
                    |
        _Iyear_1997 |          0  (omitted)
        _Iyear_1998 |          0  (omitted)
        _Iyear_1999 |  -.0023856     .00127    -1.88   0.075    -.0050349    .0002636
        _Iyear_2000 |   .0007933   .0010436     0.76   0.456    -.0013836    .0029703
        _Iyear_2001 |  -.0112841   .0010299   -10.96   0.000    -.0134325   -.0091357
        _Iyear_2002 |  -.0009933   .0009966    -1.00   0.331    -.0030721    .0010855
        _Iyear_2003 |  -.0005318   .0008962    -0.59   0.560    -.0024012    .0013377
        _Iyear_2004 |   .0018574   .0007688     2.42   0.025     .0002537    .0034611
        _Iyear_2005 |  -.0028131   .0012799    -2.20   0.040    -.0054829   -.0001432
        _Iyear_2006 |   .0055198     .00117     4.72   0.000     .0030793    .0079604
        _Iyear_2007 |   .0031555   .0013279     2.38   0.028     .0003855    .0059255
        _Iyear_2008 |   .0048382   .0013462     3.59   0.002     .0020301    .0076464
        _Iyear_2009 |  -.0054194   .0013012    -4.16   0.000    -.0081337   -.0027051
        _Iyear_2010 |          0  (omitted)
        _Iyear_2011 |  -.0070045   .0018133    -3.86   0.001     -.010787    -.003222
        _Iyear_2012 |   .0035946   .0019823     1.81   0.085    -.0005403    .0077295
        _Iyear_2013 |   -.009979   .0010491    -9.51   0.000    -.0121674   -.0077907
        _Iyear_2014 |   .0021452   .0013309     1.61   0.123     -.000631    .0049215
        _Iyear_2015 |  -.0046829   .0015431    -3.03   0.007    -.0079017   -.0014641
        _Iyear_2016 |  -.0049688   .0014339    -3.47   0.002    -.0079599   -.0019777
        _Iyear_2017 |  -.0124867   .0013422    -9.30   0.000    -.0152865   -.0096869
        _Iyear_2018 |  -.0076201   .0015902    -4.79   0.000    -.0109371    -.004303
        _Iyear_2019 |  -.0100073   .0018101    -5.53   0.000    -.0137831   -.0062315
              _cons |   .0449997   .0119948     3.75   0.001     .0199789    .0700205
    ---------------------------------------------------------------------------------

    I have to mention to some points:
    dum_recession is a dummy variable that takes zero or one in the time of recession.

    for the second estimation first I generated the lag on "dum_recession" because: xtscc does not allow some factor variables so I should create specific variables instead of using directly the code I provided in the first approach.
    I use Driscoll Kraay standard errors instead of clustering at the country level.

    But I do not know why the results is different, which I was expected that the only thing that changes be the standard error.

    Thank you so much for your valuable time and advice.
    sorry for this long questions, I tried to report all things.

    Regards.

  • #2
    Khatl:
    the number of observations is different in the two regressions: no wonder that this has a bearing on sample estimates too.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      @Carlo Lazzaro thank you so much for your reply. But the problem is that when I estimate the :

      Code:
       xi: xtscc f0.ltotalfertility l(0/2)dum_recession l(1/2) ltotalfertility i.year, fe
      the results is the same:
      Code:
      Regression with Driscoll-Kraay standard errors   Number of obs     =      3124
      Method: Fixed-effects regression                 Number of groups  =       142
      Group variable (i): ifscode                      F( 26,    21)     =   2713.73
      maximum lag: 2                                   Prob > F          =    0.0000
                                                       within R-squared  =    0.9669
      
      ---------------------------------------------------------------------------------
                      |             Drisc/Kraay
      ltotalfertility | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      ----------------+----------------------------------------------------------------
        dum_recession |
                  --. |  -.0012024   .0010265    -1.17   0.255    -.0033372    .0009324
                  L1. |  -.0012549   .0011634    -1.08   0.293    -.0036744    .0011646
                  L2. |   .0008398   .0014194     0.59   0.560     -.002112    .0037916
                      |
      ltotalfertility |
                  L1. |   1.285425   .0573657    22.41   0.000     1.166127    1.404724
                  L2. |  -.3306986   .0574403    -5.76   0.000    -.4501524   -.2112449
                      |
          _Iyear_1997 |          0  (omitted)
          _Iyear_1998 |  -.0062068   .0012673    -4.90   0.000    -.0088424   -.0035713
          _Iyear_1999 |  -.0020976   .0011406    -1.84   0.080    -.0044697    .0002745
          _Iyear_2000 |   .0008276   .0009651     0.86   0.401    -.0011794    .0028345
          _Iyear_2001 |   -.011404    .000962   -11.85   0.000    -.0134046   -.0094035
          _Iyear_2002 |  -.0009055   .0009285    -0.98   0.341    -.0028364    .0010254
          _Iyear_2003 |  -.0002265   .0007323    -0.31   0.760    -.0017495    .0012965
          _Iyear_2004 |    .001766   .0006955     2.54   0.019     .0003197    .0032123
          _Iyear_2005 |   -.002921   .0011624    -2.51   0.020    -.0053383   -.0005036
          _Iyear_2006 |   .0051898   .0009523     5.45   0.000     .0032094    .0071701
          _Iyear_2007 |   .0032185   .0011826     2.72   0.013     .0007591    .0056778
          _Iyear_2008 |   .0049785   .0011834     4.21   0.000     .0025176    .0074395
          _Iyear_2009 |   -.004409    .001299    -3.39   0.003    -.0071103   -.0017077
          _Iyear_2010 |          0  (omitted)
          _Iyear_2011 |  -.0069009   .0017047    -4.05   0.001    -.0104461   -.0033557
          _Iyear_2012 |   .0023983   .0009227     2.60   0.017     .0004794    .0043171
          _Iyear_2013 |  -.0098496   .0009009   -10.93   0.000    -.0117232   -.0079761
          _Iyear_2014 |   .0025756   .0011124     2.32   0.031     .0002623    .0048889
          _Iyear_2015 |  -.0049768   .0012115    -4.11   0.001    -.0074963   -.0024573
          _Iyear_2016 |  -.0045411   .0011694    -3.88   0.001    -.0069731   -.0021092
          _Iyear_2017 |  -.0123067    .001103   -11.16   0.000    -.0146006   -.0100129
          _Iyear_2018 |  -.0071115   .0013442    -5.29   0.000     -.009907   -.0043161
          _Iyear_2019 |  -.0097714    .001431    -6.83   0.000    -.0127474   -.0067954
                _cons |   .0416611   .0105463     3.95   0.001     .0197289    .0635933
      ---------------------------------------------------------------------------------
      however, in both, I used the same sample. But in the "xtscc" approach, if I understood correctly, I should generate the lag of the variable before running the regression. So I did :

      Code:
      gen ldum_recession =l.dum_recession
      But the results became different.
      Thank you so much for your time and advice.

      regards,

      Comment


      • #4
        Khati:
        provided that I' not missing out on something, the coefficients common to -reghdfe- and your last -xtscc- regressions are identical.
        Last edited by Carlo Lazzaro; 13 Jan 2022, 08:12.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          @Carlo Lazzaro thank you so much for your reply. Yes , they are the same but in the last -xtscc- I did not consider the lge of dum_recession before. Which if I considered correctly, I have to generate the lag of dum_recession gen I put it in the regression.
          but when I did, the results are different ( which I get in the first part).

          regards,

          Comment


          • #6
            Khati:
            what section of the -xtscc- help file advise you to create the lag manually before running the regression?
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              @Carlo Lazzaro thank you so much for your advice. I read that we have to specify the lag otherwise the -xtscc- by default use 4 lags.
              It is not written to create the lag manally before , but I thought I have to create before.

              regards,

              Comment


              • #8
                Khati:
                sorry, but I do not follow you.
                In the following toy-example I imposed up to 10 lags, without calculating them beforehand:
                Code:
                use "https://www.stata-press.com/data/r17/grunfeld.dta"
                . xtscc invest mvalue kstock, lag(1)
                
                Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                Method: Pooled OLS                               Number of groups  =        10
                Group variable (i): company                      F(  2,     9)     =    126.30
                maximum lag: 1                                   Prob > F          =    0.0000
                                                                 R-squared         =    0.8124
                                                                 Root MSE          =   94.4084
                
                ------------------------------------------------------------------------------
                             |             Drisc/Kraay
                      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1155622   .0099276    11.64   0.000     .0931043      .13802
                      kstock |   .2306785   .0452887     5.09   0.001     .1282284    .3331286
                       _cons |  -42.71437   11.85356    -3.60   0.006    -69.52899   -15.89975
                ------------------------------------------------------------------------------
                
                
                . xtscc invest mvalue kstock, lag(2)
                
                Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                Method: Pooled OLS                               Number of groups  =        10
                Group variable (i): company                      F(  2,     9)     =    105.72
                maximum lag: 2                                   Prob > F          =    0.0000
                                                                 R-squared         =    0.8124
                                                                 Root MSE          =   94.4084
                
                ------------------------------------------------------------------------------
                             |             Drisc/Kraay
                      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1155622   .0115228    10.03   0.000     .0894957    .1416286
                      kstock |   .2306785   .0483756     4.77   0.001     .1212453    .3401117
                       _cons |  -42.71437   12.29507    -3.47   0.007    -70.52774   -14.90099
                ------------------------------------------------------------------------------
                
                
                . xtscc invest mvalue kstock, lag(3)
                
                Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                Method: Pooled OLS                               Number of groups  =        10
                Group variable (i): company                      F(  2,     9)     =     99.10
                maximum lag: 3                                   Prob > F          =    0.0000
                                                                 R-squared         =    0.8124
                                                                 Root MSE          =   94.4084
                
                ------------------------------------------------------------------------------
                             |             Drisc/Kraay
                      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1155622   .0126463     9.14   0.000     .0869542    .1441702
                      kstock |   .2306785   .0493769     4.67   0.001     .1189802    .3423768
                       _cons |  -42.71437   12.27342    -3.48   0.007    -70.47878   -14.94996
                ------------------------------------------------------------------------------
                
                
                . xtscc invest mvalue kstock, lag(4)
                
                Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                Method: Pooled OLS                               Number of groups  =        10
                Group variable (i): company                      F(  2,     9)     =     97.98
                maximum lag: 4                                   Prob > F          =    0.0000
                                                                 R-squared         =    0.8124
                                                                 Root MSE          =   94.4084
                
                ------------------------------------------------------------------------------
                             |             Drisc/Kraay
                      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1155622    .013436     8.60   0.000     .0851678    .1459565
                      kstock |   .2306785    .049308     4.68   0.001      .119136    .3422209
                       _cons |  -42.71437   12.19035    -3.50   0.007    -70.29085   -15.13789
                ------------------------------------------------------------------------------
                
                
                . xtscc invest mvalue kstock, lag(10)
                
                Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                Method: Pooled OLS                               Number of groups  =        10
                Group variable (i): company                      F(  2,     9)     =    118.59
                maximum lag: 10                                  Prob > F          =    0.0000
                                                                 R-squared         =    0.8124
                                                                 Root MSE          =   94.4084
                
                ------------------------------------------------------------------------------
                             |             Drisc/Kraay
                      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                      mvalue |   .1155622   .0149057     7.75   0.000     .0818431    .1492812
                      kstock |   .2306785   .0416387     5.54   0.000     .1364852    .3248718
                       _cons |  -42.71437   11.11152    -3.84   0.004    -67.85036   -17.57838
                ------------------------------------------------------------------------------
                
                .
                Kind regards,
                Carlo
                (StataNow 18.5)

                Comment


                • #9
                  @ Carlo Lazzaro thank you so much for your reply and this clear example. Thank you.

                  regards,

                  Comment


                  • #10
                    @ Carlo Lazzaro I apologize for asking again this questions, now when I run this regression for "lntot_birth" "ltotalfertility" it seem is run but then I received an error that
                    D_lntot_birth ambiguous abbreviation
                    r(111);
                    r(111);
                    and it is for all "D_ltotalfertilitry" "D_lntot_birth" "D_totalfertility" "D_birth", this variables all : estimation in log changes and level changes. I did several times and diifferent things but unfortunatiliy I could not underestand:

                    Code:
                    clear
                    foreach v in "lntot_birth" "ltotalfertility" "D_ltotalfertilitry" "D_lntot_birth" "D_totalfertility" "D_birth" {
                    foreach vart in "0" "1" "2" "3" "4" "5" {
                    cd "C:\Users\KHATEREH\Desktop\MyProject/`v'"
                    use "C:\Users\KHATEREH\Desktop\fertility_xtscc.dta"
                    xi: statsby _b _se e(r2_a), clear:  xtscc f(`vart').`v' l(0/2)dum_recession l(1/2)`v' i.year, fe
                    foreach var in dum_recession {
                        gen t_`var' = _b_`var'/_se_`var'
                        gen time = "obs`vart'"
                    save `v'`vart'.dta, replace
                        }
                        }
                        }

                    this is another error :
                    variable D_ltotalfertilitry not found
                    an error occurred when statsby executed xtscc
                    r(111);
                    regards,
                    Last edited by Khati Zolfaghari; 15 Jan 2022, 10:38.

                    Comment


                    • #11
                      @Carlo Lazzaro, I sort it out. thanks. my problem was because of the name of the variables that I did not generated.

                      Thanks,
                      regards,

                      Comment

                      Working...
                      X