The examples below use Stata 9. If you are using Stata versions 7 or 8, please see this page.
NOTE: If you want to see the design effect or the misspecification effect, use estat effects after the command.
This example is taken from Levy and Lemeshow’s Sampling of Populations.
page 285 two-stage cluster sampling (clusters sampled with equal probability)
input center nurse m nbar w npatnts nrefrred 1 2 5 3 2.5 44 6 1 3 5 3 2.5 18 6 2 1 5 3 2.5 42 3 2 3 5 3 2.5 10 2 4 1 5 3 2.5 16 5 4 2 5 3 2.5 32 14 end
svyset center [pweight=w]
pweight: w
VCE: linearized
Strata 1: <one>
SU 1: center
FPC 1: <zero>
svy: total nrefrred
(running total on estimation sample)
Survey: Total estimation
Number of strata = 1 Number of obs = 6
Number of PSUs = 3 Population size = 15
Design df = 2
--------------------------------------------------------------
| Linearized
| Total Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
nrefrred | 90 30.31089 -40.41723 220.4172
--------------------------------------------------------------
svy: ratio nrefrred npatnts
(running ratio on estimation sample)
Survey: Ratio estimation
Number of strata = 1 Number of obs = 6
Number of PSUs = 3 Population size = 15
Design df = 2
_ratio_1: nrefrred/npatnts
--------------------------------------------------------------
| Linearized
| Ratio Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
_ratio_1 | .2222222 .0812779 -.1274883 .5719328
--------------------------------------------------------------
page 310 two-stage cluster sampling (clusters sampled with equal probability)
use https://stats.idre.ucla.edu/stat/books/sop/i10pt2.dta, clear
svyset hospno [pweight=w]
pweight: w
VCE: linearized
Strata 1: <one>
SU 1: hospno
FPC 1: <zero>
svy: total dxdead
(running total on estimation sample)
Survey: Total estimation
Number of strata = 1 Number of obs = 708
Number of PSUs = 3 Population size = 23600
Design df = 2
--------------------------------------------------------------
| Linearized
| Total Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
dxdead | 499.3792 114.6776 5.961244 992.7971
--------------------------------------------------------------
svy: ratio dxdead lifethrt
(running ratio on estimation sample)
Survey: Ratio estimation
Number of strata = 1 Number of obs = 708
Number of PSUs = 3 Population size = 23600
Design df = 2
_ratio_1: dxdead/lifethrt
--------------------------------------------------------------
| Linearized
| Ratio Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
_ratio_1 | .1703017 .072273 -.140664 .4812674
--------------------------------------------------------------
