Announcement

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

  • estpost and esttab for summary statistics

    Hello,


    I am reporting the summary statistics of variables to latex. I wish to report the standard deviation in parentheses and under the mean values. How can I modify this code for the purpose?

    My current code below reports the mean and standard deviations side by side in adjacent columns.


    Code:
    local crops corn soybeans
    
    foreach j in corn soybeans {
    forvalues i = 1/7 {
        estpost summarize coverageLevel policiesSoldCount policiesEarningPremiumCount policiesIndemnifiedCount unitsEarningPremium unitsIndemnifiedCount netReportedQuantity endorsedCompanionAcres liabilityAmount_1989 totalPremiumAmount_1989 subsidyAmount_1989 statePrivateSubsidy_1989 additionalSubsidy_1989 EFApremiumDiscount_1989 indemnityAmount_1989 premium_per_acre_1989 premium_per_liability_1989 subsidy_per_acre_1989 subsidy_per_liability_1989 indemnity_per_acre_1989 indemnity_per_liability_1989 if period== `i' & commodityName == "`j'"
    est store p`i'_`j'
               }
    }
    
    esttab p1_soybeans p2_soybeans p3_soybeans p4_soybeans p5_soybeans p6_soybeans p7_soybeans //
    using "$path_results\soybeans_subsidies_summary_stats.tex", //
    cells("mean(fmt(2)) sd(fmt(2))") replace

  • #2
    estpost is from SSC, as you are asked to explain in FAQ Advice #12. Consider this:

    Code:
    sysuse auto, clear
    estimates clear
    estpost summarize mpg weight displacement
    esttab, main(mean) aux(sd)
    Res.:

    Code:
    . esttab, main(mean) aux(sd)
    
    ----------------------------
                          (1)   
                                
    ----------------------------
    mpg                 21.30   
                      (5.786)   
    
    weight             3019.5   
                      (777.2)   
    
    displacement        197.3   
                      (91.84)   
    ----------------------------
    N                      74   
    ----------------------------
    mean coefficients; sd in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      estpost is from SSC, as you are asked to explain in FAQ Advice #12. Consider this:

      Code:
      sysuse auto, clear
      estimates clear
      estpost summarize mpg weight displacement
      esttab, main(mean) aux(sd)
      Res.:

      Code:
      . esttab, main(mean) aux(sd)
      
      ----------------------------
      (1)
      
      ----------------------------
      mpg 21.30
      (5.786)
      
      weight 3019.5
      (777.2)
      
      displacement 197.3
      (91.84)
      ----------------------------
      N 74
      ----------------------------
      mean coefficients; sd in parentheses
      * p<0.05, ** p<0.01, *** p<0.001
      Thank you so much, Andrew. It worked perfectly. Correct, estpost is from an SSC. Thank you for the clarification.

      For the reference of those who may read this thread in the future, I changed the code as follows to have standard deviation reported in parentheses under the mean values and have results reported to Latex:

      Code:
      local crops corn soybeans
      
      foreach j in corn soybeans {
      forvalues i = 1/7 {
          estpost summarize coverageLevel policiesSoldCount policiesEarningPremiumCount policiesIndemnifiedCount unitsEarningPremium unitsIndemnifiedCount netReportedQuantity endorsedCompanionAcres liabilityAmount_1989 totalPremiumAmount_1989 subsidyAmount_1989 statePrivateSubsidy_1989 additionalSubsidy_1989 EFApremiumDiscount_1989 indemnityAmount_1989 premium_per_acre_1989 premium_per_liability_1989 subsidy_per_acre_1989 subsidy_per_liability_1989 indemnity_per_acre_1989 indemnity_per_liability_1989 if period== `i' & commodityName == "`j'"
      est store p`i'_`j'
                 }
      }
      
      esttab p1_corn p2_corn p3_corn p4_corn p5_corn p6_corn p7_corn ///
      using "$path_results\corn_subsidies_summary_stats.tex", ///
      main(mean) aux(sd) replace

      Comment

      Working...
      X