Announcement

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

  • Compare means of two groups with different variables and show their significance

    Hello Stata friends,

    I have to reproduce a table in which the means of different variables are compared. For example the mean of log(sales) for companies with women on the board (dummy variable) with log(sales) mean of companies without women on the board. So the chart would look like this:

    Variables with female without female difference
    var1 mean (var1_female) mean(var1_male) colom 1- colom 2 (with stars for statistical significance
    var2 mean(var2_female) mean(var2_male) colom 1- colom 2 (with stars for statistical significance
    var3 mean(var3_female) mean(var3_male) colom 1- colom 2 (with stars for statistical significance

    I have the means already calculated but I can't figure out how to build that table...
    Thanks in advance for any help. I tried google myself but all I could find was the pwmean function and that doesn't cut it I think.

  • #2
    Okay I figured out part of my solution myself:
    ttest log_sales var2 var3 var4..., by(female) gives me the data that I'm looking for. How do I use, I assume esstab, to make the table as it appears above?
    Last edited by Johannes Walder; 07 Feb 2015, 04:24.

    Comment


    • #3
      okay havethe following code now:

      eststo: estpost ttest var1 var2 var3 var4 var5 var6, by(female) unequal

      esttab using Tabel2.rtf, star(b) noobs cells("mu_2 mu_1 b") label replace

      Everything works fine but one thing: I need the significance stars attached to the difference in means (b). Ho do I fix that? the star command does not seem to do his job.

      Comment


      • #4
        And I figured the last step out myself as well! Sometimes I think it's good to write about the issues to clear up the mind. I hope i didn't distract anybody.

        final code that I needed:

        eststo: estpost ttest var1 var2 var3 var4 var5 var6, by(female) unequal
        esttab using Tabel2.rtf, noobs cells("mu_2 mu_1 b(star)") label replace

        Comment


        • #5
          Thanks for posting the solution and closing the thread.

          Just one addition. estto and esttab are both user-written command, likely from the SSC.

          Best
          Daniel

          Comment


          • #6
            Johannes Walder you just made my day!!

            Comment


            • #7
              eststo: estpost ttest var1 var2 var3 var4 var5 var6, by(female) unequal
              esttab using Tabel2.rtf, noobs cells("mu_2 mu_1 b(star)") label replace
              Is there any way to add no of observations in the above code

              Comment


              • #8
                Originally posted by lal mohan kumar View Post
                Is there any way to add no of observations in the above code
                The help file for esttab (authored by Ben Jann and available from Stata Journal) says "The default is to report the number of observations for each model in the table footer." Example pasted from help file below.
                Code:
                        . sysuse auto
                        (1978 Automobile Data)
                        
                        . eststo: quietly regress price weight mpg
                        (est1 stored)
                        
                        . eststo: quietly regress price weight mpg foreign
                        (est2 stored)
                        
                        . esttab, ar2
                        
                        --------------------------------------------
                                              (1)             (2)   
                                            price           price   
                        --------------------------------------------
                        weight              1.747**         3.465***
                                           (2.72)          (5.49)   
                        
                        mpg                -49.51           21.85   
                                          (-0.57)          (0.29)   
                        
                        foreign                            3673.1***
                                                           (5.37)   
                        
                        _cons              1946.1         -5853.7   
                                           (0.54)         (-1.73)   
                        --------------------------------------------
                        N                      74              74   
                        adj. R-sq           0.273           0.478   
                        --------------------------------------------
                        t statistics in parentheses
                        * p<0.05, ** p<0.01, *** p<0.001
                David Radwin
                Senior Researcher, California Competes
                californiacompetes.org
                Pronouns: He/Him

                Comment


                • #9
                  Dear David Radwin
                  Thanks a lot

                  Comment

                  Working...
                  X