Announcement

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

  • missing estadd scalars in esttab

    Dear Stata Users,
    I’m having some troubles in adding some scalars to a LaTex table made with esttab.
    I run, for example, a similar regression and add some acronyms for fixed effects etc as following:
    Code:
    eststo: xi:xtreg y treatment_dummy $covs i.year, fe vce(cluster id)
    estadd local year_d "Y" , replace
    estadd local fixed "Y" , replace
    estadd local controls "Y" , replace
    summ y if e(sample)
    estadd scalar ymean = r(mean), replace
    Following this, I aim to utilize the procedure outlined by de Chaisemartin & d'Haultfoeuille (2020) to compute the negative weight and store some of the resulting diagnostic statistics:
    Code:
    twowayfeweights y id year treatment_dummy, type(feTR) controls($covs)
    ereturn list
    estadd scalar sum_neg_weight = e(sum_neg_w)
    estadd scalar sigma = e(lb_se_te)
    estadd scalar sigma_2 = e(lb_se_te2)
    Finally, I use esttab to generate the final LaTex table:
    Code:
    esttab using /path/table.tex, replace  se(%3.2f) r2 keep(treatment_dummy $covs) /*
    */ label booktabs  star(* 0.10 ** 0.05 *** 0.01)  f nogaps  nonotes/*
    */ s(ymean sum_neg_weight sigma sigma_2 controls year_d fixed  r2 N, label("Mean of dep. var." "Sum of negative weights" "$\underline \sigma_{fe}$"  "$\underline{\underline \sigma}_{fe}$" "Controls" "Year Effects"  /*
    */ "Individual Effects" "\emph{R}$^2$" "Obs."))
    Can anyone explain to me why I can't find the diagnostic values that should have been added as scalars while the other scalars that were added after the regression are present? (Note that in the table I only find a random number in one of these missing parameters that seems to have come out of nowhere).

    Best regards
    Pasquale
    Last edited by Pasquale Giacobbe; 28 Feb 2024, 07:55.

  • #2
    You need to specify to what estimation results you are assigning the scalars to. Note that estout is from SSC (FAQ Advice #12). Also, the -xi- prefix is not needed with xtreg as the command supports factor variables. See

    Code:
    help fvvarlist
    Code:
    eststo m1:xtreg y treatment_dummy $covs i.year, fe vce(cluster id)
    twowayfeweights y id year treatment_dummy, type(feTR) controls($covs)
    estadd scalar sum_neg_weight = e(sum_neg_w): m1
    for example.

    Comment


    • #3
      Dear Andrew,
      Thanks for your answer. I tried your suggestion but I still get missing values in correspondence of the scalars coming from twowayfeweights. Any further thought? Could this somehow be due to the fact that I perform the estimates within a preserve/restore environment?

      Comment


      • #4
        Can you show the results you get from

        Code:
        eststo m1:xtreg y treatment_dummy $covs i.year, fe vce(cluster id)
        twowayfeweights y id year treatment_dummy, type(feTR) controls($covs)
        ereturn list
        estadd scalar sum_neg_weight = e(sum_neg_w): m1
        estimates restore m1
        ereturn list

        Comment


        • #5
          Dear Andrew,
          Here's the Stata output screenshot, incorporating your last suggestion.

          Click image for larger version

Name:	screenshot.png
Views:	1
Size:	55.4 KB
ID:	1744920

          Comment


          • #6
            If you are using preserve and restore as you are claiming, you are losing the estimates. Try:

            Code:
            twowayfeweights y id year treatment_dummy, type(feTR) controls($covs)
            local sum_neg_weight = e(sum_neg_w)
            eststo m1:xtreg y treatment_dummy $covs i.year, fe vce(cluster id)
            estadd scalar sum_neg_weight=`sum_neg_weight': m1

            Comment


            • #7
              Dear Andrew,
              Thank you very much! It now works correctly.

              Sincerely,
              Pasquale

              Comment

              Working...
              X