Announcement

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

  • ivreghdfe vs ivreg2 when clustering standard errors

    Dear all,

    I have a panel data of political parties within countries over years. I'm using the ivreghdfe and I cluster at the country level. When I do that using the ivreghdfe command, I get the error "insufficient observations". However, the iv regression work while having the same specification but using ivreg2 (of course using dummies instead of absorb to get country and year fixed effects).

    Do I actually have insufficient observations within clusters to use the cluster option or not? How to understand which command is correct?

    thank you in advance.

    Best,

    Ernesto

  • #2
    Show us the exact commands that you ran and the resulting output. Post these within CODE delimiters.

    Comment


    • #3
      If I understand well, the code delimeters are # code and output#. These is teh command ivreg2 and its respective output:

      #
      ivreg2 trade_b C* Y* (ln_open ln_inter_open = ln_open_mt ln_inter_open_iv_mt), cluster(country_id) partial(C* Y*)
      Warning - collinearities detected
      Vars dropped: C58 Y1 Y11

      IV (2SLS) estimation
      --------------------

      Estimates efficient for homoskedasticity only
      Statistics robust to heteroskedasticity and clustering on country_id

      Number of clusters (country_id) = 58 Number of obs = 250923
      F( 2, 57) = 0.89
      Prob > F = 0.4164
      Total (centered) SS = 140442.9342 Centered R2 = -0.0118
      Total (uncentered) SS = 140442.9342 Uncentered R2 = -0.0118
      Residual SS = 142100.0121 Root MSE = .7525

      -------------------------------------------------------------------------------
      | Robust
      trade_b | Coefficient std. err. z P>|z| [95% conf. interval]
      --------------+----------------------------------------------------------------
      ln_open | -.7855193 .8081214 -0.97 0.331 -2.369408 .7983695
      ln_inter_open | 3.14164 2.825014 1.11 0.266 -2.395286 8.678565
      -------------------------------------------------------------------------------
      Underidentification test (Kleibergen-Paap rk LM statistic): 3.692
      Chi-sq(1) P-val = 0.0547
      ------------------------------------------------------------------------------
      Weak identification test (Cragg-Donald Wald F statistic): 4539.593
      (Kleibergen-Paap rk Wald F statistic): 2.561
      Stock-Yogo weak ID test critical values: 10% maximal IV size 7.03
      15% maximal IV size 4.58
      20% maximal IV size 3.95
      25% maximal IV size 3.63
      Source: Stock-Yogo (2005). Reproduced by permission.
      NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
      ------------------------------------------------------------------------------
      Hansen J statistic (overidentification test of all instruments): 0.000
      (equation exactly identified)
      ------------------------------------------------------------------------------
      Instrumented: ln_open ln_inter_open
      Excluded instruments: ln_open_mt ln_inter_open_iv_mt
      Partialled-out: C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16
      C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30
      C31 C32 C33 C34 C35 C36 C37 C38 C39 C40 C41 C42 C43 C44
      C45 C46 C47 C48 C49 C50 C51 C52 C53 C54 C55 C56 C57 Y2 Y3
      Y4 Y5 Y6 Y7 Y8 Y9 Y10 _cons
      nb: total SS, model F and R2s are after partialling-out;
      any small-sample adjustments include partialled-out
      variables in regressor count K
      Dropped collinear: C58 Y1 Y11
      ------------------------------------------------------------------------------

      #

      where C* and Y* come from the following two commands { quiet tab year, gen(Y) } and { quiet tab country_id, gen(C) }

      This is the command with ivreghdfe and its output:

      #
      . ivreghdfe trade_b (ln_open ln_inter_open = ln_open_mt ln_inter_open_iv_mt), a(country_id year id) cluster(country_id)
      insufficient observations
      r(2001);
      #

      thanks,

      Ernesto

      Comment


      • #4
        Code delimiters are

        \(\left[\text{CODE}\right]\)

        \(\left[\text{\CODE}\right]\)

        Click on # on the Advanced Editor.

        When I do that using the ivreghdfe command, I get the error "insufficient observations".
        I think this should be related to the use of string identifiers. See my comment in #6 of https://www.statalist.org/forums/for...ve-centered-r2.
        Last edited by Andrew Musau; 27 Sep 2023, 06:26.

        Comment


        • #5
          thanks andrew it worked, the clustering variable was actually a string. After encoding it to a numeric it worked.

          best,

          Ernesto

          Comment

          Working...
          X