Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Unexpected output from -collapse (rawsum)


From   "James Beard" <[email protected]>
To   [email protected]
Subject   Re: st: Unexpected output from -collapse (rawsum)
Date   Sat, 28 Sep 2013 01:53:48 -0000

Thanks very much for the clarification.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From:           	[email protected]
To:             	[email protected]
Subject:        	Re: st: Unexpected output from -collapse (rawsum)
Date sent:      	Fri, 27 Sep 2013 14:43:49 -0500
Send reply to:  	[email protected]

James Beard <[email protected]> demonstrated that -collapse- with
the -rawsum- statistic does not include in the sum any
observations that have zero weight.  His code was:

> . clear all
> . set obs 2
> obs was 0, now 2
> . gen pweight = _n - 1
> . gen v = 1
> . list, clean
>        pweight   v  
>   1.         0   1  
>   2.         1   1  
> . collapse (rawsum) rs=v (sum) ws=v [pw=pweight]
> . list, clean
>        rs   ws  
>   1.    1    1  

And James commented:

> I would have expected rs to be 2 (that is, the same as the result of 
> unweighted -collapse (sum)-. What appears to be happening is that 
> only records with 0<pweight<. are included in the output.
> The documentation, however, says that -rawsum- provides "sums,
> ignoring optionally specified weight".

In -collapse-, zero weighted observations are removed from the
computations (just like we do for observations excluded based on
-if- or -in-).  This is done before -rawsum- (and all the other
available -collapse- statistics) are calculated.  We will modify
the documentation to clarify this point.


Ken Higbee    [email protected]
StataCorp     1-800-STATAPC

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index