Announcement

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

  • My Stata 16 does not show all the local variables that are supposed to appear in a table using esttab

    There is something in how Stata 16 is set in my computer that makes the following code not to work as it should:
    eststo Agreementx_gets_face: reg Agreementx_gets Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) qui estadd local Sample="Face-to-Face" eststo Agreementx_gets_ele: reg Agreementx_gets Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) qui estadd local Sample="Electronic" eststo auto_exploitation_face: reg auto_exploitation Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) qui estadd local Sample="Face-to-Face" eststo auto_exploitation_ele: reg auto_exploitation Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) qui estadd local Sample="Electronic" esttab Agreementx_gets_face Agreementx_gets_ele auto_exploitation_face auto_exploitation_ele /// using "$latex/reg_x_earnings.tex", replace /// keep (Forced) /// b(2) se(2) star(* 0.10 ** 0.05 *** .01) /// nomtitles collabels(none) /// noobs nocons booktabs nonotes /// stats(N N_clust meanc Sample, fmt(%9.0fc 0 2 0) labels("Observations" "Num. Clusters" "Dep. Var. Mean" "Sample")) eststo clear
    In the computer of my research assistant, the code works properly and I get this table:
    { \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{4}{c}} \toprule &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\ multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\ &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\ \midrule Forced & -115.01\sym{**} & 12.93 & 0.29\sym{***}& 0.01 \\ & (44.46) & (43.32) & (0.09) & (0.10) \\ \midrule Observations& 276 & 260 & 276 & 260 \\ Num. Clusters& 85 & 88 & 85 & 88 \\ Dep. Var. Mean& 1165.18 & 1172.06 & 0.42 & 0.42 \\ Sample &Face-to-Face & Electronic &Face-to-Face & Electronic \\ \bottomrule \end{tabular} }
    However, when we run the code in my computer, I only get the local variable that I define first (whichever it is). The way the code is written, I get this (the last row is missing):
    { \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{4}{c}} \toprule &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\ multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\ &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\ \midrule Forced & -115.01\sym{**} & 12.93 & 0.29\sym{***}& 0.01 \\ & (44.46) & (43.32) & (0.09) & (0.10) \\ \midrule Observations& 276 & 260 & 276 & 260 \\ Num. Clusters& 85 & 88 & 85 & 88 \\ Dep. Var. Mean& 1165.18 & 1172.06 & 0.42 & 0.42 \\ Sample & & & & \\ \bottomrule \end{tabular} }
    On the contrary, if I define first the Sample then the mean:
    eststo Agreementx_gets_face: reg Agreementx_gets Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui estadd local Sample="Face-to-Face" qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) eststo Agreementx_gets_ele: reg Agreementx_gets Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui estadd local Sample="Electronic" qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) eststo auto_exploitation_face: reg auto_exploitation Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui estadd local Sample="Face-to-Face" qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) eststo auto_exploitation_ele: reg auto_exploitation Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1), vce(cluster Participant_id) qui estadd local Sample="Electronic" qui sum Agreementx_gets if e(sample)==1 qui estadd scalar meanc r(mean) esttab Agreementx_gets_face Agreementx_gets_ele auto_exploitation_face auto_exploitation_ele /// using "$latex/reg_x_earnings.tex", replace /// keep (Forced) /// b(2) se(2) star(* 0.10 ** 0.05 *** .01) /// nomtitles collabels(none) /// noobs nocons booktabs nonotes /// stats(N N_clust meanc Sample, fmt(%9.0fc 0 2 0) labels("Observations" "Num. Clusters" "Dep. Var. Mean" "Sample")) eststo clear
    I get the opposite problem (the second to last row is missing):
    { \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{4}{c}} \toprule &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\ multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\ &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\ \midrule Forced & -115.01\sym{**} & 12.93 & 0.29\sym{***}& 0.01 \\ & (44.46) & (43.32) & (0.09) & (0.10) \\ \midrule Observations& 276 & 260 & 276 & 260 \\ Num. Clusters& 85 & 88 & 85 & 88 \\ Dep. Var. Mean& & & & \\ Sample &Face-to-Face & Electronic &Face-to-Face & Electronic \\ \bottomrule \end{tabular} }
    This extends to other similar tables, and persists no matter whether I define variables as scalars, locals, or globals. Most importantly, it does not happen on the computer of my research assistants, so I guess it has to do with Stata settings in my computer.

    I would very much appreciate your help.

  • #2
    This was cross-posted at https://stackoverflow.com/questions/...d-to-appear-in

    The version there (after my edits) is likely to be more readable than #1. Nevertheless, Francisco Olivero, please post a more readable version using CODE delimiters.

    I suggested posting here. Nevertheless you are asked on Statalist to explain cross-posting.

    As already stated on SO, I don't understand the question myself and I fail to see how we can guess what differs on two computers. I am more optimistic that experienced users of this suite may have an explanation in its terms.

    Comment


    • #3
      The tables in SO are more clear. Here are two things that you can do:

      1. Update your estout installation.

      Code:
      ssc install estout, replace
      2. Associate the added locals or scalars to specific stored estimates. Here are illustrations for two sets of estimates.

      Code:
      eststo Agreementx_gets_face: reg Agreementx_gets Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1), vce(cluster Participant_id)
      qui sum Agreementx_gets if e(sample)==1
      qui estadd scalar meanc= r(mean): Agreementx_gets_face
      qui estadd local Sample="Face-to-Face": Agreementx_gets_face
      
      eststo Agreementx_gets_ele: reg Agreementx_gets Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1), vce(cluster Participant_id)
      qui sum Agreementx_gets if e(sample)==1
      qui estadd scalar meanc = r(mean): Agreementx_gets_ele
      qui estadd local Sample="Electronic": Agreementx_gets_ele


      Comment


      • #4
        Eureka! Thanks for your answer Andrew Musau , I updated muy estout installation and now it works properly.

        Comment


        • #5
          Here it's the correction with code delimiters:

          There is something in how Stata 16 is set in my computer that makes the following code not to work as it should:
          Code:
          eststo Agreementx_gets_face: reg Agreementx_gets Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          qui estadd local Sample="Face-to-Face"
          
          eststo Agreementx_gets_ele: reg Agreementx_gets Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          qui estadd local Sample="Electronic"
          
          eststo auto_exploitation_face: reg auto_exploitation Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          qui estadd local Sample="Face-to-Face"
          
          eststo auto_exploitation_ele: reg auto_exploitation Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          qui estadd local Sample="Electronic"
          
          esttab Agreementx_gets_face Agreementx_gets_ele auto_exploitation_face auto_exploitation_ele ///
          using "$latex/reg_x_earnings.tex", replace /// keep (Forced) /// b(2) se(2) star(* 0.10 ** 0.05 *** .01) ///
          nomtitles collabels(none) /// noobs nocons booktabs nonotes
          /// stats(N N_clust meanc Sample,
          fmt(%9.0fc 0 2 0) labels("Observations" "Num. Clusters" "Dep. Var. Mean" "Sample"))
          
          eststo clear
          In the computer of my research assistant, the code works properly and I get this table:
          Code:
          { \def\sym#1{\ifmmode^{#1}\else^{#1}^{#1}\fi}
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\            
          &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}
          &\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule
          Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&     1165.18         &     1172.06         &        0.42         &        0.42         \\
          Sample      &Face-to-Face         &  Electronic         &Face-to-Face         &  Electronic         \\
          \bottomrule
          \end{tabular}
          
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                      &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule
          Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&     1165.18         &     1172.06         &        0.42         &        0.42         \\
          Sample      &Face-to-Face         &  Electronic         &Face-to-Face         &  Electronic         \\
          \bottomrule \end{tabular}
          }
          However, when we run the code in my computer, I only get the local variable that I define first (whichever it is). The way the code is written, I get this (the last row is missing):

          Code:
          { \def\sym#1{\ifmmode^{#1}\else^{#1}^{#1}\fi}
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                      &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&     1165.18         &     1172.06         &        0.42         &        0.42         \\
          Sample      &                     &                     &                     &                     \\
          \bottomrule
          \end{tabular}
          
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                      &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule
          Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&     1165.18         &     1172.06         &        0.42         &        0.42         \\
          Sample      &                     &                     &                     &                     \\
          \bottomrule \end{tabular}
          }
          On the contrary, if I define first the Sample then the mean:

          Code:
          eststo Agreementx_gets_face: reg Agreementx_gets Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui estadd local Sample="Face-to-Face"
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          
          eststo Agreementx_gets_ele: reg Agreementx_gets Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui estadd local Sample="Electronic"
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          
          eststo auto_exploitation_face: reg auto_exploitation Forced i.round_dummy if face==1 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui estadd local Sample="Face-to-Face"
          qui sum Agreementx_gets if e(sample)==1
          qui estadd scalar meanc r(mean)
          
          eststo auto_exploitation_ele: reg auto_exploitation Forced i.round_dummy if face==0 & (Forced==1 | Baseline==1),
          vce(cluster Participant_id)
          qui estadd local Sample="Electronic"
          qui sum Agreementx_gets if e(sample)==1
          qui estadd
          scalar meanc r(mean)
          
          esttab Agreementx_gets_face Agreementx_gets_ele auto_exploitation_face auto_exploitation_ele
          /// using "$latex/reg_x_earnings.tex", replace /// keep (Forced) /// b(2) se(2) star(* 0.10 ** 0.05 *** .01)
          /// nomtitles collabels(none) /// noobs nocons booktabs nonotes
          /// stats(N N_clust meanc Sample,
          fmt(%9.0fc 0 2 0) labels("Observations" "Num. Clusters" "Dep. Var. Mean" "Sample"))
          eststo clear
          I get the opposite problem (the second to last row is missing):

          Code:
          { \def\sym#1{\ifmmode^{#1}\else^{#1}^{#1}\fi}
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                      &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule
          Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&                     &                     &                     &                     \\
          Sample      &Face-to-Face         &  Electronic         &Face-to-Face         &  Electronic         \\
          \bottomrule
          \end{tabular}
          
          \begin{tabular}{l*{4}{c}} \toprule             &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\  multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
                      &\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{Decider's Profits}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}&\multicolumn{1}{c}{$\mathds{1}($ Decider's Profits$<x)$}\\
          \midrule
          Forced      &     -115.01\sym{**} &       12.93         &        0.29\sym{***}&        0.01         \\
                      &     (44.46)         &     (43.32)         &      (0.09)         &      (0.10)         \\
          \midrule
          Observations&         276         &         260         &         276         &         260         \\
          Num. Clusters&          85         &          88         &          85         &          88         \\
          Dep. Var. Mean&                     &                     &                     &                     \\
          Sample      &Face-to-Face         &  Electronic         &Face-to-Face         &  Electronic         \\
          \bottomrule
          \end{tabular}
          }
          This extends to other similar tables, and persists no matter whether I define variables as scalars, locals, or globals. Most importantly, it does not happen on the computer of my research assistants, so I guess it has to do with Stata settings in my computer.

          I would very much appreciate your help.
          Last edited by Francisco Olivero; 15 Jan 2025, 17:13.

          Comment


          • #6
            This thread is confusing. From comments on Stack Overflow (which may or may not disappear soon) it seems that

            1. Francisco Olivero and Andres Gago are co-workers.

            2. The solution in #3 from Andrew Musau solved the problem (#4).

            3. So #5 is just a repost of #1 and there is nothing else to discuss.

            Comment

            Working...
            X