Stata 15 help for svy

[SVY] svy -- The survey prefix command


svy [vcetype] [, svy_options eform_option] : command

vcetype Description ------------------------------------------------------------------------- SE linearized Taylor-linearized variance estimation bootstrap bootstrap variance estimation; see [SVY] svy bootstrap brr BRR variance estimation; see [SVY] svy brr jackknife jackknife variance estimation; see [SVY] svy jackknife sdr SDR variance estimation; see [SVY] svy sdr ------------------------------------------------------------------------- Specifying a vcetype overrides the default from svyset.

svy_options Description ------------------------------------------------------------------------- if/in subpop([varname] [if]) identify a subpopulation

SE dof(#) design degrees of freedom bootstrap_options more options allowed with bootstrap variance estimation brr_options more options allowed with BRR variance estimation jackknife_options more options allowed with jackknife variance estimation sdr_options more options allowed with SDR variance estimation

Reporting level(#) set confidence level; default is level(95) nocnsreport do not display constraints display_options control columns and column formats, row spacing, line width, display of omitted variables and base and empty cells, and factor-variable labeling

noheader suppress table header nolegend suppress table legend noadjust do not adjust model Wald statistic noisily display any output from command trace trace command coeflegend display legend instead of statistics ------------------------------------------------------------------------- svy requires that the survey design variables be identified using svyset. command defines the estimation command to be executed. The by prefix cannot be part of command. mi estimate may be used with svy linearized if the estimation command allows mi estimate; it may not be used with svy bootstrap, svy brr, svy jackknife, or svy sdr. noheader, nolegend, noadjust, noisily, trace, and coeflegend are not shown in the dialog boxes for estimation commands. Warning: Using if or in restrictions will often not produce correct variance estimates for subpopulations. To compute estimates for subpopulations, use the subpop() option. See [SVY] svy postestimation for features available after estimation.


svy fits statistical models for complex survey data by adjusting the results of a command for survey settings identified by svyset. Any Stata estimation command listed in [SVY] svy estimation may be used with svy. User-written programs that meet the requirements in [P] program properties may also be used.


+-------+ ----+ if/in +------------------------------------------------------------

subpop(subpop) specifies that estimates be computed for the single subpopulation identified by subpop, which is

[varname] [if]

Thus the subpopulation is defined by the observations for which varname!=0 that also meet the if conditions. Typically, varname=1 defines the subpopulation, and varname=0 indicates observations not belonging to the subpopulation. For observations whose subpopulation status is uncertain, varname should be set to a missing value; such observations are dropped from the estimation sample.

See [SVY] subpopulation estimation and [SVY] estat.

+----+ ----+ SE +---------------------------------------------------------------

dof(#) specifies the design degrees of freedom, overriding the default calculation, df = N_psu - N_strata.

bootstrap_options are other options that are allowed with bootstrap variance estimation specified by svy bootstrap or specified as svyset using the vce(bootstrap) option; see [SVY] bootstrap_options.

brr_options are other options that are allowed with BRR variance estimation specified by svy brr or specified as svyset using the vce(brr) option; see [SVY] brr_options.

jackknife_options are other options that are allowed with jackknife variance estimation specified by svy jackknife or specified as svyset using the vce(jackknife) option; see [SVY] jackknife_options.

sdr_options are other options that are allowed with SDR variance estimation specified by svy sdr or specified as svyset using the vce(sdr) option; see [SVY] sdr_options.

+-----------+ ----+ Reporting +--------------------------------------------------------

level(#) specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level.

nocnsreport; see [R] estimation options.

display_options: noci, nopvalues, noomitted, vsquish, noemptycells, baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style), cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

The following options are available with svy but are not shown in the dialog boxes:

noheader prevents the table header from being displayed. This option implies nolegend.

nolegend prevents the table legend identifying the subpopulations from being displayed.

noadjust specifies that the model Wald test be carried out as W/k distributed F(k,d), where W is the Wald test statistic, k is the number of terms in the model excluding the constant term, d is the total number of sampled PSUs minus the total number of strata, and F(k,d) is an F distribution with k numerator degrees of freedom and d denominator degrees of freedom. By default, an adjusted Wald test is conducted: (d-k+1)W/(kd) distributed F(k,d-k+1).

See Korn and Graubard (1990) for a discussion of the Wald test and the adjustments thereof. Using the noadjust option is not recommended.

noisily requests that any output from command be displayed.

trace causes a trace of the execution of command to be displayed.

coeflegend; see [R] estimation options.

The following option is usually available with svy at the time of estimation or on replay but is not shown in all dialog boxes:

eform_option; see [R] eform_option.


. webuse nhanes2f . svyset psuid [pweight=finalwgt], strata(stratid) . svy: mean zinc . mean zinc

. svyset [pweight=finalwgt] . svy: mean zinc

. svyset psuid [pweight=finalwgt] . svy: mean zinc

. svyset psuid [pweight=finalwgt], strata(stratid) . svy: regress zinc age age2 weight female black orace rural

Stored results

svy stores the following in e():

Scalars e(N) number of observations e(N_sub) subpopulation observations e(N_strata) number of strata e(N_strata_omit) number of strata omitted e(singleton) 1 if singleton strata, 0 otherwise e(census) 1 if census data, 0 otherwise e(F) model F statistic e(df_m) model degrees of freedom e(df_r) variance degrees of freedom e(N_pop) estimate of population size e(N_subpop) estimate of subpopulation size e(N_psu) number of sampled PSUs e(stages) number of sampling stages e(k_eq) number of equations in e(b) e(k_aux) number of ancillary parameters e(p) p-value e(rank) rank of e(V)

Macros e(prefix) svy e(cmdname) command name from command e(cmd) same as e(cmdname) or e(vce) e(command) command e(cmdline) command as typed e(wtype) weight type e(wexp) weight expression e(weight#) variable identifying weight for stage # e(wvar) weight variable name e(singleunit) singleunit() setting e(strata) strata() variable e(strata#) variable identifying strata for stage # e(psu) psu() variable e(su#) variable identifying sampling units for stage # e(fpc) fpc() variable e(fpc#) FPC for stage # e(title) title in estimation output e(poststrata) poststrata() variable e(postweight) postweight() variable e(vce) vcetype specified in vce() e(vcetype) title used to label Std. Err. e(mse) mse, if specified e(subpop) subpop from subpop() e(adjust) noadjust, if specified e(properties) b V e(estat_cmd) program used to implement estat e(predict) program used to implement predict e(marginsnotok) predictions disallowed by margins e(marginswtype) weight type for margins

Matrices e(b) estimates e(V) design-based variance e(V_srs) simple-random-sampling-without-replacement variance, V_srswor hat e(V_srssub) subpopulation simple-random-sampling-without-replacement variance, V_srswor hat (created only when subpop() is specified) e(V_srswr) simple-random-sampling-with-replacement variance, V_srswr hat (created only when fpc() option is svyset) e(V_srssubwr) subpopulation simple-random-sampling-with-replacement variance, V_srswr hat (created only when subpop() is specified) e(V_modelbased) model-based variance e(V_msp) variance from misspecified model fit, V_msp hat e(_N_strata_single) number of strata with one sampling unit e(_N_strata_certain) number of certainty strata e(_N_strata) number of strata

Functions e(sample) marks estimation sample

svy also carries forward most of the results already in e() from command.


Korn, E. L., and B. I. Graubard. 1990. Simultaneous testing of regression coefficients with complex survey data: Use of Bonferroni t statistics. American Statistician 44: 270-276.

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index