Announcement

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

  • Paneldata Fixed Effects with and without robust leads to the same result

    Hello,
    I hope anyone can help me.
    I have a unbalanced Panel. Hausmann leads me to use for further analysis fixed effects. Testparm and modified wald test leads me to use entity and time fixed effects and also "robust" with vce (robust) because of heteroskedasticiy. When I use xi: xtreg y x1 i.year, fe and xi: xtreg y x1 i.year, fe vce (robust) I get the same results...Did i made a mistake anywhre? Thanks in advance.

    . xtset Unternehmen Jahr
    panel variable: Unternehmen (unbalanced)
    time variable: Jahr, 2014 to 2018, but with gaps
    delta: 1 year

    . xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, fe

    Fixed-effects (within) regression Number of obs = 342
    Group variable: Unternehmen Number of groups = 79

    R-sq: Obs per group:
    within = 0.6964 min = 1
    between = 0.3551 avg = 4.3
    overall = 0.4950 max = 5

    F(11,252) = 52.54
    corr(u_i, Xb) = -0.2154 Prob > F = 0.0000

    ------------------------------------------------------------------------------
    Y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    x1 | .0121592 .015234 0.80 0.426 -.017843 .0421614
    x2 | 1.885169 5.310276 0.36 0.723 -8.573006 12.34334
    x3 | -.4471534 .2738079 -1.63 0.104 -.9863968 .09209
    x4 | -12.6464 3.358336 -3.77 0.000 -19.26038 -6.032417
    x5 | -3.154039 1.94352 -1.62 0.106 -6.981651 .6735729
    x6 | 9.843865 .5781626 17.03 0.000 8.705219 10.98251
    x7 | -.0105897 .0053595 -1.98 0.049 -.0211448 -.0000345
    x8 | -.0909935 .1932579 -0.47 0.638 -.4716 .289613
    x9 | .0042337 .179777 0.02 0.981 -.3498233 .3582906
    x10 | .2618862 .1633328 1.60 0.110 -.0597851 .5835574
    x11 | .286262 .1016634 2.82 0.005 .0860437 .4864802
    _cons | 10.14478 64.69261 0.16 0.876 -117.2623 137.5519
    -------------+----------------------------------------------------------------
    sigma_u | 22.903426
    sigma_e | 13.34097
    rho | .74666305 (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(78, 252) = 5.96 Prob > F = 0.0000

    . estimates store fe

    . xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, re

    Random-effects GLS regression Number of obs = 342
    Group variable: Unternehmen Number of groups = 79

    R-sq: Obs per group:
    within = 0.6785 min = 1
    between = 0.5220 avg = 4.3
    overall = 0.6113 max = 5

    Wald chi2(11) = 611.68
    corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

    ------------------------------------------------------------------------------
    Y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    x1 | .0017081 .012697 0.13 0.893 -.0231775 .0265937
    x2 | 1.529129 1.906254 0.80 0.422 -2.20706 5.265318
    x3 | -.3607013 .2628963 -1.37 0.170 -.8759687 .1545661
    x4 | -6.831479 2.186577 -3.12 0.002 -11.11709 -2.545868
    x5 | -4.372107 1.993001 -2.19 0.028 -8.278317 -.4658961
    x6 | 10.26525 .5341722 19.22 0.000 9.218294 11.31221
    x7 | -.0058791 .0054074 -1.09 0.277 -.0164774 .0047193
    x8 | .2901557 .1817283 1.60 0.110 -.0660251 .6463366
    x9 | -.2081798 .1323955 -1.57 0.116 -.4676702 .0513107
    x10 | .1843618 .1283733 1.44 0.151 -.0672452 .4359688
    x11 | .0867639 .079641 1.09 0.276 -.0693296 .2428575
    _cons | 16.62166 31.65446 0.53 0.600 -45.41994 78.66325
    -------------+----------------------------------------------------------------
    sigma_u | 15.001195
    sigma_e | 13.34097
    rho | .55837761 (fraction of variance due to u_i)
    ------------------------------------------------------------------------------

    . estimates store re

    . hausman fe re

    ---- Coefficients ----
    | (b) (B) (b-B) sqrt(diag(V_b-V_B))
    | fe re Difference S.E.
    -------------+----------------------------------------------------------------
    x1 | .0121592 .0017081 .0104511 .0084179
    x2 | 1.885169 1.529129 .3560401 4.956332
    x3 | -.4471534 -.3607013 -.0864521 .0765263
    x4 | -12.6464 -6.831479 -5.814919 2.548981
    x5 | -3.154039 -4.372107 1.218068 .
    x6 | 9.843865 10.26525 -.4213873 .221206
    x7 | -.0105897 -.0058791 -.0047106 .
    x8 | -.0909935 .2901557 -.3811492 .065753
    x9 | .0042337 -.2081798 .2124134 .1216191
    x10 | .2618862 .1843618 .0775244 .1009847
    x11 | .286262 .0867639 .199498 .0631883
    ------------------------------------------------------------------------------
    b = consistent under Ho and Ha; obtained from xtreg
    B = inconsistent under Ha, efficient under Ho; obtained from xtreg

    Test: Ho: difference in coefficients not systematic

    chi2(11) = (b-B)'[(V_b-V_B)^(-1)](b-B)
    = 76.16
    Prob>chi2 = 0.0000
    (V_b-V_B is not positive definite)


    . xtset Unternehmen Jahr
    panel variable: Unternehmen (unbalanced)
    time variable: Jahr, 2014 to 2018, but with gaps
    delta: 1 year

    . xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe
    i.Jahr _IJahr_2014-2018 (naturally coded; _IJahr_2014 omitted)

    Fixed-effects (within) regression Number of obs = 342
    Group variable: Unternehmen Number of groups = 79

    R-sq: Obs per group:
    within = 0.7509 min = 1
    between = 0.4127 avg = 4.3
    overall = 0.5609 max = 5

    F(15,248) = 49.85
    corr(u_i, Xb) = -0.1701 Prob > F = 0.0000


    Y Coef. Std. Err. t P>t [95% Conf. Interval]

    x1 .0091464 .0139301 0.66 0.512 -.01829 .0365829
    x2 -4.252209 4.960329 -0.86 0.392 -14.02195 5.517534
    x3 -.473511 .2530563 -1.87 0.062 -.9719246 .0249026
    x4 -12.73621 3.099359 -4.11 0.000 -18.84064 -6.63179
    x5 11.2182 3.789075 2.96 0.003 3.755325 18.68107
    x6 10.09346 .5504423 18.34 0.000 9.009325 11.1776
    x7 .0046431 .0086834 0.53 0.593 -.0124595 .0217458
    x8 .0455602 .2440602 0.19 0.852 -.4351348 .5262552
    x9 -.0980529 .1657255 -0.59 0.555 -.4244618 .228356
    x10 .2070221 .1506021 1.37 0.170 -.0896001 .5036444
    x11 .102173 .0971356 1.05 0.294 -.0891428 .2934889
    _IJahr_2015 15.09593 3.162919 4.77 0.000 8.866322 21.32554
    _IJahr_2016 21.15731 5.111523 4.14 0.000 11.08978 31.22485
    _IJahr_2017 17.33039 4.970709 3.49 0.001 7.540202 27.12058
    _IJahr_2018 23.44871 3.456689 6.78 0.000 16.6405 30.25692
    _cons 17.31959 66.04854 0.26 0.793 -112.768 147.4072

    sigma_u 21.567956
    sigma_e 12.179949
    rho .75819981 (fraction of variance due to u_i)

    F test that all u_i=0: F(78, 248) = 6.59 Prob > F = 0.0000

    . xi: regress Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Unternehmen i.Jahr
    i.Unternehmen _IUnternehm_1-79 (naturally coded; _IUnternehm_1 omitted)
    i.Jahr _IJahr_2014-2018 (naturally coded; _IJahr_2014 omitted)

    Source SS df MS Number of obs = 342
    F(93, 248) = 23.07
    Model 318227.767 93 3421.80395 Prob > F = 0.0000
    Residual 36791.0876 248 148.35116 R-squared = 0.8964
    Adj R-squared = 0.8575
    Total 355018.854 341 1041.11101 Root MSE = 12.18


    Y Coef. Std. Err. t P>t [95% Conf. Interval]

    x1 .0091464 .0139301 0.66 0.512 -.01829 .0365829
    x2 -4.252209 4.960329 -0.86 0.392 -14.02195 5.517534
    x3 -.473511 .2530563 -1.87 0.062 -.9719246 .0249026
    x4 -12.73621 3.099359 -4.11 0.000 -18.84064 -6.63179
    x5 11.2182 3.789075 2.96 0.003 3.755325 18.68107
    x6 10.09346 .5504423 18.34 0.000 9.009325 11.1776
    x7 .0046431 .0086834 0.53 0.593 -.0124595 .0217458
    x8 .0455602 .2440602 0.19 0.852 -.4351348 .5262552
    x9 -.0980529 .1657255 -0.59 0.555 -.4244618 .228356
    x10 .2070221 .1506021 1.37 0.170 -.0896001 .5036444
    x11 .102173 .0971356 1.05 0.294 -.0891428 .2934889
    _IUnternehm_2 1.575516 10.30654 0.15 0.879 -18.724 21.87503
    _IUnternehm_3 -39.06488 10.25417 -3.81 0.000 -59.26125 -18.86852
    _IUnternehm_4 -24.40019 12.7029 -1.92 0.056 -49.41951 .6191261
    _IUnternehm_5 -14.42787 11.04235 -1.31 0.193 -36.17662 7.320877
    _IUnternehm_6 -8.348222 9.779419 -0.85 0.394 -27.60953 10.91308
    _IUnternehm_7 20.5798 15.03405 1.37 0.172 -9.030897 50.1905
    _IUnternehm_8 2.41823 14.65319 0.17 0.869 -26.44234 31.2788
    _IUnternehm_9 5.66785 16.76055 0.34 0.736 -27.34332 38.67902
    _IUnternehm_10 -16.14584 10.02271 -1.61 0.108 -35.88633 3.594639
    _IUnternehm_11 17.81726 18.40685 0.97 0.334 -18.43642 54.07094
    _IUnternehm_12 19.34285 14.61768 1.32 0.187 -9.447774 48.13348
    _IUnternehm_13 20.54812 12.09701 1.70 0.091 -3.277862 44.3741
    _IUnternehm_14 32.32243 12.44368 2.60 0.010 7.813661 56.83119
    _IUnternehm_15 -37.85379 12.83629 -2.95 0.003 -63.13584 -12.57174
    _IUnternehm_16 46.11187 13.25584 3.48 0.001 20.00349 72.22025
    _IUnternehm_17 -6.344185 8.112828 -0.78 0.435 -22.32301 9.634643
    _IUnternehm_18 2.288403 11.73014 0.20 0.845 -20.81499 25.3918
    _IUnternehm_19 2.392787 11.70008 0.20 0.838 -20.65141 25.43699
    _IUnternehm_20 5.753934 18.12912 0.32 0.751 -29.95275 41.46061
    _IUnternehm_21 -4.725286 11.67111 -0.40 0.686 -27.71241 18.26184
    _IUnternehm_22 -16.47211 15.21205 -1.08 0.280 -46.4334 13.48917
    _IUnternehm_23 -4.486927 12.41375 -0.36 0.718 -28.93675 19.9629
    _IUnternehm_24 13.11413 18.38299 0.71 0.476 -23.09257 49.32082
    _IUnternehm_25 9.684397 15.62584 0.62 0.536 -21.09188 40.46067
    _IUnternehm_26 14.69772 15.2387 0.96 0.336 -15.31606 44.71149
    _IUnternehm_27 -6.59571 14.57482 -0.45 0.651 -35.30192 22.1105
    _IUnternehm_28 5.690628 11.49149 0.50 0.621 -16.94274 28.32399
    _IUnternehm_29 7.263189 10.90053 0.67 0.506 -14.20623 28.73261
    _IUnternehm_30 54.27688 15.65619 3.47 0.001 23.44083 85.11292
    _IUnternehm_31 1.799696 14.1221 0.13 0.899 -26.01485 29.61424
    _IUnternehm_32 41.18111 11.57496 3.56 0.000 18.38334 63.97887
    _IUnternehm_33 9.193567 10.87896 0.85 0.399 -12.23338 30.62051
    _IUnternehm_34 -18.78013 10.63879 -1.77 0.079 -39.73402 2.173762
    _IUnternehm_35 -3.696596 9.635246 -0.38 0.702 -22.67394 15.28075
    _IUnternehm_36 7.51152 8.79678 0.85 0.394 -9.814405 24.83744
    _IUnternehm_37 7.066402 14.56265 0.49 0.628 -21.61584 35.74864
    _IUnternehm_38 34.83821 10.2329 3.40 0.001 14.68374 54.99269
    _IUnternehm_39 -10.7081 12.98113 -0.82 0.410 -36.27542 14.85923
    _IUnternehm_40 13.68806 11.58929 1.18 0.239 -9.137929 36.51404
    _IUnternehm_41 57.59317 17.35045 3.32 0.001 23.42015 91.76619
    _IUnternehm_42 -3.437701 13.36429 -0.26 0.797 -29.75967 22.88427
    _IUnternehm_43 -2.297358 8.450392 -0.27 0.786 -18.94105 14.34633
    _IUnternehm_44 2.880239 10.46194 0.28 0.783 -17.72534 23.48582
    _IUnternehm_45 -18.96786 10.9294 -1.74 0.084 -40.49414 2.55842
    _IUnternehm_46 -14.54469 9.648038 -1.51 0.133 -33.54723 4.457851
    _IUnternehm_47 -24.71603 10.59782 -2.33 0.020 -45.58923 -3.842824
    _IUnternehm_48 23.25981 11.90508 1.95 0.052 -.1881501 46.70778
    _IUnternehm_49 -6.297338 9.950548 -0.63 0.527 -25.89569 13.30102
    _IUnternehm_50 18.34087 20.53314 0.89 0.373 -22.10071 58.78245
    _IUnternehm_51 -18.92622 15.42757 -1.23 0.221 -49.31199 11.45954
    _IUnternehm_52 -14.16451 9.746474 -1.45 0.147 -33.36092 5.031913
    _IUnternehm_53 -.7125818 9.647064 -0.07 0.941 -19.7132 18.28804
    _IUnternehm_54 8.41392 10.01824 0.84 0.402 -11.31775 28.14559
    _IUnternehm_55 26.42424 14.99984 1.76 0.079 -3.119073 55.96755
    _IUnternehm_56 -23.45135 9.192148 -2.55 0.011 -41.55599 -5.346725
    _IUnternehm_57 -15.05711 9.931668 -1.52 0.131 -34.61828 4.504062
    _IUnternehm_58 57.27402 13.73893 4.17 0.000 30.21415 84.33388
    _IUnternehm_59 -.4294764 14.91609 -0.03 0.977 -29.80784 28.94889
    _IUnternehm_60 -15.16002 8.958061 -1.69 0.092 -32.8036 2.483558
    _IUnternehm_61 17.21946 8.898878 1.94 0.054 -.3075541 34.74647
    _IUnternehm_62 -14.53266 10.48203 -1.39 0.167 -35.17782 6.112498
    _IUnternehm_63 -6.940407 10.67026 -0.65 0.516 -27.95629 14.07548
    _IUnternehm_64 -5.196539 15.06009 -0.35 0.730 -34.85853 24.46546
    _IUnternehm_65 26.02929 19.90437 1.31 0.192 -13.17388 65.23246
    _IUnternehm_66 14.60718 11.24314 1.30 0.195 -7.537036 36.75139
    _IUnternehm_67 -22.08857 8.733508 -2.53 0.012 -39.28987 -4.887264
    _IUnternehm_68 -7.113967 8.458266 -0.84 0.401 -23.77316 9.545228
    _IUnternehm_69 -17.87005 11.78165 -1.52 0.131 -41.07491 5.334804
    _IUnternehm_70 52.5356 12.00522 4.38 0.000 28.89041 76.18079
    _IUnternehm_71 -34.25489 15.97117 -2.14 0.033 -65.71133 -2.798458
    _IUnternehm_72 -8.828511 12.80215 -0.69 0.491 -34.04332 16.3863
    _IUnternehm_73 21.10142 14.70096 1.44 0.152 -7.853237 50.05607
    _IUnternehm_74 -20.18248 11.94858 -1.69 0.092 -43.71611 3.351144
    _IUnternehm_75 12.24323 18.45948 0.66 0.508 -24.11412 48.60058
    _IUnternehm_76 -12.00339 15.06139 -0.80 0.426 -41.66793 17.66115
    _IUnternehm_77 5.011427 12.52339 0.40 0.689 -19.65435 29.6772
    _IUnternehm_78 -29.8218 15.41626 -1.93 0.054 -60.18529 .5416937
    _IUnternehm_79 -24.57285 16.59229 -1.48 0.140 -57.25261 8.106912
    _IJahr_2015 15.09593 3.162919 4.77 0.000 8.866322 21.32554
    _IJahr_2016 21.15731 5.111523 4.14 0.000 11.08978 31.22485
    _IJahr_2017 17.33039 4.970709 3.49 0.001 7.540202 27.12058
    _IJahr_2018 23.44871 3.456689 6.78 0.000 16.6405 30.25692
    _cons 15.75827 61.05587 0.26 0.797 -104.4959 136.0124


    . xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe vce(robust)
    i.Jahr _IJahr_2014-2018 (naturally coded; _IJahr_2014 omitted)

    Fixed-effects (within) regression Number of obs = 342
    Group variable: Unternehmen Number of groups = 79

    R-sq: Obs per group:
    within = 0.7509 min = 1
    between = 0.4127 avg = 4.3
    overall = 0.5609 max = 5

    F(15,78) = 37.55
    corr(u_i, Xb) = -0.1701 Prob > F = 0.0000

    (Std. Err. adjusted for 79 clusters in Unternehmen)

    Robust
    Y Coef. Std. Err. t P>t [95% Conf. Interval]

    x1 .0091464 .0133006 0.69 0.494 -.017333 .0356259
    x2 -4.252209 5.415393 -0.79 0.435 -15.03343 6.52901
    x3 -.473511 .3681172 -1.29 0.202 -1.206376 .2593541
    x4 -12.73621 3.07371 -4.14 0.000 -18.8555 -6.616927
    x5 11.2182 4.267745 2.63 0.010 2.721767 19.71462
    x6 10.09346 .9198481 10.97 0.000 8.262186 11.92474
    x7 .0046431 .008961 0.52 0.606 -.0131968 .0224831
    x8 .0455602 .2953716 0.15 0.878 -.5424795 .6335998
    x9 -.0980529 .1633973 -0.60 0.550 -.4233519 .2272461
    x10 .2070221 .1437574 1.44 0.154 -.0791769 .4932211
    x11 .102173 .0929156 1.10 0.275 -.0828077 .2871538
    _IJahr_2015 15.09593 3.107805 4.86 0.000 8.908765 21.2831
    _IJahr_2016 21.15731 5.616581 3.77 0.000 9.975561 32.33907
    _IJahr_2017 17.33039 5.899157 2.94 0.004 5.586071 29.07471
    _IJahr_2018 23.44871 3.764808 6.23 0.000 15.95355 30.94387
    _cons 17.31959 65.53958 0.26 0.792 -113.1597 147.7989

    sigma_u 21.567956
    sigma_e 12.179949
    rho .75819981 (fraction of variance due to u_i)



  • #2
    Lu:
    welcome to this forum.
    I would recommend you to use CODE delimiters to share what you typed and what Stata gave you back (see the FAQ), as your post is really difficult to read. Thanks.
    That said, robust clustered standard errors affects the standard errors and related stuff (basically, 95%CI and p-value) without affecting the point estimates.
    Hence, as far as I can get from your post, you did nothing wrong.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,
      thank you very much for your help. I try to show the coding again.
      I just wonder if the results are correct when it´s the same. Robust and normal.

      Code:
      . xtset Unternehmen Jahr
             panel variable:  Unternehmen (unbalanced)
              time variable:  Jahr, 2014 to 2018, but with gaps
                      delta:  1 year
      
      . xtreg Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, fe
      
      Fixed-effects (within) regression               Number of obs     =        342
      Group variable: Unternehmen                     Number of groups  =         79
      
      R-sq:                                           Obs per group:
           within  = 0.6964                                         min =          1
           between = 0.3551                                         avg =        4.3
           overall = 0.4950                                         max =          5
      
                                                      F(11,252)         =      52.54
      corr(u_i, Xb)  = -0.2154                        Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
                 Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .0121592    .015234     0.80   0.426     -.017843    .0421614
                x2 |   1.885169   5.310276     0.36   0.723    -8.573006    12.34334
                x3 |  -.4471534   .2738079    -1.63   0.104    -.9863968      .09209
                x4 |   -12.6464   3.358336    -3.77   0.000    -19.26038   -6.032417
                x5 |  -3.154039    1.94352    -1.62   0.106    -6.981651    .6735729
                x6 |   9.843865   .5781626    17.03   0.000     8.705219    10.98251
                x7 |  -.0105897   .0053595    -1.98   0.049    -.0211448   -.0000345
                x8 |  -.0909935   .1932579    -0.47   0.638       -.4716     .289613
                x9 |   .0042337    .179777     0.02   0.981    -.3498233    .3582906
               x10 |   .2618862   .1633328     1.60   0.110    -.0597851    .5835574
               x11 |    .286262   .1016634     2.82   0.005     .0860437    .4864802
             _cons |   10.14478   64.69261     0.16   0.876    -117.2623    137.5519
      -------------+----------------------------------------------------------------
           sigma_u |  22.903426
           sigma_e |   13.34097
               rho |  .74666305   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(78, 252) = 5.96                     Prob > F = 0.0000
      
      . estimates store fe
      
      . xtreg Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, re
      
      Random-effects GLS regression                   Number of obs     =        342
      Group variable: Unternehmen                     Number of groups  =         79
      
      R-sq:                                           Obs per group:
           within  = 0.6785                                         min =          1
           between = 0.5220                                         avg =        4.3
           overall = 0.6113                                         max =          5
      
                                                      Wald chi2(11)     =     611.68
      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
      
      ------------------------------------------------------------------------------
                 Y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .0017081    .012697     0.13   0.893    -.0231775    .0265937
                x2 |   1.529129   1.906254     0.80   0.422     -2.20706    5.265318
                x3 |  -.3607013   .2628963    -1.37   0.170    -.8759687    .1545661
                x4 |  -6.831479   2.186577    -3.12   0.002    -11.11709   -2.545868
                x5 |  -4.372107   1.993001    -2.19   0.028    -8.278317   -.4658961
                x6 |   10.26525   .5341722    19.22   0.000     9.218294    11.31221
                x7 |  -.0058791   .0054074    -1.09   0.277    -.0164774    .0047193
                x8 |   .2901557   .1817283     1.60   0.110    -.0660251    .6463366
                x9 |  -.2081798   .1323955    -1.57   0.116    -.4676702    .0513107
               x10 |   .1843618   .1283733     1.44   0.151    -.0672452    .4359688
               x11 |   .0867639    .079641     1.09   0.276    -.0693296    .2428575
             _cons |   16.62166   31.65446     0.53   0.600    -45.41994    78.66325
      -------------+----------------------------------------------------------------
           sigma_u |  15.001195
           sigma_e |   13.34097
               rho |  .55837761   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . estimates store re
      
      . hausman fe re
      
                       ---- Coefficients ----
                   |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                   |       fe           re         Difference          S.E.
      -------------+----------------------------------------------------------------
                x1 |    .0121592     .0017081        .0104511        .0084179
                x2 |    1.885169     1.529129        .3560401        4.956332
                x3 |   -.4471534    -.3607013       -.0864521        .0765263
                x4 |    -12.6464    -6.831479       -5.814919        2.548981
                x5 |   -3.154039    -4.372107        1.218068               .
                x6 |    9.843865     10.26525       -.4213873         .221206
                x7 |   -.0105897    -.0058791       -.0047106               .
                x8 |   -.0909935     .2901557       -.3811492         .065753
                x9 |    .0042337    -.2081798        .2124134        .1216191
               x10 |    .2618862     .1843618        .0775244        .1009847
               x11 |     .286262     .0867639         .199498        .0631883
      ------------------------------------------------------------------------------
                                 b = consistent under Ho and Ha; obtained from xtreg
                  B = inconsistent under Ha, efficient under Ho; obtained from xtreg
      
          Test:  Ho:  difference in coefficients not systematic
      
                       chi2(11) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                                =       76.16
                      Prob>chi2 =      0.0000
                      (V_b-V_B is not positive definite)
      
      . xtreg Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, fe
      
      Fixed-effects (within) regression               Number of obs     =        342
      Group variable: Unternehmen                     Number of groups  =         79
      
      R-sq:                                           Obs per group:
           within  = 0.6964                                         min =          1
           between = 0.3551                                         avg =        4.3
           overall = 0.4950                                         max =          5
      
                                                      F(11,252)         =      52.54
      corr(u_i, Xb)  = -0.2154                        Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
                 Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .0121592    .015234     0.80   0.426     -.017843    .0421614
                x2 |   1.885169   5.310276     0.36   0.723    -8.573006    12.34334
                x3 |  -.4471534   .2738079    -1.63   0.104    -.9863968      .09209
                x4 |   -12.6464   3.358336    -3.77   0.000    -19.26038   -6.032417
                x5 |  -3.154039    1.94352    -1.62   0.106    -6.981651    .6735729
                x6 |   9.843865   .5781626    17.03   0.000     8.705219    10.98251
                x7 |  -.0105897   .0053595    -1.98   0.049    -.0211448   -.0000345
                x8 |  -.0909935   .1932579    -0.47   0.638       -.4716     .289613
                x9 |   .0042337    .179777     0.02   0.981    -.3498233    .3582906
               x10 |   .2618862   .1633328     1.60   0.110    -.0597851    .5835574
               x11 |    .286262   .1016634     2.82   0.005     .0860437    .4864802
             _cons |   10.14478   64.69261     0.16   0.876    -117.2623    137.5519
      -------------+----------------------------------------------------------------
           sigma_u |  22.903426
           sigma_e |   13.34097
               rho |  .74666305   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(78, 252) = 5.96                     Prob > F = 0.0000
      
      . xttest3
      
      Modified Wald test for groupwise heteroskedasticity
      in fixed effect regression model
      
      H0: sigma(i)^2 = sigma^2 for all i
      
      chi2 (79)  =    1.1e+32
      Prob>chi2 =      0.0000
      
      
      . xi: xtreg Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe
      i.Jahr            _IJahr_2014-2018    (naturally coded; _IJahr_2014 omitted)
      
      Fixed-effects (within) regression               Number of obs     =        342
      Group variable: Unternehmen                     Number of groups  =         79
      
      R-sq:                                           Obs per group:
           within  = 0.7509                                         min =          1
           between = 0.4127                                         avg =        4.3
           overall = 0.5609                                         max =          5
      
                                                      F(15,248)         =      49.85
      corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
                 Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .0091464   .0139301     0.66   0.512      -.01829    .0365829
                x2 |  -4.252209   4.960329    -0.86   0.392    -14.02195    5.517534
                x3 |   -.473511   .2530563    -1.87   0.062    -.9719246    .0249026
                x4 |  -12.73621   3.099359    -4.11   0.000    -18.84064    -6.63179
                x5 |    11.2182   3.789075     2.96   0.003     3.755325    18.68107
                x6 |   10.09346   .5504423    18.34   0.000     9.009325     11.1776
                x7 |   .0046431   .0086834     0.53   0.593    -.0124595    .0217458
                x8 |   .0455602   .2440602     0.19   0.852    -.4351348    .5262552
                x9 |  -.0980529   .1657255    -0.59   0.555    -.4244618     .228356
               x10 |   .2070221   .1506021     1.37   0.170    -.0896001    .5036444
               x11 |    .102173   .0971356     1.05   0.294    -.0891428    .2934889
       _IJahr_2015 |   15.09593   3.162919     4.77   0.000     8.866322    21.32554
       _IJahr_2016 |   21.15731   5.111523     4.14   0.000     11.08978    31.22485
       _IJahr_2017 |   17.33039   4.970709     3.49   0.001     7.540202    27.12058
       _IJahr_2018 |   23.44871   3.456689     6.78   0.000      16.6405    30.25692
             _cons |   17.31959   66.04854     0.26   0.793     -112.768    147.4072
      -------------+----------------------------------------------------------------
           sigma_u |  21.567956
           sigma_e |  12.179949
               rho |  .75819981   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      F test that all u_i=0: F(78, 248) = 6.59                     Prob > F = 0.0000
      
      . xi: regress Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Unternehmen i.Jahr
      i.Unternehmen     _IUnternehm_1-79    (naturally coded; _IUnternehm_1 omitted)
      i.Jahr            _IJahr_2014-2018    (naturally coded; _IJahr_2014 omitted)
      
            Source |       SS           df       MS      Number of obs   =       342
      -------------+----------------------------------   F(93, 248)      =     23.07
             Model |  318227.767        93  3421.80395   Prob > F        =    0.0000
          Residual |  36791.0876       248   148.35116   R-squared       =    0.8964
      -------------+----------------------------------   Adj R-squared   =    0.8575
             Total |  355018.854       341  1041.11101   Root MSE        =     12.18
      
      --------------------------------------------------------------------------------
                   Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ---------------+----------------------------------------------------------------
                  x1 |   .0091464   .0139301     0.66   0.512      -.01829    .0365829
                  x2 |  -4.252209   4.960329    -0.86   0.392    -14.02195    5.517534
                  x3 |   -.473511   .2530563    -1.87   0.062    -.9719246    .0249026
                  x4 |  -12.73621   3.099359    -4.11   0.000    -18.84064    -6.63179
                  x5 |    11.2182   3.789075     2.96   0.003     3.755325    18.68107
                  x6 |   10.09346   .5504423    18.34   0.000     9.009325     11.1776
                  x7 |   .0046431   .0086834     0.53   0.593    -.0124595    .0217458
                  x8 |   .0455602   .2440602     0.19   0.852    -.4351348    .5262552
                  x9 |  -.0980529   .1657255    -0.59   0.555    -.4244618     .228356
                 x10 |   .2070221   .1506021     1.37   0.170    -.0896001    .5036444
                 x11 |    .102173   .0971356     1.05   0.294    -.0891428    .2934889
       _IUnternehm_2 |   1.575516   10.30654     0.15   0.879      -18.724    21.87503
       _IUnternehm_3 |  -39.06488   10.25417    -3.81   0.000    -59.26125   -18.86852
       _IUnternehm_4 |  -24.40019    12.7029    -1.92   0.056    -49.41951    .6191261
       _IUnternehm_5 |  -14.42787   11.04235    -1.31   0.193    -36.17662    7.320877
       _IUnternehm_6 |  -8.348222   9.779419    -0.85   0.394    -27.60953    10.91308
       _IUnternehm_7 |    20.5798   15.03405     1.37   0.172    -9.030897     50.1905
       _IUnternehm_8 |    2.41823   14.65319     0.17   0.869    -26.44234     31.2788
       _IUnternehm_9 |    5.66785   16.76055     0.34   0.736    -27.34332    38.67902
      _IUnternehm_10 |  -16.14584   10.02271    -1.61   0.108    -35.88633    3.594639
      _IUnternehm_11 |   17.81726   18.40685     0.97   0.334    -18.43642    54.07094
      _IUnternehm_12 |   19.34285   14.61768     1.32   0.187    -9.447774    48.13348
      _IUnternehm_13 |   20.54812   12.09701     1.70   0.091    -3.277862     44.3741
      _IUnternehm_14 |   32.32243   12.44368     2.60   0.010     7.813661    56.83119
      _IUnternehm_15 |  -37.85379   12.83629    -2.95   0.003    -63.13584   -12.57174
      _IUnternehm_16 |   46.11187   13.25584     3.48   0.001     20.00349    72.22025
      _IUnternehm_17 |  -6.344185   8.112828    -0.78   0.435    -22.32301    9.634643
      _IUnternehm_18 |   2.288403   11.73014     0.20   0.845    -20.81499     25.3918
      _IUnternehm_19 |   2.392787   11.70008     0.20   0.838    -20.65141    25.43699
      _IUnternehm_20 |   5.753934   18.12912     0.32   0.751    -29.95275    41.46061
      _IUnternehm_21 |  -4.725286   11.67111    -0.40   0.686    -27.71241    18.26184
      _IUnternehm_22 |  -16.47211   15.21205    -1.08   0.280     -46.4334    13.48917
      _IUnternehm_23 |  -4.486927   12.41375    -0.36   0.718    -28.93675     19.9629
      _IUnternehm_24 |   13.11413   18.38299     0.71   0.476    -23.09257    49.32082
      _IUnternehm_25 |   9.684397   15.62584     0.62   0.536    -21.09188    40.46067
      _IUnternehm_26 |   14.69772    15.2387     0.96   0.336    -15.31606    44.71149
      _IUnternehm_27 |   -6.59571   14.57482    -0.45   0.651    -35.30192     22.1105
      _IUnternehm_28 |   5.690628   11.49149     0.50   0.621    -16.94274    28.32399
      _IUnternehm_29 |   7.263189   10.90053     0.67   0.506    -14.20623    28.73261
      _IUnternehm_30 |   54.27688   15.65619     3.47   0.001     23.44083    85.11292
      _IUnternehm_31 |   1.799696    14.1221     0.13   0.899    -26.01485    29.61424
      _IUnternehm_32 |   41.18111   11.57496     3.56   0.000     18.38334    63.97887
      _IUnternehm_33 |   9.193567   10.87896     0.85   0.399    -12.23338    30.62051
      _IUnternehm_34 |  -18.78013   10.63879    -1.77   0.079    -39.73402    2.173762
      _IUnternehm_35 |  -3.696596   9.635246    -0.38   0.702    -22.67394    15.28075
      _IUnternehm_36 |    7.51152    8.79678     0.85   0.394    -9.814405    24.83744
      _IUnternehm_37 |   7.066402   14.56265     0.49   0.628    -21.61584    35.74864
      _IUnternehm_38 |   34.83821    10.2329     3.40   0.001     14.68374    54.99269
      _IUnternehm_39 |   -10.7081   12.98113    -0.82   0.410    -36.27542    14.85923
      _IUnternehm_40 |   13.68806   11.58929     1.18   0.239    -9.137929    36.51404
      _IUnternehm_41 |   57.59317   17.35045     3.32   0.001     23.42015    91.76619
      _IUnternehm_42 |  -3.437701   13.36429    -0.26   0.797    -29.75967    22.88427
      _IUnternehm_43 |  -2.297358   8.450392    -0.27   0.786    -18.94105    14.34633
      _IUnternehm_44 |   2.880239   10.46194     0.28   0.783    -17.72534    23.48582
      _IUnternehm_45 |  -18.96786    10.9294    -1.74   0.084    -40.49414     2.55842
      _IUnternehm_46 |  -14.54469   9.648038    -1.51   0.133    -33.54723    4.457851
      _IUnternehm_47 |  -24.71603   10.59782    -2.33   0.020    -45.58923   -3.842824
      _IUnternehm_48 |   23.25981   11.90508     1.95   0.052    -.1881501    46.70778
      _IUnternehm_49 |  -6.297338   9.950548    -0.63   0.527    -25.89569    13.30102
      _IUnternehm_50 |   18.34087   20.53314     0.89   0.373    -22.10071    58.78245
      _IUnternehm_51 |  -18.92622   15.42757    -1.23   0.221    -49.31199    11.45954
      _IUnternehm_52 |  -14.16451   9.746474    -1.45   0.147    -33.36092    5.031913
      _IUnternehm_53 |  -.7125818   9.647064    -0.07   0.941     -19.7132    18.28804
      _IUnternehm_54 |    8.41392   10.01824     0.84   0.402    -11.31775    28.14559
      _IUnternehm_55 |   26.42424   14.99984     1.76   0.079    -3.119073    55.96755
      _IUnternehm_56 |  -23.45135   9.192148    -2.55   0.011    -41.55599   -5.346725
      _IUnternehm_57 |  -15.05711   9.931668    -1.52   0.131    -34.61828    4.504062
      _IUnternehm_58 |   57.27402   13.73893     4.17   0.000     30.21415    84.33388
      _IUnternehm_59 |  -.4294764   14.91609    -0.03   0.977    -29.80784    28.94889
      _IUnternehm_60 |  -15.16002   8.958061    -1.69   0.092     -32.8036    2.483558
      _IUnternehm_61 |   17.21946   8.898878     1.94   0.054    -.3075541    34.74647
      _IUnternehm_62 |  -14.53266   10.48203    -1.39   0.167    -35.17782    6.112498
      _IUnternehm_63 |  -6.940407   10.67026    -0.65   0.516    -27.95629    14.07548
      _IUnternehm_64 |  -5.196539   15.06009    -0.35   0.730    -34.85853    24.46546
      _IUnternehm_65 |   26.02929   19.90437     1.31   0.192    -13.17388    65.23246
      _IUnternehm_66 |   14.60718   11.24314     1.30   0.195    -7.537036    36.75139
      _IUnternehm_67 |  -22.08857   8.733508    -2.53   0.012    -39.28987   -4.887264
      _IUnternehm_68 |  -7.113967   8.458266    -0.84   0.401    -23.77316    9.545228
      _IUnternehm_69 |  -17.87005   11.78165    -1.52   0.131    -41.07491    5.334804
      _IUnternehm_70 |    52.5356   12.00522     4.38   0.000     28.89041    76.18079
      _IUnternehm_71 |  -34.25489   15.97117    -2.14   0.033    -65.71133   -2.798458
      _IUnternehm_72 |  -8.828511   12.80215    -0.69   0.491    -34.04332     16.3863
      _IUnternehm_73 |   21.10142   14.70096     1.44   0.152    -7.853237    50.05607
      _IUnternehm_74 |  -20.18248   11.94858    -1.69   0.092    -43.71611    3.351144
      _IUnternehm_75 |   12.24323   18.45948     0.66   0.508    -24.11412    48.60058
      _IUnternehm_76 |  -12.00339   15.06139    -0.80   0.426    -41.66793    17.66115
      _IUnternehm_77 |   5.011427   12.52339     0.40   0.689    -19.65435     29.6772
      _IUnternehm_78 |   -29.8218   15.41626    -1.93   0.054    -60.18529    .5416937
      _IUnternehm_79 |  -24.57285   16.59229    -1.48   0.140    -57.25261    8.106912
         _IJahr_2015 |   15.09593   3.162919     4.77   0.000     8.866322    21.32554
         _IJahr_2016 |   21.15731   5.111523     4.14   0.000     11.08978    31.22485
         _IJahr_2017 |   17.33039   4.970709     3.49   0.001     7.540202    27.12058
         _IJahr_2018 |   23.44871   3.456689     6.78   0.000      16.6405    30.25692
               _cons |   15.75827   61.05587     0.26   0.797    -104.4959    136.0124
      --------------------------------------------------------------------------------
      
      . xi: xtreg Y  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe vce(robust)
      i.Jahr            _IJahr_2014-2018    (naturally coded; _IJahr_2014 omitted)
      
      Fixed-effects (within) regression               Number of obs     =        342
      Group variable: Unternehmen                     Number of groups  =         79
      
      R-sq:                                           Obs per group:
           within  = 0.7509                                         min =          1
           between = 0.4127                                         avg =        4.3
           overall = 0.5609                                         max =          5
      
                                                      F(15,78)          =      37.55
      corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
      
                                 (Std. Err. adjusted for 79 clusters in Unternehmen)
      ------------------------------------------------------------------------------
                   |               Robust
                 Y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .0091464   .0133006     0.69   0.494     -.017333    .0356259
                x2 |  -4.252209   5.415393    -0.79   0.435    -15.03343     6.52901
                x3 |   -.473511   .3681172    -1.29   0.202    -1.206376    .2593541
                x4 |  -12.73621    3.07371    -4.14   0.000     -18.8555   -6.616927
                x5 |    11.2182   4.267745     2.63   0.010     2.721767    19.71462
                x6 |   10.09346   .9198481    10.97   0.000     8.262186    11.92474
                x7 |   .0046431    .008961     0.52   0.606    -.0131968    .0224831
                x8 |   .0455602   .2953716     0.15   0.878    -.5424795    .6335998
                x9 |  -.0980529   .1633973    -0.60   0.550    -.4233519    .2272461
               x10 |   .2070221   .1437574     1.44   0.154    -.0791769    .4932211
               x11 |    .102173   .0929156     1.10   0.275    -.0828077    .2871538
       _IJahr_2015 |   15.09593   3.107805     4.86   0.000     8.908765     21.2831
       _IJahr_2016 |   21.15731   5.616581     3.77   0.000     9.975561    32.33907
       _IJahr_2017 |   17.33039   5.899157     2.94   0.004     5.586071    29.07471
       _IJahr_2018 |   23.44871   3.764808     6.23   0.000     15.95355    30.94387
                 _cons |   17.31959   65.53958     0.26   0.792    -113.1597    147.7989
      -------------+----------------------------------------------------------------
           sigma_u |  21.567956
           sigma_e |  12.179949
                   rho |  .75819981   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      .

      Comment


      • #4

        Lu:
        thanks for re-posting using CODE delimiters, that allows more comments on your query:
        !) As already commented above, the following codes are expected to give you the same point estimates (whereas the other results differ):
        . xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe
        xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe vce(robust).
        2) it's methodologically wrong to compare -fe- and -re- specification via -hausman- and then add robust or clustered standard errors after -hausman- outcome.
        If you detected heteroskedastcity and/or autocorrelation in your dataset and wisely invoked robust or clustered standard errors (under -xtreg- they do the very same job and give back identical results), you should replace -hausman- with the communuty-contributed command -xtoverid-, that need the -re- specification only to work properly, as you can see from the following toy-example:
        Code:
        . use "https://www.stata-press.com/data/r16/nlswork.dta"
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        
        . xtreg ln_wage age, vce(cluster idcode)
        
        Random-effects GLS regression                   Number of obs     =     28,510
        Group variable: idcode                          Number of groups  =      4,710
        
        R-sq:                                           Obs per group:
             within  = 0.1026                                         min =          1
             between = 0.0877                                         avg =        6.1
             overall = 0.0774                                         max =         15
        
                                                        Wald chi2(1)      =    1064.91
        corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
        
                                     (Std. Err. adjusted for 4,710 clusters in idcode)
        ------------------------------------------------------------------------------
                     |               Robust
             ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 age |   .0185667    .000569    32.63   0.000     .0174516    .0196819
               _cons |   1.120439   .0159154    70.40   0.000     1.089245    1.151632
        -------------+----------------------------------------------------------------
             sigma_u |  .36972456
             sigma_e |  .30349389
                 rho |  .59743613   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        
        . xtoverid
        
        Test of overidentifying restrictions: fixed vs random effects
        Cross-section time-series model: xtreg re  robust cluster(idcode)
        Sargan-Hansen statistic  14.529  Chi-sq(1)    P-value = 0.0001
        
        .
        In this example, by rejecting the null (loosely speaking, the null states that -re- is OK), -xtoverid- outcome points you to -fe- specification.
        In addition, -xtoverid-, being glorious but a bit old-fashioned, does not support -fvvarlist- notation; hence, prefixing your code with -xi:- is the fix. Conversely, please note that all the Stata built-in commands support -fvvarlist- notation, which is the best way to create categorical variables and interactions.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          unfortunately its not possible for me to run xtoverid:

          Code:
          . xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11, vce(cluster Unternehmen)
          
          Random-effects GLS regression                   Number of obs     =        342
          Group variable: Unternehmen                     Number of groups  =         79
          
          R-sq:                                           Obs per group:
               within  = 0.6785                                         min =          1
               between = 0.5220                                         avg =        4.3
               overall = 0.6113                                         max =          5
          
                                                          Wald chi2(11)     =     362.53
          corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
          
                                     (Std. Err. adjusted for 79 clusters in Unternehmen)
          ------------------------------------------------------------------------------
                       |               Robust
                     Y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                    x1 |   .0017081   .0113987     0.15   0.881    -.0206329    .0240492
                    x2 |   1.529129    1.98697     0.77   0.442    -2.365261    5.423519
                    x3 |  -.3607013   .2983987    -1.21   0.227    -.9455521    .2241495
                    x4 |  -6.831479   2.396766    -2.85   0.004    -11.52906   -2.133904
                    x5 |  -4.372107   2.324113    -1.88   0.060    -8.927285    .1830718
                    x6 |   10.26525   .8676914    11.83   0.000     8.564609     11.9659
                    x7 |  -.0058791   .0051341    -1.15   0.252    -.0159417    .0041836
                    x8 |   .2901557   .1825913     1.59   0.112    -.0677166    .6480281
                    x9 |  -.2081798   .1454665    -1.43   0.152    -.4932889    .0769294
                   x10 |   .1843618    .123079     1.50   0.134    -.0568687    .4255922
                   x11 |   .0867639   .0840197     1.03   0.302    -.0779116    .2514395
                 _cons |   16.62166   33.26694     0.50   0.617    -48.58034    81.82365
          -------------+----------------------------------------------------------------
               sigma_u |  15.001195
               sigma_e |   13.34097
                   rho |  .55837761   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          . xtoverid
          Error - must have ivreg2/ivreg29/ivreg28 version 2.1.15 or greater installed
          r(601);
          
          .
          1.)Are there other possibility to test for fe/re analysis and autocorrelation and heteroskedastcity ?
          2.)And are there other tests necessary before running a Panelanalysis?

          I´m sorry but now I´m a little bit confused.
          3.) It´s not correct to test if I have to use FE or RE effects with running first xtreg for both and test with Hausmann?
          4.)When I have to use FE and have autocorrelation and heteroskedastcity : It´s correct to do the Analyse with xi: xtreg for time and entity effects or with xi: regress y x i.country i.year ?

          My problem is that my basis is a table with this: −0.290 (0.068)***and the comment: Robust standard errors are in parentheses (Huber–White sandwich
          estimators). ***p < 0.01, **p < 0.05, *p < 0.1.and I thought that the first numbers are the Coef. of the "normal" FE-Panelanalysis and the number in the bracket the Coef. with Huber-White sandwich estimators --> vce (robust) ...And here are different results fof Coef. with and without vce robust...

          Its the first time I worked with Panel in Stata...

          Comment


          • #6
            Lu:
            1) if you install one of the suggested community-contributed command, then you'll be able to run -xtoverid-;
            3) yes it is, as long as you have default standard errors (and this one is an unavoidable condition, as -hausman- does not support non-default standard errors). What is wrong is to add non-default standard errors after -hausman- outcome.
            4) if you have detected heteroskedastcity and/or autocorrelation, you should run the following code:
            Code:
            xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.year, vce(cluster Unternehmen)
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Ok many thanks! But running your code the analysis is for random effects not for fixed effects. And -xtoverid- has the same result as Hausman that I have to use Fixed effects with entity and time fixed effects and I detected heteroskedastcity and/or autocorrelation...

              Comment


              • #8
                Using
                Code:
                . xtreg CDSSpread Verschuldung nUnternehmensgröße Gesamtkapitalrentabilität ALTMANsScore Zinsstrukturkurve Marktliq
                > uidität Marktentwicklung impliziteVolatilität EnSc SoSc GoSc i.Jahr, fe vce(robust)
                
                Fixed-effects (within) regression               Number of obs     =        342
                Group variable: Unternehmen                     Number of groups  =         79
                
                R-sq:                                           Obs per group:
                     within  = 0.7509                                         min =          1
                     between = 0.4127                                         avg =        4.3
                     overall = 0.5609                                         max =          5
                
                                                                F(15,78)          =      37.55
                corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
                
                                                        (Std. Err. adjusted for 79 clusters in Unternehmen)
                -------------------------------------------------------------------------------------------
                                          |               Robust
                                CDSSpread |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                --------------------------+----------------------------------------------------------------
                             Verschuldung |   .0091464   .0133006     0.69   0.494     -.017333    .0356259
                       nUnternehmensgröße |  -4.252209   5.415393    -0.79   0.435    -15.03343     6.52901
                Gesamtkapitalrentabilität |   -.473511   .3681172    -1.29   0.202    -1.206376    .2593541
                             ALTMANsScore |  -12.73621    3.07371    -4.14   0.000     -18.8555   -6.616927
                        Zinsstrukturkurve |    11.2182   4.267745     2.63   0.010     2.721767    19.71462
                          Marktliquidität |   10.09346   .9198481    10.97   0.000     8.262186    11.92474
                         Marktentwicklung |   .0046431    .008961     0.52   0.606    -.0131968    .0224831
                     impliziteVolatilität |   .0455602   .2953716     0.15   0.878    -.5424795    .6335998
                                     EnSc |  -.0980529   .1633973    -0.60   0.550    -.4233519    .2272461
                                     SoSc |   .2070221   .1437574     1.44   0.154    -.0791769    .4932211
                                     GoSc |    .102173   .0929156     1.10   0.275    -.0828077    .2871538
                                          |
                                     Jahr |
                                    2015  |   15.09593   3.107805     4.86   0.000     8.908765     21.2831
                                    2016  |   21.15731   5.616581     3.77   0.000     9.975561    32.33907
                                    2017  |   17.33039   5.899157     2.94   0.004     5.586071    29.07471
                                    2018  |   23.44871   3.764808     6.23   0.000     15.95355    30.94387
                                          |
                                    _cons |   17.31959   65.53958     0.26   0.792    -113.1597    147.7989
                --------------------------+----------------------------------------------------------------
                                  sigma_u |  21.567956
                                  sigma_e |  12.179949
                                      rho |  .75819981   (fraction of variance due to u_i)
                -------------------------------------------------------------------------------------------
                
                . xtreg CDSSpread Verschuldung nUnternehmensgröße Gesamtkapitalrentabilität ALTMANsScore Zinsstrukturkurve Marktliq
                > uidität Marktentwicklung impliziteVolatilität EnSc SoSc GoSc i.Jahr, fe vce(robust)
                
                Fixed-effects (within) regression               Number of obs     =        342
                Group variable: Unternehmen                     Number of groups  =         79
                
                R-sq:                                           Obs per group:
                     within  = 0.7509                                         min =          1
                     between = 0.4127                                         avg =        4.3
                     overall = 0.5609                                         max =          5
                
                                                                F(15,78)          =      37.55
                corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
                
                                                        (Std. Err. adjusted for 79 clusters in Unternehmen)
                -------------------------------------------------------------------------------------------
                                          |               Robust
                                CDSSpread |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                --------------------------+----------------------------------------------------------------
                             Verschuldung |   .0091464   .0133006     0.69   0.494     -.017333    .0356259
                       nUnternehmensgröße |  -4.252209   5.415393    -0.79   0.435    -15.03343     6.52901
                Gesamtkapitalrentabilität |   -.473511   .3681172    -1.29   0.202    -1.206376    .2593541
                             ALTMANsScore |  -12.73621    3.07371    -4.14   0.000     -18.8555   -6.616927
                        Zinsstrukturkurve |    11.2182   4.267745     2.63   0.010     2.721767    19.71462
                          Marktliquidität |   10.09346   .9198481    10.97   0.000     8.262186    11.92474
                         Marktentwicklung |   .0046431    .008961     0.52   0.606    -.0131968    .0224831
                     impliziteVolatilität |   .0455602   .2953716     0.15   0.878    -.5424795    .6335998
                                     EnSc |  -.0980529   .1633973    -0.60   0.550    -.4233519    .2272461
                                     SoSc |   .2070221   .1437574     1.44   0.154    -.0791769    .4932211
                                     GoSc |    .102173   .0929156     1.10   0.275    -.0828077    .2871538
                                          |
                                     Jahr |
                                    2015  |   15.09593   3.107805     4.86   0.000     8.908765     21.2831
                                    2016  |   21.15731   5.616581     3.77   0.000     9.975561    32.33907
                                    2017  |   17.33039   5.899157     2.94   0.004     5.586071    29.07471
                                    2018  |   23.44871   3.764808     6.23   0.000     15.95355    30.94387
                                          |
                                    _cons |   17.31959   65.53958     0.26   0.792    -113.1597    147.7989
                --------------------------+----------------------------------------------------------------
                                  sigma_u |  21.567956
                                  sigma_e |  12.179949
                                      rho |  .75819981   (fraction of variance due to u_i)
                -------------------------------------------------------------------------------------------
                brings the same results...and this is finally the correct way?
                If i want to show first without robust standard erros: What is the correct form for time and entity fixed effects? Just - xtreg y X1 X2 i.year, fe - ?

                Comment


                • #9
                  Sorry I mean:
                  Code:
                  . xtreg CDSSpread Verschuldung nUnternehmensgröße Gesamtkapitalrentabilität ALTMANsScore Zinsstrukturkurve Marktliq
                  > uidität Marktentwicklung impliziteVolatilität EnSc SoSc GoSc i.Jahr, fe vce(cluster Unternehmen)
                  
                  Fixed-effects (within) regression               Number of obs     =        342
                  Group variable: Unternehmen                     Number of groups  =         79
                  
                  R-sq:                                           Obs per group:
                       within  = 0.7509                                         min =          1
                       between = 0.4127                                         avg =        4.3
                       overall = 0.5609                                         max =          5
                  
                                                                  F(15,78)          =      37.55
                  corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
                  
                                                          (Std. Err. adjusted for 79 clusters in Unternehmen)
                  -------------------------------------------------------------------------------------------
                                            |               Robust
                                  CDSSpread |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  --------------------------+----------------------------------------------------------------
                               Verschuldung |   .0091464   .0133006     0.69   0.494     -.017333    .0356259
                         nUnternehmensgröße |  -4.252209   5.415393    -0.79   0.435    -15.03343     6.52901
                  Gesamtkapitalrentabilität |   -.473511   .3681172    -1.29   0.202    -1.206376    .2593541
                               ALTMANsScore |  -12.73621    3.07371    -4.14   0.000     -18.8555   -6.616927
                          Zinsstrukturkurve |    11.2182   4.267745     2.63   0.010     2.721767    19.71462
                            Marktliquidität |   10.09346   .9198481    10.97   0.000     8.262186    11.92474
                           Marktentwicklung |   .0046431    .008961     0.52   0.606    -.0131968    .0224831
                       impliziteVolatilität |   .0455602   .2953716     0.15   0.878    -.5424795    .6335998
                                       EnSc |  -.0980529   .1633973    -0.60   0.550    -.4233519    .2272461
                                       SoSc |   .2070221   .1437574     1.44   0.154    -.0791769    .4932211
                                       GoSc |    .102173   .0929156     1.10   0.275    -.0828077    .2871538
                                            |
                                       Jahr |
                                      2015  |   15.09593   3.107805     4.86   0.000     8.908765     21.2831
                                      2016  |   21.15731   5.616581     3.77   0.000     9.975561    32.33907
                                      2017  |   17.33039   5.899157     2.94   0.004     5.586071    29.07471
                                      2018  |   23.44871   3.764808     6.23   0.000     15.95355    30.94387
                                            |
                                      _cons |   17.31959   65.53958     0.26   0.792    -113.1597    147.7989
                  --------------------------+----------------------------------------------------------------
                                    sigma_u |  21.567956
                                    sigma_e |  12.179949
                                        rho |  .75819981   (fraction of variance due to u_i)
                  -------------------------------------------------------------------------------------------
                  
                  . xtreg CDSSpread Verschuldung nUnternehmensgröße Gesamtkapitalrentabilität ALTMANsScore Zinsstrukturkurve Marktliq
                  > uidität Marktentwicklung impliziteVolatilität EnSc SoSc GoSc i.Jahr, fe vce(robust)
                  
                  Fixed-effects (within) regression               Number of obs     =        342
                  Group variable: Unternehmen                     Number of groups  =         79
                  
                  R-sq:                                           Obs per group:
                       within  = 0.7509                                         min =          1
                       between = 0.4127                                         avg =        4.3
                       overall = 0.5609                                         max =          5
                  
                                                                  F(15,78)          =      37.55
                  corr(u_i, Xb)  = -0.1701                        Prob > F          =     0.0000
                  
                                                          (Std. Err. adjusted for 79 clusters in Unternehmen)
                  -------------------------------------------------------------------------------------------
                                            |               Robust
                                  CDSSpread |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  --------------------------+----------------------------------------------------------------
                               Verschuldung |   .0091464   .0133006     0.69   0.494     -.017333    .0356259
                         nUnternehmensgröße |  -4.252209   5.415393    -0.79   0.435    -15.03343     6.52901
                  Gesamtkapitalrentabilität |   -.473511   .3681172    -1.29   0.202    -1.206376    .2593541
                               ALTMANsScore |  -12.73621    3.07371    -4.14   0.000     -18.8555   -6.616927
                          Zinsstrukturkurve |    11.2182   4.267745     2.63   0.010     2.721767    19.71462
                            Marktliquidität |   10.09346   .9198481    10.97   0.000     8.262186    11.92474
                           Marktentwicklung |   .0046431    .008961     0.52   0.606    -.0131968    .0224831
                       impliziteVolatilität |   .0455602   .2953716     0.15   0.878    -.5424795    .6335998
                                       EnSc |  -.0980529   .1633973    -0.60   0.550    -.4233519    .2272461
                                       SoSc |   .2070221   .1437574     1.44   0.154    -.0791769    .4932211
                                       GoSc |    .102173   .0929156     1.10   0.275    -.0828077    .2871538
                                            |
                                       Jahr |
                                      2015  |   15.09593   3.107805     4.86   0.000     8.908765     21.2831
                                      2016  |   21.15731   5.616581     3.77   0.000     9.975561    32.33907
                                      2017  |   17.33039   5.899157     2.94   0.004     5.586071    29.07471
                                      2018  |   23.44871   3.764808     6.23   0.000     15.95355    30.94387
                                            |
                                      _cons |   17.31959   65.53958     0.26   0.792    -113.1597    147.7989
                  --------------------------+----------------------------------------------------------------
                                    sigma_u |  21.567956
                                    sigma_e |  12.179949
                                        rho |  .75819981   (fraction of variance due to u_i)
                  -------------------------------------------------------------------------------------------
                  
                  .

                  Comment


                  • #10
                    Lu:
                    my previous code used -re- specification indeed, as -xtoverid- throws an error message when used after -xtreg, fe-.
                    Your code:
                    Code:
                    xtset entity year
                    xtreg Y X1 X2 i.year,fe
                    gives you the fixed effect for-entity- only, -i.year- simply being a categorical predictor.
                    As previously pointed out, if you want to capture tour or more fixed effects, you should switch to the community-contributed command -reghdfe-.
                    Eventually, your last two regression codes give back the same results.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Thank you very much for your support! I will try it tomorrow :-) I wish you a nice evening

                      Comment


                      • #12
                        Actually, including i.year in the above xtreg, Fe command achieves exactly what you want: entity and year fixed effects.

                        Comment


                        • #13
                          Jeff Wooldridge
                          I would be grateful to receive a clarification on the following points.
                          Via -predict- -xtreg,fe- we obtain the fixed effect of the panels that we -xtset- at the beginning of the procedure.
                          For each other categorical variable, -i.time- included, -predict- after -xtreg,fe- does not give back anything.
                          Conversely, the community-contributed command -reghdfe- allows operators to include two or more fixed effect and obtain the related fixed effects as new variables.
                          That said, can we consider -i.year- in -xtreg,fe- a fixed effect according to panel data regression terms?
                          Thanks a lot in advance.
                          I attach an example below:
                          Code:
                          use "https://www.stata-press.com/data/r16/nlswork.dta"
                          . xtreg ln_wage i.year age, fe
                          
                          Fixed-effects (within) regression               Number of obs     =     28,510
                          Group variable: idcode                          Number of groups  =      4,710
                          
                          R-sq:                                           Obs per group:
                               within  = 0.1060                                         min =          1
                               between = 0.0914                                         avg =        6.1
                               overall = 0.0805                                         max =         15
                          
                                                                          F(15,23785)       =     188.00
                          corr(u_i, Xb)  = 0.0467                         Prob > F          =     0.0000
                          
                          ------------------------------------------------------------------------------
                               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          -------------+----------------------------------------------------------------
                                  year |
                                   69  |   .0748621   .0159011     4.71   0.000      .043695    .1060292
                                   70  |   .0478697   .0235673     2.03   0.042     .0016763     .094063
                                   71  |   .0865577   .0327939     2.64   0.008     .0222795     .150836
                                   72  |   .0856757   .0424903     2.02   0.044     .0023919    .1689594
                                   73  |   .0880069    .052344     1.68   0.093    -.0145906    .1906044
                                   75  |   .0778607   .0720304     1.08   0.280    -.0633235    .2190449
                                   77  |    .108365   .0922272     1.17   0.240    -.0724063    .2891363
                                   78  |   .1309518   .1028143     1.27   0.203    -.0705707    .3324743
                                   80  |   .1142649    .122792     0.93   0.352    -.1264152     .354945
                                   82  |   .1090451   .1431112     0.76   0.446    -.1714619    .3895522
                                   83  |   .1211272   .1532018     0.79   0.429    -.1791581    .4214125
                                   85  |   .1465637   .1736146     0.84   0.399    -.1937321    .4868594
                                   87  |   .1382642   .1941163     0.71   0.476     -.242216    .5187445
                                   88  |   .1799741   .2079871     0.87   0.387    -.2276938     .587642
                                       |
                                   age |   .0125992   .0102163     1.23   0.217    -.0074253    .0326238
                                 _cons |   1.203731   .1952306     6.17   0.000     .8210667    1.586396
                          -------------+----------------------------------------------------------------
                               sigma_u |   .4058746
                               sigma_e |  .30300411
                                   rho |  .64212421   (fraction of variance due to u_i)
                          ------------------------------------------------------------------------------
                          F test that all u_i=0: F(4709, 23785) = 8.80                 Prob > F = 0.0000
                          
                          .
                          
                          predict U_hat, u
                          
                          . reghdfe ln_wage age, absorb(FE1=idcode FE2=year)
                          (dropped 551 singleton observations)
                          (converged in 9 iterations)
                          (converged in 10 iterations)
                          
                          HDFE Linear regression                            Number of obs   =     27,959
                          Absorbing 2 HDFE groups                           F(   1,  23785) =       1.52
                                                                            Prob > F        =     0.2175
                                                                            R-squared       =     0.6553
                                                                            Adj R-squared   =     0.5949
                                                                            Within R-sq.    =     0.0001
                                                                            Root MSE        =     0.3030
                          
                          ------------------------------------------------------------------------------
                               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          -------------+----------------------------------------------------------------
                                   age |   .0125992   .0102163     1.23   0.217    -.0074253    .0326238
                          -------------+----------------------------------------------------------------
                              Absorbed |    F(4172, 23785) =      9.568   0.000             (Joint test)
                          ------------------------------------------------------------------------------
                          
                          Absorbed degrees of freedom:
                          ---------------------------------------------------------------+
                           Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     |
                          -------------+-------------------------------------------------|
                                idcode |         4159            4159              0     |
                                  year |           14              15              1     |
                          ---------------------------------------------------------------+
                          
                          . list idcode year U_hat FE1 FE2 if idcode==1
                          
                                 +---------------------------------------------------+
                                 | idcode   year      U_hat         FE1          FE2 |
                                 |---------------------------------------------------|
                              1. |      1     70   .3944654   .39254547   -.05767195 |
                              2. |      1     71   .3944654   .39254547   -.01898388 |
                              3. |      1     72   .3944654   .39254547   -.01986592 |
                              4. |      1     73   .3944654   .39254547   -.01753474 |
                              5. |      1     75   .3944654   .39254547   -.02768092 |
                                 |---------------------------------------------------|
                              6. |      1     77   .3944654   .39254547    .00282337 |
                              7. |      1     78   .3944654   .39254547    .02541019 |
                              8. |      1     80   .3944654   .39254547    .00872329 |
                              9. |      1     83   .3944654   .39254547    .01558559 |
                             10. |      1     85   .3944654   .39254547    .04102204 |
                                 |---------------------------------------------------|
                             11. |      1     87   .3944654   .39254547    .03272262 |
                             12. |      1     88   .3944654   .39254547     .0744325 |
                                 +---------------------------------------------------+
                          
                          .
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            Originally posted by Carlo Lazzaro View Post
                            Lu:
                            thanks for re-posting using CODE delimiters, that allows more comments on your query:
                            !) As already commented above, the following codes are expected to give you the same point estimates (whereas the other results differ):
                            . xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe
                            xi: xtreg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 i.Jahr, fe vce(robust).
                            2) it's methodologically wrong to compare -fe- and -re- specification via -hausman- and then add robust or clustered standard errors after -hausman- outcome.
                            If you detected heteroskedastcity and/or autocorrelation in your dataset and wisely invoked robust or clustered standard errors (under -xtreg- they do the very same job and give back identical results), you should replace -hausman- with the communuty-contributed command -xtoverid-, that need the -re- specification only to work properly, as you can see from the following toy-example:
                            Code:
                            . use "https://www.stata-press.com/data/r16/nlswork.dta"
                            (National Longitudinal Survey. Young Women 14-26 years of age in 1968)
                            
                            . xtreg ln_wage age, vce(cluster idcode)
                            
                            Random-effects GLS regression Number of obs = 28,510
                            Group variable: idcode Number of groups = 4,710
                            
                            R-sq: Obs per group:
                            within = 0.1026 min = 1
                            between = 0.0877 avg = 6.1
                            overall = 0.0774 max = 15
                            
                            Wald chi2(1) = 1064.91
                            corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000
                            
                            (Std. Err. adjusted for 4,710 clusters in idcode)
                            ------------------------------------------------------------------------------
                            | Robust
                            ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                            -------------+----------------------------------------------------------------
                            age | .0185667 .000569 32.63 0.000 .0174516 .0196819
                            _cons | 1.120439 .0159154 70.40 0.000 1.089245 1.151632
                            -------------+----------------------------------------------------------------
                            sigma_u | .36972456
                            sigma_e | .30349389
                            rho | .59743613 (fraction of variance due to u_i)
                            ------------------------------------------------------------------------------
                            
                            . xtoverid
                            
                            Test of overidentifying restrictions: fixed vs random effects
                            Cross-section time-series model: xtreg re robust cluster(idcode)
                            Sargan-Hansen statistic 14.529 Chi-sq(1) P-value = 0.0001
                            
                            .
                            In this example, by rejecting the null (loosely speaking, the null states that -re- is OK), -xtoverid- outcome points you to -fe- specification.
                            In addition, -xtoverid-, being glorious but a bit old-fashioned, does not support -fvvarlist- notation; hence, prefixing your code with -xi:- is the fix. Conversely, please note that all the Stata built-in commands support -fvvarlist- notation, which is the best way to create categorical variables and interactions.
                            Hello Carlo,
                            regarding to this post.
                            I understand that it´s not correct to run first -xtreg y 1, fe-, -estimates store fe-, -xtreg y x1,re- , -estimates store re- and than run the Hausman test?
                            Because when I use first my time and entity fixed effects model and then use hausman it´s not possibe:

                            Code:
                            . hausman fe re
                            hausman cannot be used with vce(robust), vce(cluster cvar), or p-weighted data
                            r(198);
                            I understand the literature that after the Hausmantest I decide for FE-Modell (depends on the results) and test than for Heterogeneity, Autocorrelation etc.
                            Because for exapmle Wald-Test gives me the result of Presence of Heteroskedasticity and than I have use "robust" for the finally analysis...
                            I think I have to wrote in my work that I run different tests and this tests lead me to the result that I have to use time and entity fixed effects with the option robust...

                            Thanks in adavance

                            Comment


                            • #15
                              Lu:
                              you're right.
                              Imposing non-default standard errors implies switching from -hausman- to the community-contributed programme -xtoverid-.
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X