Stata svy:regres Command for Multiple Linear Regression

Statements Explanation
use "C:\Stata\tutorial\analysis_data.dta", clear

Use the use command to load the Stata-format dataset. Use the clear option to replace any data in memory.

svyset sdmvpsu [pweight=wtmec4yr], strata(sdmvstra) vce(linearized)


Use the svyset command to declare the survey design for the dataset. Specifiy the psu variable sdmvpsu.

Use the [pweight=] option to account for the unequal probability of sampling and non-response.  In this example, the MEC weight for four years of data (wtmec4yr) is used. Use the strata ( ) option to specify the stratum identifier (sdmvstra). Use the vce( ) option to specific the variance estimation method  (linearized) for Taylor linearization.

char ridreth1[omit]3

char smoker[omit]3

char educ[omit]3  

char bmicat[omit]2

Use these options to choose your reference group for the categorical variables. For example, the 3rd race/ethnicity (ridreth1) category (non-Hispanic White) is chosen as the reference group. If you do not specify the reference group options, Stata will choose the lowest numbered group by default.

xi: svy, subpop(if ridageyr >=20) vce(linearized): regress lbdhdl i.riagendr i.ridreth1 ridageyr bmxbmi i.smoker i.educ i.bmicat

Use the xi command to expand terms containing categorical variables (denoted i.varname) into indicator (also called dummy) variable sets. Use the svy: regress command to perform multiple linear regression to specify the dependent variable HDL cholesterol (lbdhdl) and independent variables, including: gender, race, age, body mass index, smoking, education and BMI category.



test _Iriagendr_2, nosvyadjust

test _Iridreth1_1 _Iridreth1_2 _Iridreth1_4 _Iridreth1_5, nosvyadjust

test ridageyr, nosvyadjust

test _Ibmicat_1 _Ibmicat_3 _Ibmicat_4, nosvyadjust

test _Ismoker_1 _Ismoker_2, nosvyadjust

test _Ieduc_1 _Ieduc_2, nosvyadjust 


test  _Ismoker_1 - _Ismoker_2 =0


Use the test postestimation command to produce the Wald F statistic and the corresponding p-value. Use the nosvyadjust option to produce the unadjusted Wald F. In the example, the command test is used to test all coefficient together; all coefficients separately; and to test the hypothesis that HDL cholesterol for non-smokers is the same as that for past smokers.



Close icon Close Window