Announcement

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

  • LaTeX regression table output (extra rows)

    Hi everyone, I use eststo and esttab to generate the LaTeX regression table output. However, there are always extra rows generated. For example,
    Click image for larger version

Name:	Screen Shot 2022-04-07 at 9.03.41 PM.png
Views:	1
Size:	32.7 KB
ID:	1658534



    What I would like to see is like the one below.
    Click image for larger version

Name:	Screen Shot 2022-04-07 at 9.04.15 PM.png
Views:	1
Size:	31.0 KB
ID:	1658535




    Please find the example code below. Any ideas on how to fix this issue (by deleting the second (1) and b/se)? Thank you very much in advance.

    Code:
    sysuse auto, clear
    
    eststo  clear
    
    eststo: reg price mpg headroom weight, r
    
    #delimit ;
    esttab using "regression", nomtitles booktabs replace
           cells((b(star fmt(%9.3f))) (se(fmt(%9.3f)par)))
           order(mpg headroom weight)
           stats(N r2 r2_a, labels("Observations" "R-squared" "Adjusted R-squared") fmt(%9.0fc 3 3))
           starlevels(* 0.10 ** 0.05 *** 0.01)
           prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
           "\begin{tabular}{l*{2}{c}}"
           "\toprule"
           "\textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\"
           "\multicolumn{2}{l}{\textbf{Price}}\\")
           posthead("\midrule")
           label;
    #delimit cr

  • #2
    estout is from SSC as you are asked to explain (FAQ Advice #12). Thanks for the reproducible example:

    Code:
    eststo  clear
    
    eststo: reg price mpg headroom weight, r
    
    #delimit ;
    esttab, nomtitles booktabs replace
           cells((b(star fmt(%9.3f))) (se(fmt(%9.3f)par)))
           order(mpg headroom weight)
           stats(N r2 r2_a, labels("Observations" "R-squared" "Adjusted R-squared") fmt(%9.0fc 3 3))
           starlevels(* 0.10 ** 0.05 *** 0.01)
           prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
           "\begin{tabular}{l*{2}{c}}"
           "\toprule"
           "\textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\"
           "\multicolumn{2}{l}{\textbf{Price}}\\")
           posthead("\midrule") nonumbers collab(none)
           label;
    #delimit cr
    Res.:

    Code:
    . #delimit ;
    delimiter now ;
    . esttab, nomtitles booktabs replace
    >        cells((b(star fmt(%9.3f))) (se(fmt(%9.3f)par)))
    >        order(mpg headroom weight)
    >        stats(N r2 r2_a, labels("Observations" "R-squared" "Adjusted R-squared") fmt(%9.0fc 3 3))
    >        starlevels(* 0.10 ** 0.05 *** 0.01)
    >        prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
    >        "\begin{tabular}{l*{2}{c}}"
    >        "\toprule"
    >        "\textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\"
    >        "\multicolumn{2}{l}{\textbf{Price}}\\")
    >        posthead("\midrule") nonumbers collab(none)
    >        label;
    
    {\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
    \begin{tabular}{l*{2}{c}}
    \toprule
    \textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\
    \multicolumn{2}{l}{\textbf{Price}}\\
    \midrule
    Mileage (mpg)       &     -56.194   \\
                        &    (97.510)   \\
    Headroom (in.)      &    -675.596** \\
                        &   (335.368)   \\
    Weight (lbs.)       &       2.062** \\
                        &     (0.821)   \\
    Constant            &    3158.306   \\
                        &  (4112.711)   \\
    \midrule
    Observations        &          74   \\
    R-squared           &       0.322   \\
    Adjusted R-squared  &       0.293   \\
    \bottomrule
    \end{tabular}
    }
    
    . #delimit cr
    delimiter now cr

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      estout is from SSC as you are asked to explain (FAQ Advice #12). Thanks for the reproducible example:

      Code:
      eststo clear
      
      eststo: reg price mpg headroom weight, r
      
      #delimit ;
      esttab, nomtitles booktabs replace
      cells((b(star fmt(%9.3f))) (se(fmt(%9.3f)par)))
      order(mpg headroom weight)
      stats(N r2 r2_a, labels("Observations" "R-squared" "Adjusted R-squared") fmt(%9.0fc 3 3))
      starlevels(* 0.10 ** 0.05 *** 0.01)
      prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
      "\begin{tabular}{l*{2}{c}}"
      "\toprule"
      "\textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\"
      "\multicolumn{2}{l}{\textbf{Price}}\\")
      posthead("\midrule") nonumbers collab(none)
      label;
      #delimit cr
      Res.:

      Code:
      . #delimit ;
      delimiter now ;
      . esttab, nomtitles booktabs replace
      > cells((b(star fmt(%9.3f))) (se(fmt(%9.3f)par)))
      > order(mpg headroom weight)
      > stats(N r2 r2_a, labels("Observations" "R-squared" "Adjusted R-squared") fmt(%9.0fc 3 3))
      > starlevels(* 0.10 ** 0.05 *** 0.01)
      > prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
      > "\begin{tabular}{l*{2}{c}}"
      > "\toprule"
      > "\textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\"
      > "\multicolumn{2}{l}{\textbf{Price}}\\")
      > posthead("\midrule") nonumbers collab(none)
      > label;
      
      {\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
      \begin{tabular}{l*{2}{c}}
      \toprule
      \textbf{Dependent Variable:} &\multicolumn{1}{c}{(1)}\\
      \multicolumn{2}{l}{\textbf{Price}}\\
      \midrule
      Mileage (mpg) & -56.194 \\
      & (97.510) \\
      Headroom (in.) & -675.596** \\
      & (335.368) \\
      Weight (lbs.) & 2.062** \\
      & (0.821) \\
      Constant & 3158.306 \\
      & (4112.711) \\
      \midrule
      Observations & 74 \\
      R-squared & 0.322 \\
      Adjusted R-squared & 0.293 \\
      \bottomrule
      \end{tabular}
      }
      
      . #delimit cr
      delimiter now cr
      Thank you so much.

      Comment

      Working...
      X