Announcement

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

  • Explanation of tabstat command

    Hello,

    I am a little confused when running the "tabstat" command. For example, I entered the command "tabstat male marry single, by(smoke) statistics(mean sd n) longstub format (%9.1g)" on a dataset of mine. Take male for example, the dummy variable is smoke (column is either 0 or 1), and the 0 column has mean=.33, sd=.47, N=40200; and the 1 column has mean=.93, sd=.25, N=9552. The total column below them has mean=.45, sd=.5, and N=49752.

    What do the statistical (mean, sd, N) variables actually mean within the 1 and 0 columns? And within the total?

  • #2
    33/100 non-smokers are male and 93/100 smokers are male.

    So, the number of males is an integer close to

    Code:
    . di 40200 * .33 + 9552 * .93
    22149.36
    and the overall proportion of males is something like

    Code:
    . di (40200 * .33 + 9552 * .93) /(40200 + 9552)
    .44519537
    The proportion of smokers is

    Code:
    . di 9552/ (40200 + 9552)
    .19199228

    So, which country?

    Flipping the problem round, so that smoke is the outcome may be closer to what you want to know.

    Comment


    • #3
      You might want to show a sample of your data using -dataex-, and phrase your questions with respect to the results on the data you have shown.

      I am not on very clear what you are asking. Here:

      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      . tabstat price, by(foreign) statistics(mean sd n) longstub format (%9.1g)
      
      foreign      variable |      mean        sd         N
      ----------------------+------------------------------
      Domestic        price |      6072      3097        52
      Foreign         price |      6385      2622        22
      ----------------------+------------------------------
      Total           price |      6165      2949        74
      -----------------------------------------------------
      
      . summ price
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
             price |         74    6165.257    2949.496       3291      15906
      So you get the statistics you have requested by the groups defined by foreign, and then on the bottom you get the statistics you have requested for the whole dataset.

      Comment


      • #4
        Here is a screenshot of my dataset
        Click image for larger version

Name:	Screen Shot 2021-05-07 at 10.34.38 PM.png
Views:	1
Size:	342.2 KB
ID:	1609034

        Comment

        Working...
        X