Announcement

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

  • adding coefficient generated by lincom in esttab output

    I want to add the coefficients generated by lincom in esttab output along with sig * and se, by running this code I am able to add it as scalar:

    ppmlhdfe trade ///
    fta_other fta_ind ///
    fta_other_lead_2-fta_other_lead_4 ///
    fta_other_lag_2-fta_other_lag_10, ///
    absorb(exp#year imp#year exp#imp) ///
    cluster(exp#imp)

    * Sum of the fta_other coefficients (lags and leads)
    lincom ///
    _b[fta_other] + ///
    _b[fta_other_lead_2] + _b[fta_other_lead_4] + ///
    _b[fta_other_lag_2] + _b[fta_other_lag_4] + ///
    _b[fta_other_lag_6] + _b[fta_other_lag_8] + _b[fta_other_lag_10]

    * Store estimate, standard error, and p-value for fta_other sum
    scalar sum_fta_other = r(estimate)
    scalar se_fta_other = r(se)
    scalar p_fta_other = r(p)

    * Add sum_fta_other as a new coefficient with se and p-value
    estadd scalar sum_fta_other = sum_fta_other
    estadd scalar se_fta_other = se_fta_other
    estadd scalar p_fta_other = p_fta_other

    * Store the regression estimates for the sector
    estimates store model1


    * Generate the final table with esttab, including the pooled and sector results
    esttab model1 using "Results11.xls", scalars(sum_fta_other se_fta_other p_fta_other) se ar2 pr2 aic bic mtitles star(* 0.10 ** 0.05 *** 0.01) replace

    can anyone suggest a more ingenious way of doing this.
    Last edited by Tariq Masood; 18 Sep 2024, 12:10.

  • #2
    Code:
    sysuse auto, clear
    estimates clear
    eststo e1: reg price mpg weight foreign
    lincom mpg + weight
    estadd local est = r(estimate)
    estadd local se = r(se)
    esttab e1 , se append star(* 0.10 ** 0.05 *** 0.01) stats(r2 F N est se)

    Comment


    • #3
      thanks, it looks much better. But still, it does not provide a p-value or * for significance for lincom variable.

      Comment


      • #4
        Code:
        sysuse auto, clear
        estimates clear
        eststo e1: reg price mpg weight foreign
        lincom mpg - foreign
        local e = r(estimate)
        local s : di %5.2f r(se)
        estadd local s2 = `s'
        local p = r(p)
        estadd local pr "`= cond(`p'<0.01,"`:di %6.1f `=`e'''***", cond(`p'<0.05,"`:di %6.1f `=`e'''**", cond(`p'<0.1,"`:di %6.1f `=`e'''*",  "`:di %6.1f `=`e'''")))'"
        esttab e1 , se append star(* 0.10 ** 0.05 *** 0.01) stats(r2 F N pr s2)

        Comment


        • #5
          thanks, now it is perfect.

          Comment

          Working...
          X