* Example of individual-level and cluster-level analysis with the same variables * Kenya 2022 DHS survey use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\KEIR81FL.DTA" , clear * construct a binary outcome variable for 4+ children gen nch4plus=0 replace nch4plus=1 if v201>=4 * construct dummies for wealth quintiles xi, noomit i.v190 rename _I* * * Individual-level analysis svyset v001 [pweight=v005], strata(v023) singleunit(centered) svy: glm nch4plus v190_* , family(binomial) link(logit) eform * Cluster-level analysis; first switch to clusters as units gen cases=1 collapse (first) v005 v023 (sum) nch4plus cases (mean) v190_*, by(v001) * Calculate to observed proportions with outcome=1 in each cluster * Weights not needed because all cases in the same cluster have the same weight gen nch4plus_prop=nch4plus/cases svyset [pweight=v005], strata(v023) singleunit(centered) * Run with eform to get odds ratios svy: glm nch4plus v190_* , family(binomial cases) link(logit) eform * Run without eform to get fitted frequencies and fitted proportions svy: glm nch4plus v190_* , family(binomial cases) link(logit) predict nch4plus_hat gen nch4plus_prop_hat=nch4plus_hat/cases scatter nch4plus_prop_hat nch4plus_prop, graphregion(color(white)) xlabel(0 .25 .5 .75 1) ylabel(0 .25 .5 .75 1) * Note: there are clusters in which all households are in the bottom wealth quintile * or all households are in the top wealth quintile