Announcement

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

  • e(sample) not working for ivreg2hdfe

    For ivreghdfe, I could find summary stats of the regressor by running something like this
    ivreghdfe Y (X=Z) C, absorb(FE1 FE2) cluster(Cluster)
    summarize X if e(sample), detail
    But for ivreg2hdfe, it seems it doesn't work.
    ivreg2hdfe, depvar(Y) en(X) ex(C) iv(Z) id1(FE1) id2(FE2) cluster(Cluster)
    summarize X if e(sample), detail
    It seems e(sample) simply didn't work for ivreg2hdfe.

    What can I do to obtain summary stats of X for the observations that were used in the regression that used ivreg2hdfe?


    Random data to run this can be created by running the following.
    clear

    * Set a random seed for reproducibility
    set seed 12345

    * Generate random variables
    set obs 100 // Number of observations
    generate Y = rnormal(0,1)
    generate X = rnormal(0,1) // Independent variable
    generate Z = rnormal(0,1) // Instrumental variable
    generate C = rnormal(0,1) // Control variable

    * Create categorical fixed effects variables
    gen FE1 = floor((uniform() * 5) + 1) // Categorical fixed effect with 5 categories
    gen FE2 = floor((uniform() * 3) + 1) // Categorical fixed effect with 3 categories

    * Create a cluster variable
    gen Cluster = floor((uniform() * 5) + 1)

    * Regression
    ivreghdfe Y (X=Z) C, absorb(FE1 FE2) cluster(Cluster)
    summarize X if e(sample), detail

    ivreg2hdfe, depvar(Y) en(X) ex(C) iv(Z) id1(FE1) id2(FE2) cluster(Cluster)
    summarize X if e(sample), detail

  • #2
    I do not use ivreg2hdfe from SSC as you are asked to explain in FAQ Advice #12, but what is the preference here over ivreghdfe also from SSC?

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      I do not use ivreg2hdfe from SSC as you are asked to explain in FAQ Advice #12, but what is the preference here over ivreghdfe also from SSC?

      Yes they are both from SSC. They seem to give different coef and se...

      Comment


      • #4
        ivreghdfe is essentially ivreg2 (from SSC) with reghdfe handling the absorbed fixed effects. The estimator has been sufficiently tested and works well. I do not know much about ivreg2hdfe, but you can use the official xtivreg including one set of fixed effects as dummies to compare the results.

        Comment

        Working...
        X