Announcement

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

  • Problem Using reghdfe with only an Intercept and Double Clustering


    Hello Statalist members,

    for my research I want to test if the mean of my dependent variable is different from zero, while additionally clustering the standard errors. I want to use reghdfe and double cluster my standard errors. Originally, I use panel data, but I have created an example that leads to the same error message as with my own data set, so that you can better understand my issue. Here’s my approach:

    Code:
    sysuse auto, clear
    gen wc = wordcount(make)
    su wc, meanonly
    local max = r(max)
    gen wanted = substr(make, 1, 1)
     
    reghdfe price, vce(cluster foreign wanted)
    However, there seems to be a problem with reghdfe when only using the intercept while clustering on multiple dimensions. I get the following output:
    Code:
    . reghdfe price, vce(cluster foreign wanted)
    (MWFE estimator converged in 1 iterations)
    reghdfe_fix_psd():  3301  subscript invalid
    reghdfe_vce_cluster():     -  function returned error
    reghdfe_solve_ols():     -  function returned error
    <istmt>:     -  function returned error
    r(3301);
    I have already tried to generate a constant and add it to the regression, but this didn’t resolve my issue. Any help would be highly appreciated! Thank you!



  • #2
    reghdfe is from https://github.com/sergiocorreia/reghdfe (FAQ Advice #12). Try an older version of the command or regress (Stata 18+).

    Code:
    webuse grunfeld, clear
    reghdfe invest, noabsorb vce(cluster company year) version(5)
    regress invest, vce(cluster company year)
    Res.:

    Code:
    . reghdfe invest, noabsorb vce(cluster company year) version(5)
    (running historical version of reghdfe: 5)
    (MWFE estimator converged in 1 iterations)
    
    HDFE Linear regression                            Number of obs   =        200
    Absorbing 1 HDFE group                            F(   0,      9) =          .
    Statistics robust to heteroskedasticity           Prob > F        =          .
                                                      R-squared       =     0.0000
                                                      Adj R-squared   =     0.0000
    Number of clusters (company) =         10         Within R-sq.    =     0.0000
    Number of clusters (year)    =         20         Root MSE        =   216.8753
    
                              (Std. err. adjusted for 10 clusters in company year)
    ------------------------------------------------------------------------------
                 |               Robust
          invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _cons |   145.9583   62.19122     2.35   0.044     5.271936    286.6446
    ------------------------------------------------------------------------------
    
    .
    . regress invest, vce(cluster company year)
    
    Linear regression                                     Number of obs =      200
    Clusters per comb.:                                   Cluster comb. =        3
      min =  10                                           F(0, 9)       =        .
      avg =  77                                           Prob > F      =        .
      max = 200                                           R-squared     =   0.0000
                                                          Adj R-squared =   0.0000
                                                          Root MSE      = 216.8753
    
                                      (Std. err. adjusted for multiway clustering)
    ------------------------------------------------------------------------------
                 |               Robust
          invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _cons |   145.9583   62.31677     2.34   0.044     4.987914    286.9286
    ------------------------------------------------------------------------------
    Cluster combinations formed by company and year.
    Last edited by Andrew Musau; 02 Sep 2024, 03:55.

    Comment


    • #3
      Thank you very much for your fast reply! This helps.

      Comment

      Working...
      X