**Logistic regression for binary data****NEPAL DATA**** ***generate obs no representing equally spaced times**** egen newid=group(id) summ newid drop id ren newid id sort id age by id: gen obsno=_n tab obsno tsset id obsno ***Generate binary breastfeeding variable*** xttab bf ** label list gen bfbin=1*(bf==1|bf==2) tab bf bfbin ***Explore marginal mean model wrt age ksm bfbin age, lowess bw(.4) xlab ylab(0(.2)1) nograph gen(bfbinsm) sort age gr bfbin bfbinsm age, c(.L) s(oi) ylab gen bfbinjg=bfbin+.1*(uniform()-.5) sort age gr bfbinjg bfbinsm age, c(.L) s(oi) ylab *** logistic regression in STATA *** gen agesex=age*sex logit bfbin age sex agesex logistic bfbin age sex agesex predict prob *** sensitivity and specificity from 2 by 2 table *** gen c = .5 gen bfhat = 1 if prob > c replace bfhat = 0 if bfhat == . tab bfbin bfhat *** test for statistical significance *** test agesex test sex agesex ***FIT GEE w/ AR(1)*** xtgee bfbin sex age agesex, f(bin) link(logit) corr(ar1) test sex agesex xtgee bfbin age, f(bin) link(logit) corr(ar1) xtcorr, compact xtcorr ***Assess the model fit**** predict bffitar1 sort age gr bfbinjg bfbinsm bffitar1 age,c(.ll) s(oii) ylab ****Fit GEE with uniform corr model **** xtgee bfbin sex age agesex, f(bin) link(logit) corr(exc) nolog ** display exponential of coefficient *** xtgee bfbin age , f(bin) link(logit) corr(exc) nolog xtgee bfbin age , f(bin) link(logit) corr(exc) nolog eform predict bffitexc gr bfbinjg bfbinsm bffitar1 bffitexc age,c(.lll) s(ooip) ylab ***Fit an unstructured correlation structure*** xtgee bfbin age , f(bin) link(logit) corr(unst) nolog xtcorr