Announcement

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

  • Create a table of grouped first stage IV regression outputs

    Dear all,

    I'm currently struggling with an output I'm trying to create from an IV regression. I try to make up a table from the first stage of my IV regression. Furthermore, I also get the output I'm searching for. BUT: I used bysort in combination with eststo so get my output for several groups, and I'm not able to find the right code to create a table with esttab out of the grouped values. Please find my modified code attached. Thank you!




    bysort groupe_name: eststo m1: ivreghdfe variable_1 controls (IV_variable= IV_regressors), first savefirst savefprefix(s1) absorb(cluster_variables) tol(1e-6)
    estadd scalar cdf1 = `e(cdf)': s1variable_1
    estadd scalar sstat1 = `e(sstat)': s1variable_1
    qui reg `e(instd)' `e(insts)' if e(sample)
    local r2a= e(r2_a)
    est restore m1
    estadd scalar r2a = `r2a': s1variable_1


    esttab s1variable_1 using title.tex, replace ///
    stats(cdf1 sstat1 r2a , labels("CD Wald F" "SW S stat." "Adj. R2" )) ///
    indicate("Controls= controls" `r(indicate_fe)') ///
    compress star(+ 0.10 * 0.05 ** 0.01 *** 0.001) scalars(N) b(4) ///
    label title(with cooking fuel) ///
    nonumbers mtitles("variable_1" ) nodepvar nonumber
    Last edited by Clara Heidelberg; 25 Oct 2022, 07:03.

  • #2
    estout is from SSC (FAQ Advice #12). Use levelsof and loop instead of the -bysort- prefix as getting R2 statistics from the first stages cannot be achieved using this method. I cannot be more detailed without a reproducible example, see the referenced FAQ for advice on how to create one in case you need specific code suggestions.

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X