Announcement

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

  • esttab: report different standard errors (robust and non robust) into a single column

    Hello,
    I am estimating many regressions using different assumptions for standard errors.
    An example of what I am doing is the following:
    Code:
    sysuse auto, clear
    generate gpmw = ((1/mpg)/weight)*100*1000
    eststo clear
    eststo: reg gpmw foreign length
    eststo: reg gpmw foreign length, vce(robust)
    To export this into a latex table I do the following:

    Code:
    esttab, se
    esttab using example.tex, order(foreign length) ///
    label se star(* 0.10 ** 0.05 *** 0.01)
    Using this approach I have two columns with identical point estimates but different standard errors. This is a problem as I have tens of model to estimate and I would like to convey the information in a more concise way. I would like to create a latex output that joins these models with identical point estimates into a single column, reporting robust standard errors below the normal standard errors. Is there a convenient way to do this?

    I thank you very much in advance for helping me with this coding issue


    Best regards










  • #2
    To my knowledge, the only way is to use cells(). Also, you have to be very careful of the order in which you do things, and don't call eststo twice. Here's an example.

    Code:
    sysuse auto, clear
    generate gpmw = ((1/mpg)/weight)*100*1000
    eststo clear
    
    reg gpmw foreign length, vce(robust)
    
    mat robust_mat=r(table)[2..2,1..3]
    
    eststo: reg gpmw foreign length
    
    estadd mat robust_se=robust_mat
    
    esttab using example.tex, order(foreign length) ///
    label ///
    cells(b(fmt(3)) se(fmt(3) par) robust_se(fmt(3) par(" \right[ " " \left] "))) ///
     star(* 0.10 ** 0.05 *** 0.01) replace
    I suggest you also include collabels(none) so that the ugly column label isn't displayed.

    Comment


    • #3
      This is helpful. Is there a way to add row names to indicate which SE is robust and which is non-robust? The cells option doesn't seem to allow cell labels.

      Comment


      • #4
        The parentheses and brackets distinguish these. So you want to add a note "Conventional standard errors in parentheses [Robust standard errors in brackets]."
        Last edited by Andrew Musau; 06 Mar 2023, 18:08.

        Comment


        • #5
          Thank you Andrew Musau. Is there any way to put that as a row name? below the coefficient name using esttab or estout?

          Comment


          • #6
            You can add it to the bottom of the table like this.

            Code:
            sysuse auto, clear
            generate gpmw = ((1/mpg)/weight)*100*1000
            eststo clear
            
            reg gpmw foreign length, vce(robust)
            
            mat robust_mat=r(table)[2..2,1..3]
            
            eststo: reg gpmw foreign length
            
            estadd mat robust_se=robust_mat
            
            esttab, order(foreign length) ///
            label ///
            cells(b(fmt(3)) se(fmt(3) par) robust_se(fmt(3) par(" \right[ " " \left] "))) ///
             star(* 0.10 ** 0.05 *** 0.01) replace addnote("Conventional standard errors in parentheses" "[Robust standard errors in brackets]".)
            Res.:

            Code:
            > cells(b(fmt(3)) se(fmt(3) par) robust_se(fmt(3) par(" \right[ " " \left] "))) ///
            >  star(* 0.10 ** 0.05 *** 0.01) replace addnote("Conventional standard errors in parentheses" "[Robust standard errors in brackets]".)
            
            ---------------------------------
                                          (1)
                                         gpmw
                                 b/se/robus~e
            ---------------------------------
            Car type                    0.233
                                      (0.067)
                                  \right[ 0.075 \left] 
            Length (in.)               -0.000
                                      (0.001)
                                  \right[ 0.001 \left] 
            Constant                    1.704
                                      (0.274)
                                  \right[ 0.271 \left] 
            ---------------------------------
            Observations                   74
            ---------------------------------
            Conventional standard errors in parentheses
            [Robust standard errors in brackets]

            Comment


            • #7
              I don't know of a way. I would advocate for Andrew Musau's solution, because I think putting "Car type" "Conventional SE" "Robust SE" Length, and then repeating "Conventional SE" "Robust SE" is going to lead to a less visually appealing table.
              Originally posted by Denat Ephrem Negatu View Post
              This is helpful. Is there a way to add row names to indicate which SE is robust and which is non-robust? The cells option doesn't seem to allow cell labels.

              Comment


              • #8
                Thank you everyone for your wonderful code!

                I am quite close to extending this for multiple regression columns and multiple coefficients but seem to not be 100 percent there.

                Code:
                eststo clear 
                
                reg match_quality algorithm employer i.job_num,  vce(bootstrap, reps(200))
                mat bootstrap_mat=r(table)[2..2,1..2]
                
                eststo matchq: reg match_quality algorithm employer i.job_num, cluster(job_num) 
                mat bootstrap_se=bootstrap_mat
                
                estadd mat bootstrap_se=bootstrap_mat
                
                reg interest algorithm employer i.job_num,  vce(bootstrap, reps(200))
                mat bootstrap_mat=r(table)[2..2,1..2]
                
                
                eststo interest: reg interest algorithm employer i.job_num,  cluster(job_num)
                
                matrix bootstrap_se=(bootstrap_se \ bootstrap_mat)
                
                matrix list bootstrap_se 
                
                estadd mat bootstrap_se
                
                
                esttab matchq interest, order(algorithm employer) keep(algorithm employer) ///
                cells(b(fmt(3)) se(fmt(3) par) bootstrap_se(fmt(3) par(" \right[ " " \left] "))) ///
                 star(* 0.10 ** 0.05 *** 0.01) replace addnote("Cluster-robust standard errors in parentheses" "[Bootstrapped standard errors in brackets]") tex
                What this code does is runs four regressions, with two sets of standard errors for each. I have successfully generated the matrix for the various standard errors but in the output, it is drawing the same ones each time. Does anyone have any suggestions? See output below.

                Code:
                {
                \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
                \begin{tabular}{l*{2}{c}}
                \hline\hline
                            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
                            &\multicolumn{1}{c}{match\_quality}&\multicolumn{1}{c}{interest}\\
                            &b/se/bootstrap\_se&b/se/bootstrap\_se\\
                \hline
                algorithm   &      -0.206&      -0.598\\
                            &     (0.153)&     (0.213)\\
                            & \right[ 0.316 \left] & \right[ 0.316 \left] \\
                employer    &       0.220&       0.200\\
                            &     (0.217)&     (0.245)\\
                            & \right[ 0.305 \left] & \right[ 0.305 \left] \\
                \hline
                \(N\)       &          78&          79\\
                \hline\hline
                \multicolumn{3}{l}{\footnotesize Cluster-robust standard errors in parentheses}\\
                \multicolumn{3}{l}{\footnotesize [Bootstrapped standard errors in brackets]}\\
                \end{tabular}
                }

                Comment


                • #9
                  Sarah Bana don't you need an =bootstrap_se in the second estadd mat statement?

                  I can't be sure because I don't have your dataset, so I don't know what the values should be. It might be better if you showed us an example using auto, or another system dataset.

                  Comment


                  • #10
                    In addition to the useful answers above, note that estout / esttab author Ben Jann himself has posted about this on Stackoverflow:

                    https://stackoverflow.com/questions/...tandard-errors

                    Ben's post includes a way to have separate significance stars for each set of standard errors.

                    Comment


                    • #11
                      You are quite right, Alecia, I should have used a system dataset for replicability. I will certainly do so in the future.

                      And thank you, Bert, for telling me about Ben's answer! I would have never known. It seems like it is his one answer there! How serendipitous.

                      Comment


                      • #12
                        Originally posted by Sarah Bana View Post
                        You are quite right, Alecia, I should have used a system dataset for replicability. I will certainly do so in the future.

                        And thank you, Bert, for telling me about Ben's answer! I would have never known. It seems like it is his one answer there! How serendipitous.
                        No worries!

                        Comment

                        Working...
                        X