** HW 2 Solutions 2009 ** ** Read in Dataset ** cd "/Users/haley/Dropbox/Desktop/LDA09/data" infile id infect time gender vitA age using "ICHS.txt" xtset id time ** fit the model in (a) with independent correlation structure ** xi: xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(ind) test vitA ** fit the model in (c) using the unstructured correlation ** xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(uns) estat wcor ** try the exchangeable and ar1 models ** xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(exc) xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(ar1) ** final model ** xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(exc) robust ** test H0 ** test vitA ** tests in part (f) ** test time test age test gender test age gender ** fit the random intercept model from (g) ** xtlogit infect time gender age vitA ** estimate the probabilities in (i) ** lincom 3*time+3*age+_cons display exp(-1.49)/(1+exp(-1.49)) display exp(-2.19)/(1+exp(-2.19)) display exp(-0.78)/(1+exp(-0.78)) lincom 3*time+3*age+vitA+_cons ** estimate the same probabilities for the gee model ** xtgee infect time gender age vitA, nolog f(bin) l(logit) corr(exc) robust lincom 3*time+3*age+_cons lincom 3*time+3*age+vitA+_cons ** fit a GEE and RE transition model ** ** first create the indicator variable for infection at previous visit ** ** shift the infection indicator down by 1 row ** gen infect_prev = infect[_n-1] ** drop the first visit of all subjects ** by id: drop if _n==1 xtgee infect infect_prev time gender age vitA, nolog f(bin) l(logit) corr(exc) robust xtlogit infect infect_prev time gender age vitA