Announcement

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

  • Variance display

    I want to display variance in the summary statistic in Stata.

    I am currently using sex as the BY group and then placement on political scale as the summary group.

    I get mean, deviation and error but no variance. How come?

    I have tried to use the help function to no avail.

  • #2
    If you post an example dataset, that will be helpful. In the sort form of summary statistics, the variance is not shown. However, you can use the detail option with sum command. You have shown that you have a grouping variable, in that case, tabstat can be more useful. Let me show one example using the auto dataset.

    Code:
    sysuse auto
    tabstat price mpg rep78, stat(N mean sd var semean)
    
       stats |     price       mpg     rep78
    ---------+------------------------------
           N |        74        74        69
        mean |  6165.257   21.2973  3.405797
          sd |  2949.496  5.785503  .9899323
    variance |   8699526  33.47205  .9799659
    se(mean) |  342.8719  .6725511  .1191738
    ----------------------------------------
    With a grouping variable - using foreign as a grouping variable.
    Code:
    tabstat price mpg rep78, stat(N mean sd var semean) by(foreign )
    
     foreign |     price       mpg     rep78
    ---------+------------------------------
    Domestic |        52        52        48
             |  6072.423  19.82692  3.020833
             |  3097.104  4.743297   .837666
             |   9592055  22.49887  .7016844
             |  429.4911   .657777  .1209067
    ---------+------------------------------
     Foreign |        22        22        21
             |  6384.682  24.77273  4.285714
             |  2621.915  6.611187  .7171372
             |   6874439  43.70779  .5142857
             |  558.9942   1.40951  .1564922
    ---------+------------------------------
       Total |        74        74        69
             |  6165.257   21.2973  3.405797
             |  2949.496  5.785503  .9899323
             |   8699526  33.47205  .9799659
             |  342.8719  .6725511  .1191738
    ----------------------------------------
    Last edited by Attaullah Shah; 21 Apr 2018, 07:02.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Originally posted by Attaullah Shah View Post
      If you post an example dataset, that will be helpful. In the sort form of summary statistics, the variance is not shown. However, you can use the detail option with sum command. You have shown that you have a grouping variable, in that case, tabstat can be more useful. Let me show one example using the auto dataset.

      Code:
      sysuse auto
      tabstat price mpg rep78, stat(N mean sd var semean)
      
      stats | price mpg rep78
      ---------+------------------------------
      N | 74 74 69
      mean | 6165.257 21.2973 3.405797
      sd | 2949.496 5.785503 .9899323
      variance | 8699526 33.47205 .9799659
      se(mean) | 342.8719 .6725511 .1191738
      ----------------------------------------
      With a grouping variable - using foreign as a grouping variable.
      Code:
      tabstat price mpg rep78, stat(N mean sd var semean) by(foreign )
      
      foreign | price mpg rep78
      ---------+------------------------------
      Domestic | 52 52 48
      | 6072.423 19.82692 3.020833
      | 3097.104 4.743297 .837666
      | 9592055 22.49887 .7016844
      | 429.4911 .657777 .1209067
      ---------+------------------------------
      Foreign | 22 22 21
      | 6384.682 24.77273 4.285714
      | 2621.915 6.611187 .7171372
      | 6874439 43.70779 .5142857
      | 558.9942 1.40951 .1564922
      ---------+------------------------------
      Total | 74 74 69
      | 6165.257 21.2973 3.405797
      | 2949.496 5.785503 .9899323
      | 8699526 33.47205 .9799659
      | 342.8719 .6725511 .1191738
      ----------------------------------------
      Thank you! Worked like a charm.

      Comment

      Working...
      X