use https://www.stata-press.com/data/r18/nhanes2f, clear svyset psuid [pweight=finalwgt], strata(stratid) singleunit(centered) * slide 82 * 1. Get the means for the variables "iron" and "hgb" svy: mean iron hbg * 2. Make a weighted scatterplot with the variables "iron" and "hgb". twoway (scatter iron hbg [pw = finalwgt]) (lfit iron hbg [pw = finalwgt]) * 3. Get a frequency table for the variable "female"; include both the weighted (population) and unweighted size. svy: female, count obs ci cellwidth(12) format(%12.2g) * 4. Is there a relationship between the variables "female" and "agegrp"? svy: tab female agegrp // no; p-value = 0.2960 * slide 124 * 1. Run a t-test with the variable "heartatk" as the predictor and the variable "vitaminc" as the outcome svy: regress vitaminc i.heartatk * 2. Is the result statistically significant? * no; the p-value is 0.1813 * 3. Run a regression model with "vitaminc" as the outcome and one continuous and one categorical predictor of your choice. Use two post-estimation commands of your choice. svy: regress vitaminc i.agegrp bpsystol contrast agegrp margins agegrp, vce(unconitional) * 4. How are the degrees of freedom for the model calculated? * number of PSUs - number of strata * 5. Rerun your regression using data from females only svy, subpop(female): regress vitaminc i.agegrp bpsystol contrast agegrp margins agegrp, vce(unconditional) subpop(female) * slide 143 * 1. Choose or create a binary variable from the example dataset * I choose diabetes * 2. Run a logistic regression with this new variable as the outcome variable and three predictors of your choice svy: logit diabetes i.agegrp i.region weight * 3. Include an interaction term in the model svy: logit diabetes i.agegrp##c.weight i.region contrast agegrp#c.weight * 4. Graph the interaction margins agegrp, at(weight=(35(10)175)) vce(unconditional) marginsplot * 5. Rerun your model using a subpopulation svy, subpop(female): logit diabetes i.agegrp##c.weight i.region contrast agegrp#c.weight * 6. Get the predicted probabilities margins agegrp, at(weight=(35(10)175)) vce(unconditional) subpop(female) marginsplot