Announcement

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

  • xtscc with time fixed effect

    Hi
    While doing robustness check I found that I have the existence of serial correlation and heteroscedasticity in my model.

    xtreg y x, fe (cluster id)
    xttest3
    xtreg y x, fe
    xtcsd, pesaran abs

    In both test I have significant result (p 0.0000) which is implying the existence of heteroscedasticity and correlation.
    I tried to use xtscc command with lag(17) as I have 140 country and 17 years.

    Now is it okay to use xtscc? how can I use time fixed effect as its also important for the model. Did testparm and got p value 0.0039. Does that mean I need to use time fixed effect?
    Best
    Nuzaba

  • #2
    Nuzaba:
    -xtscc- is for small N, large T panel datasets.
    As that does not seem to be your case, I would go -xtreg y x, fe (cluster id)- as you did.
    You can plug -i.year. among the predictors and, as you already did, use -tesparm- for checking its joint statistical significance.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Hi again Carlo
      Thanks for your suggestion and you saw that I used cluster id command and tesparm where I got p=0.0039. How can I describe that?
      If cluster id solves heteroscedasticity and auto correlation problem then after testing why am I having significant result for the existence of those disturbances? Is something wrong with my data or variables?
      Best
      Nuzaba

      Comment


      • #4
        Nuzaba:
        -xttest3- will give you the same outcome before and after clustering your standard errors (see example below):
        Code:
        . use "http://www.stata-press.com/data/r14/nlswork.dta", clear
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        
        . xtreg ln_wage tenure, fe
        
        Fixed-effects (within) regression               Number of obs     =     28,101
        Group variable: idcode                          Number of groups  =      4,699
        
        R-sq:                                           Obs per group:
             within  = 0.0972                                         min =          1
             between = 0.1966                                         avg =        6.0
             overall = 0.1373                                         max =         15
        
                                                        F(1,23401)        =    2520.15
        corr(u_i, Xb)  = 0.1395                         Prob > F          =     0.0000
        
        ------------------------------------------------------------------------------
             ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              tenure |   .0341807   .0006809    50.20   0.000     .0328462    .0355153
               _cons |   1.570329   .0027935   562.14   0.000     1.564854    1.575805
        -------------+----------------------------------------------------------------
             sigma_u |  .39172445
             sigma_e |  .30357621
                 rho |  .62477177   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F test that all u_i=0: F(4698, 23401) = 7.80                 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 (4699)  =  9.7e+35
        Prob>chi2 =      0.0000
        
        . predict A, e
        (433 missing values generated)
        
        . xtreg ln_wage tenure, fe vce(cluster idcode)
        
        Fixed-effects (within) regression               Number of obs     =     28,101
        Group variable: idcode                          Number of groups  =      4,699
        
        R-sq:                                           Obs per group:
             within  = 0.0972                                         min =          1
             between = 0.1966                                         avg =        6.0
             overall = 0.1373                                         max =         15
        
                                                        F(1,4698)         =    1221.93
        corr(u_i, Xb)  = 0.1395                         Prob > F          =     0.0000
        
                                     (Std. Err. adjusted for 4,699 clusters in idcode)
        ------------------------------------------------------------------------------
                     |               Robust
             ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              tenure |   .0341807   .0009778    34.96   0.000     .0322638    .0360977
               _cons |   1.570329   .0030546   514.09   0.000     1.564341    1.576318
        -------------+----------------------------------------------------------------
             sigma_u |  .39172445
             sigma_e |  .30357621
                 rho |  .62477177   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        
        . xttest3
        
        Modified Wald test for groupwise heteroskedasticity
        in fixed effect regression model
        
        H0: sigma(i)^2 = sigma^2 for all i
        
        chi2 (4699)  =  9.7e+35
        Prob>chi2 =      0.0000
        
        
        . predict B, e
        (433 missing values generated)
        
        . su A B
        
            Variable |        Obs        Mean    Std. Dev.       Min        Max
        -------------+---------------------------------------------------------
                   A |     28,101    4.10e-11    .2770332  -1.908755   3.107209
                   B |     28,101    4.10e-11    .2770332  -1.908755   3.107209
        
        .
        Hence, I will simply keep your standard errors clustered.
        -testparm- indicates that -i.time- shoud be included among your predictors.
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment


        • #5
          Thanks a lot Carlo. You solved the exact problem of mine.
          Best
          Nuzaba

          Comment


          • #6
            Hi
            I have a similar problem, panel data 9 states, 20 years.
            I have heteroscedasticity, cross sectional dependence, serial correlation and I need to include time effects as well. Which standard errors should I use. If I use xtscc I would have to drop the time effects. If I used clustered I would have not correct for cross sectional dependence.
            I notice in this paper: https://www.degruyter.com/downloadpd...-2015-0167.pdf they correct for everything above:
            "We employ a method to estimate standard errors and hypothesis tests robust to heteroskedasticity, serial correlation, and spatial correlation developed by Vogelsang (2012) that extends the Driscoll and Kraay (1998) approach with state fixed effects to a setting with state and time effects"
            Is this possible to do in stata?

            Regards Rob

            Comment


            • #7
              @ Carlo Lazzaro: As an economist I find the article: Robust Standard Errors for Panel Regressions with Cross-Sectional Dependence
              from Daniel Hoechle of the University of Basel interesting,
              as he explains that stocks have cross-sectional dependance in most of the times for which we should correct. Using robust st. errors like Newey-West do not correct for this correlation so
              "Stata program, xtscc, which estimates pooled OLS/WLS and fixed effects (within) regression models with Driscoll and Kraay (Review of Economics and Statistics 80: 549-560) standard errors"
              is better to be used.

              His example contains : "a panel of 219 European mid- and large-cap stocks, month-end data from Thomson Financial Datastream and the sample period aranges from December 2000 to December 2005 (61 months)."

              In comparison is N here high and T small, this contradicts your statement application about:

              "-xtscc- is for small N, large T panel datasets."

              I discover a lot of problems to get Newey West st. errors for the xtfmb for example, therefore i came across the xtscc robust st.errors.

              But with a N = big and T = small, you would not advise this?

              Your sincerely

              Thomas

              Comment


              • #8
                Thomas:
                as you noted, I've to correct myseld, in that -xtscc- seems to work for both small N, large T, large N, small T (-help xtscc-) and large N, large T (as it seems from the example you quoted) panel datasets.
                Hence, I would give it a try with your data.
                Kind regards,
                Carlo
                (Stata 18.0 SE)

                Comment


                • #9
                  @ Robert Carnegy: Tim Vogelsang provides the Stata code for his 2012 Journal of Econometrics paper on his website: https://msu.edu/~tjv/working.html (fixedbstata.zip).

                  About the original question of using xtscc with time fixed effects: iIn principle, this should be doable with the xtsccfixedb ado from Tim Vogelsang. However, his function does not support factor variables (error message: "factor-variable and time-series operators not allowed"). One way to circumvent this issue is to define time dummies that equal one for each time period and zero otherwise. Below is a reproducible example that should illustrate this method. Please correct me, if I'm mistaken.

                  Best,
                  Christoph

                  Code:
                  . use http://www.stata-press.com/data/r9/grunfeld.dta, clear
                  
                  . summarize
                  
                      Variable |        Obs        Mean    Std. Dev.       Min        Max
                  -------------+---------------------------------------------------------
                       company |        200         5.5    2.879489          1         10
                          year |        200      1944.5    5.780751       1935       1954
                        invest |        200    145.9583    216.8753        .93     1486.7
                        mvalue |        200    1081.681     1314.47      58.12     6241.7
                        kstock |        200    276.0172    301.1039         .8     2226.3
                  -------------+---------------------------------------------------------
                          time |        200        10.5    5.780751          1         20
                  
                  . xtscc invest mvalue kstock, fe lag(4)
                  
                  Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                  Method: Fixed-effects regression                 Number of groups  =        10
                  Group variable (i): company                      F(  2,    19)     =     79.65
                  maximum lag: 4                                   Prob > F          =    0.0000
                                                                   within R-squared  =    0.7668
                  
                  ------------------------------------------------------------------------------
                               |             Drisc/Kraay
                        invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                        mvalue |   .1101238   .0201931     5.45   0.000     .0678592    .1523884
                        kstock |   .3100653    .034045     9.11   0.000     .2388083    .3813224
                         _cons |  -58.74393   24.45362    -2.40   0.027     -109.926   -7.561907
                  ------------------------------------------------------------------------------
                  
                  
                  . xtsccfixedb invest mvalue kstock, fe lag(4)
                  
                  Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                  Method: Fixed-effects regression                 Number of groups  =        10
                  Group variable (i): company                      Chi2(  2)         =    169.39
                  maximum lag: 4                                   Prob > Chi2       =    0.0000
                  Fixed-b ratio: 0.25                              within R-squared  =    0.7668
                  cvtfixedb is 2.713 for tail 0.975
                  
                  P-values and confidence intervals are computed using fixed-b distribution
                  ------------------------------------------------------------------------------
                        invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                        mvalue |   .1101238   .0195826     5.62   0.001     .0569931    .1632545
                        kstock |   .3100653   .0330158     9.39   0.000     .2204882    .3996425
                         _cons |  -58.74393   23.71437    -2.48   0.069    -123.0848    5.596943
                  ------------------------------------------------------------------------------
                  
                  .
                  . // create time dummies
                  . forval t = 1/20 {
                    2.         gen time`t' = 0
                    3.         replace time`t' = 1 if time == `t'
                    4. }
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  (10 real changes made)
                  
                  .
                  . // note time1 is omitted anyway
                  . xtsccfixedb invest mvalue kstock time2-time20, fe lag(4)
                  
                  Regression with Driscoll-Kraay standard errors   Number of obs     =       200
                  Method: Fixed-effects regression                 Number of groups  =        10
                  Group variable (i): company                      Chi2( 21)         =     12.77
                  maximum lag: 4                                   Prob > Chi2       =    0.0017
                  Fixed-b ratio: 0.25                              within R-squared  =    0.7985
                  cvtfixedb is 2.713 for tail 0.975
                  
                  P-values and confidence intervals are computed using fixed-b distribution
                  ------------------------------------------------------------------------------
                        invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                        mvalue |   .1177158   .0220019     5.35   0.001      .058021    .1774106
                        kstock |   .3579163   .0529491     6.76   0.000     .2142568    .5015757
                         time2 |  -19.19741   8.045977    -2.39   0.078    -41.02743    2.632614
                         time3 |  -40.69001   13.78463    -2.95   0.036    -78.08992   -3.290092
                         time4 |   -39.2264   4.424035    -8.87   0.000    -51.22952   -27.22329
                         time5 |  -69.47029   8.399176    -8.27   0.000    -92.25859   -46.68198
                         time6 |  -44.23507   9.444775    -4.68   0.002    -69.86026   -18.60989
                         time7 |  -18.80446   8.966701    -2.10   0.114    -43.13255     5.52363
                         time8 |  -21.13979    7.47027    -2.83   0.043    -41.40783   -.8717575
                         time9 |  -42.97762   8.822276    -4.87   0.002    -66.91386   -19.04138
                        time10 |  -43.09876   9.131187    -4.72   0.002    -67.87313    -18.3244
                        time11 |  -55.68303   10.88328    -5.12   0.001     -85.2111   -26.15496
                        time12 |  -31.16928   12.24854    -2.54   0.063    -64.40152    2.062955
                        time13 |  -39.39223    12.6387    -3.12   0.028    -73.68304    -5.10143
                        time14 |  -43.71651    14.6574    -2.98   0.034    -83.48437   -3.948652
                        time15 |   -73.4951   16.46399    -4.46   0.004    -118.1645   -28.82567
                        time16 |  -75.89611   17.53525    -4.33   0.004     -123.472   -28.32017
                        time17 |   -62.4809   19.56282    -3.19   0.025     -115.558   -9.403843
                        time18 |  -64.63233   22.51298    -2.87   0.040    -125.7136   -3.551007
                        time19 |  -67.71796   27.57538    -2.46   0.071    -142.5344     7.09844
                        time20 |  -93.52622   30.85483    -3.03   0.032    -177.2403   -9.812154
                         _cons |  -32.83631   15.04733    -2.18   0.102    -73.66212    7.989497
                  ------------------------------------------------------------------------------

                  Comment


                  • #10
                    Hi Statalisters, I also have a question regarding the xtssc command but with country fixed effects. I have panel data for 30 countries and 65 quarters and 11 independent variables. I want to lag each independent variable by one quarter to avoid endogeneity. Am I correct to assume that the following xtscc code would work?

                    xtscc depvariable L.indepv1 L.indepv2 ..... L. , fe lag(1)

                    I am unsure about the lag specification at the end though. Should it be lag(4) instead as I am using quarterly data or lag(1) as I am lagging the independent variables by one quarter?

                    Comment

                    Working...
                    X