Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: Weighted number of observations


From   Toyoto Iwata <iwata@med.akita-u.ac.jp>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Weighted number of observations
Date   Wed, 04 Aug 2004 00:11:32 +0900

Dear Friedrich and Nick,

Richard Williams has reported the feature of the tabstat.

>To add to the mystery:
>
>. tabstat foreign [aw=weight], stat(count)
>
>variable | N
>-------------+----------
>foreign | 74
>------------------------
>
>. tabstat foreign [aw=weight], stat(mean)
>
>variable | mean
>-------------+----------
>foreign | .2280254
>------------------------
>
>. tabstat foreign [aw=weight], stat(sum)
>
>variable | sum
>-------------+----------
>foreign | 50950
>------------------------
>

In fact,

. sum for [aw = wei]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min
Max
-------------+--------------------------------------------------------------
---
     foreign |      74      223440    .2280254    .422423          0
  1

. gen sumweight = sum(weight)

. list sumweight in l

     +----------+
     | sumwei~t |
     |----------|
 74. |   223440 |
     +----------+

. di 50950/223440
.22802542

  This is because we assume the value 0 or 1 for each weight unit.


Toyoto

> Dear Toyoto,
> 
> The auto data has 22 observations with foreign=1, not 50950. In [R]
> tabstat we read: "aweights and fweights are allowed; see [U] 14.1.6
> weight." [U] 14.1.6 states that most Stata commands rescale the
> aweights to sum to N. However, -tabstat- does not rescale the
> weights.  The fact that -tabstat- treats aweights the same way as
> fweights is not clearly documented. One could also argue that this
> behavior is inconsistent.
> 
> Friedrich Huebler
> 


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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