Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Why does one command "lose" observations compared to another command?


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: Why does one command "lose" observations compared to another command?
Date   Sun, 22 Jan 2006 15:02:19 -0500

At 02:16 PM 1/22/2006, Suzy wrote:
If the mecwt4 variable loses some observations (which is certainly possible), why didn't it also lose those observations for the svy command? In other words, shouldn't the svy command output have been =
Subpop. no. obs = 10,568 rather than the 11,441?

Thank you for helping troubleshoot the problem!
Does mecwt4 include weights of zero? I am guessing that may be why. svy still counts cases with 0 weights, but mean with the weight parameter does not. Here is a pseudo-replication of your problem. Rich

. webuse nhanes2f

. * subpop size is 9090 in both svy, non-svy analysis
. svy, subpop(if age>=25): mean age, over(race)
(running mean on estimation sample)

Survey: Mean estimation

Number of strata = 31 Number of obs = 10337
Number of PSUs = 62 Population size = 1.2e+08
Subpop. no. obs = 9090
Subpop. size = 1.0e+08
Design df = 31

White: race = White
Black: race = Black
Other: race = Other

--------------------------------------------------------------
| Linearized
Over | Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
age |
White | 45.91354 .308088 45.28519 46.54189
Black | 44.20919 .5337285 43.12064 45.29773
Other | 44.03196 2.201001 39.54299 48.52093
--------------------------------------------------------------

. mean age [pweight = finalwgt] if age>=25, over(race)

Mean estimation Number of obs = 9090

White: race = White
Black: race = Black
Other: race = Other

--------------------------------------------------------------
Over | Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
age |
White | 45.91354 .170648 45.57903 46.24805
Black | 44.20919 .4886224 43.25138 45.167
Other | 44.03196 1.073968 41.92674 46.13718
--------------------------------------------------------------

. *************************************
. replace finalwgt = 0 in 1/10
(10 real changes made)

. * We've changed some weights to 0 - but subpop size is still 9090 in svy
. svy, subpop(if age>=25): mean age, over(race)
(running mean on estimation sample)

Survey: Mean estimation

Number of strata = 31 Number of obs = 10337
Number of PSUs = 62 Population size = 1.2e+08
Subpop. no. obs = 9090
Subpop. size = 1.0e+08
Design df = 31

White: race = White
Black: race = Black
Other: race = Other

--------------------------------------------------------------
| Linearized
Over | Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
age |
White | 45.90365 .304178 45.28327 46.52402
Black | 44.19801 .5404275 43.0958 45.30022
Other | 44.03196 2.201001 39.54299 48.52093
--------------------------------------------------------------

. * But Mean command now reports a smaller subpop size of 9081
. mean age [pweight = finalwgt] if age>=25, over(race)

Mean estimation Number of obs = 9081

White: race = White
Black: race = Black
Other: race = Other

--------------------------------------------------------------
Over | Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
age |
White | 45.90365 .1707149 45.56901 46.23829
Black | 44.19801 .4886391 43.24017 45.15585
Other | 44.03196 1.073968 41.92674 46.13718
--------------------------------------------------------------


*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index