Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Diffrence between sum and tabsum


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Diffrence between sum and tabsum
Date   Tue, 15 Sep 2009 11:46:15 -0500

Ulrich Kohler <kohler@wzb.eu> asks, 

> Does anybody know why -tabulate, summarize- displays a nonzero
> standard-deviation for a variable that is a constant?
>
> . tab seopsu if seopsu==948, sum(firstweight)
>
>      Cps Pr |
>    Sampl Un |       Summary of firstweight
>     5:71-73 |        Mean   Std. Dev.       Freq.
> ------------+------------------------------------
>         948 |   13949.146   .00024815           3
> ------------+------------------------------------
>       Total |   13949.146   .00024815           3
>
> . sum firstweight if seopsu==948
>
>     Variable |       Obs        Mean    Std. Dev.       Min        Max
> -------------+--------------------------------------------------------
>  firstweight |         3    13949.15           0   13949.15   13949.15

-tabulate, summarize- uses the less accurate one-pass algorithm
to compute the standard deviation while -summarize- uses the
two-pass algorithm.

We will change the algorithm in -tabulate, summarize- to use the
two-pass algorithm in a future executable update.

As a temporary workaround, 

	. table dummy, contents(mean firstweight sd firstweight freq)

produces a more accurate tabulation.  -table- uses the two-pass
algorithm to compute the standard deviation.  Even so, the
default display format is different between -summarize- and
-table-.  Displaying a zero standard deviation requires using
option -format()- to change the default format in -table-.

-- Vince 
   vwiggins@stata.com

 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index