Search
   >> Home >> Resources & support >> FAQs >> The svy command’s handling of zero weights

Do the svy commands handle zero weights differently than non-svy commands do?

Title   The svy command’s handling of zero weights
Author Bill Sribney, StataCorp
Date April 1998; updated June 2013

Yes, the svy commands treat zero weights differently than do non-svy commands that allow pweights. The svy commands are the ones that dot all the i’s and cross all the t’s—meaning they get all the details right for complex survey data. Although one can use the non-svy commands with survey data and get essentially correct results in almost all cases, it is better to use the svy commands if you have data from a complex survey design.

Non-svy commands 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], nolog

Logistic 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.

So how are zero weights handled?

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) (zi − zbar)2

where i indexes clusters (PSUs) and

zi = (Sum over elements in the i-th cluster) weight*something

and zbar is the mean of zi. (I’m assuming there is only one stratum.)

If all weights in a cluster are zero, then zi 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 in the svy commands from the non-svy commands 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.

How are zero weights interpreted?

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 iweights 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 the svy commands. 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 the svy 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.

The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ Watch us on YouTube