Title | The svy command’s handling of zero weights | |

Author | Bill Sribney, StataCorp |

Yes, commands used with the **svy**
prefix treat zero weights differently than commands that allow
**pweight**s used without the svy prefix. The svy prefix dots all the i’s
and cross all the t’s—meaning it gets all the details
right for complex survey data. Although one can use commands
without svy and get essentially correct results in almost all cases, it
is better to use svy if you have data from a complex survey
design.

Commands used without svy ignore any observations with zero weights. You can see the number of observations reported is different. Here’s an example in which two observations have zero weights:

. webuse nhanes2d . keep in 1/70(10281 observations deleted). replace finalwgt = 0 in 1/2(2 real changes made). logit highbp height weight [pw=finalwgt], nologLogistic regression Number of obs = 68 Wald chi2(2) = 4.94 Prob > chi2 = 0.0845 Log pseudolikelihood = -455772.54 Pseudo R2 = 0.1188 ------------------------------------------------------------------------------ | Robust highbp | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- height | -.0467991 .0296647 -1.58 0.115 -.104941 .0113427 weight | .0629183 .0298693 2.11 0.035 .0043756 .1214611 _cons | 2.527636 4.439258 0.57 0.569 -6.173149 11.22842 ------------------------------------------------------------------------------. svyset [pw=finalwgt]pweight: finalwgt VCE: linearized Single unit: missing Strata 1: <one> SU 1: <observations> FPC 1: <zero>. svy: logit highbp height weight(running logit on estimation sample) Survey: Logistic regression Number of strata = 1 Number of obs = 70 Number of PSUs = 70 Population size = 811930 Design df = 69 F( 2, 68) = 2.44 Prob > F = 0.0950 ------------------------------------------------------------------------------ | Linearized highbp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- height | -.0467991 .0296584 -1.58 0.119 -.1059661 .0123678 weight | .0629183 .0298629 2.11 0.039 .0033434 .1224933 _cons | 2.527636 4.438311 0.57 0.571 -6.326553 11.38183 ------------------------------------------------------------------------------

First, note the point estimates are exactly the same. This is always true. Only the elements with nonzero weights are used to compute the point estimates.

Zero weights affect only the variance computation. In the above example, one can see the standard errors differ in the fifth decimal place.

Actually, nothing special is done with them; they are treated just like
nonzero weights. If you look at the formulas in [SVY] **variance
estimation**, you see the variance formula involves the sum:

(Sum over clusters) (z_{i} − zbar)^{2}

where *i* indexes clusters (PSUs) and

z_{i} = (Sum over elements in the *i*-th cluster) weight*something

and zbar is the mean of z_{i}. (I’m assuming
there is only one stratum.)

If all weights in a cluster are zero, then z_{i} is zero.
Thus there is a term (0 − zbar)^{2} in the sum in the variance
formula. Clearly, this result is different from the result one would get if
one ignored observations with zero weights.

Hence, the rule is “Zero weights give different results with svy when all the weights in one or more clusters are zero.”

In the example above, “clusters” are observations, so the above rule implies there will be a difference in this case.

Theoretically, zero sampling weights should not be possible. Sampling
weights are supposed to be the inverse of the probability of being sampled,
so, if this is the case, they cannot be zero. But often weights are adjusted
through various procedures, and they can be set to zero or even a negative
value. (Aside: only
**svyset** with
**iweight**s will handle negative weights, all other commands will exit
with an error mentioning negative weights.)

Zero weights can also be created when one is modeling a subpopulation. For
instance, suppose you have males and females in your sample, and you want to
model only the males. You can do this by setting all the weights for
females to zero. It would be incorrect to model males (**gender**==1) by
doing

. svy: logit y x ... if gender==1

When you do the above, you are ignoring the variation due to sampling different numbers of males. That is, if you redid the sampling, you would get different numbers of males each time.

To model males properly, you can set the weights of females to zero. This,
however, is unnecessary with svy. You can simply use the
**subpop()** option. But this is what the **subpop()** option is
effectively doing—it makes the weights zero for everyone not in the
subpopulation.

In the previous example, we can use the **subpop()** option and get the
same results. We will create a subpopulation indicator variable called
**sub** that is 1 when the weights are nonzero and 0 when they are zero:

. generate sub = (finalwgt != 0) . svy, subpop(sub): logit highbp height weight(running logit on estimation sample) Survey: Logistic regression Number of strata = 1 Number of obs = 70 Number of PSUs = 70 Population size = 811930 Subpop. no. of obs = 68 Subpop. size = 811930 Design df = 69 F( 2, 68) = 2.44 Prob > F = 0.0950 ------------------------------------------------------------------------------ | Linearized highbp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- height | -.0467991 .0296584 -1.58 0.119 -.1059661 .0123678 weight | .0629183 .0298629 2.11 0.039 .0033434 .1224933 _cons | 2.527636 4.438311 0.57 0.571 -6.326553 11.38183 ------------------------------------------------------------------------------

The interpretation of zero weights is that with the svy prefix the commands pick up the component of variance due to sampling differing numbers of elements with zero–nonzero weights.

Hence, when there are only a few zero weights, the difference in standard errors will be very, very small—as it is in this example. Only when there are substantial numbers of zero weights will the standard errors differ appreciably.