clear import delimited /Users/edwinnuwagira/Downloads/dataset.csv, clear count /***DATA MANAGMENT**/ ****************************************************** recode age (18/24.99 = 1 "18-24") (25/34.99 = 2 "25-34") (35/49.99 = 3 "35-49") (50/max = 4 ">=50"), generate (agecat) recode child_live (1/2 = 1 "1-2") (3/4 = 2 "3-4") (5/max = 3 ">=5") (0 = .), generate (child_alive1) count *new count: 193 recode cd4_0 (min/99.99 =1 "<100") (100/250.99 =2 "100-250") (251/500.99 =3 "251-500") (501/max =4 ">500"), gen (cd4_cat) recode cd4_12 (min/99.99 =1 "<100") (100/250.99 =2 "100-250") (251/500.99 =3 "251-500") (501/max =4 ">500"), gen (cd4_cat12) gen bmi0 = (wt0/(ht0/100)^2) recode bmi0 (min/18.499 = 1 "<18.5") (18.5/25.999 = 2 "18.5-25") (26/29.99 = 3 "26-29") (30/max = 4 ">=30"), generate (bmi0_cat) ta bmi0_cat sum bmi0, d sum vl0, d sum lym, d sum hb0, d label define mstatus 1"Single/Divorced/widowed/separated" 2"Married label value mstatus mstatus tab mstatus tab clin_fail tab immuno_fail tab clin_fail sum child_live tab tb0 tab ccm0 tab ks0 recode vl0 (min/399.99 = 1 "<1000") (400/max = 2 ">=1000"), generate (bvl_cat) recode vl12 (min/399.99 = 1 "<400") (400/max = 2 ">=400"), generate (vl12_cat) recode yearart(min/2006=1 "<2006") (2006.1/2010=2 "2006-2010") (2010/max=3 ">2010"), gen(statyr) *Generating Outcome variables* recode hb0 (13/max = 0 "Normal") (11/12.99 = 1 "mild") (8/10.99 = 2 "Moderate") (min/7.99 = 3 "Severe") if sex==1, generate (aneamiama) recode hb0 (12/max = 0 "Normal") (11/11.99 = 1 "mild") (8/10.99 = 2 "Moderate") (min/7.99 = 3 "Severe") if sex==2, generate (aneamiafe) gen anemiax=. replace anemiax=0 if anemiax==. & (aneamiama==0 | aneamiafe==0) replace anemiax=1 if anemiax==. & (aneamiama==1 | aneamiafe==1) replace anemiax=2 if anemiax==. & (aneamiama==2 | aneamiafe==2) replace anemiax=3 if anemiax==. & (aneamiama==3 | aneamiafe==3) recode anemiax (0 = 0 "No") (1 = 1 "Mild") (2/3 = 2 "Mod/sev"), generate (anemia_final) replace immuno_fail=1 if immuno_fail==2 recode sbp0 (min/139 = 0 "<=139") (140/max = 1 ">139"), generate (sbpcat0) recode dbp0 (min/89 = 0 "<=89") (90/max = 1 ">89"), generate (dbpcat0) *Generating combined lftu and death ta death ltfu recode yearart(min/2006=1 "<2006") (2006.1/2010=2 "2006-2010") (2010/max=3 ">2010"), gen(artyear) label value artyear artyear label define sex 1"Male" 2"Female" label value sex sex mdesc mstatus pstatus child_live occup cd4_0 anemia_final sbpcat0 dbpcat0 statyr bmi12_cat child_alive1 ********************************************************* /***EXCLUDING MISSING VALUES***/ ********************************************** ****************************************************************************** /*2. Determine the factors associated with loss to follow up of patients on second line ART during the first one year of treatment. */ ***************************************************************************** /**UNIVARIATE ANALYSIS**/ sum age, d sum cd4_0, d sum **Chi-square test ********************* *Sociodemo xtics ta agecat ltfu, chi row tab sex ltfu, chi row ta pat_type ltfu, chi row ta mstatus ltfu, chi row ta pstatus ltfu, chi row ta occup ltfu, chi row ta anemia_final ltfu, row *MEDICAL XTICS* ta statyr ltfu, chi row ta ddi ltfu, chi row *CLINICAL STATUS AT secondline INITIATION* tab cd4_cat ltfu, chi row ta bmi0_cat ltfu, chi row ta sbpcat0 ltfu, chi row ta dbpcat0 ltfu, chi row ta ks0 ltfu, chi row ta ccm0 ltfu, chi row ta tb0 ltfu, chi row ta bvl_cat ltfu, chi row ta stage0 ltfu, chi row ta anemia_final ltfu, chi row su lymp0, detail ta immuno_fail ltfu, chi row ta viral_fail ltfu, chi row ta clin_fail ltfu, chi row ta adh ltfu, chi row /**UNIVARIATE ANALYSIS**/ **Chi-square test ********************* mi set mlong mi misstable patterns pstatus occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1 mi misstable summarize pstatus child_live occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1 pwcorr pstatus occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1 gen mstatus_flag=1 replace mstatus_flag=0 if mstatus==. gen pstatus_flag=1 replace pstatus_flag=0 if pstatus==. gen child_alive1_flag=1 replace child_alive1_flag=0 if child_alive1==. gen occup_flag=1 replace occup_flag=0 if occup==. gen anemia4_flag=1 replace anemia4_flag=0 if anemia4==. gen sbpcat0_flag=1 replace sbpcat0_flag=0 if sbpcat0==. gen dbpcat0_flag=1 replace dbpcat0_flag=1 if dbpcat0==. gen statyr_flag=. replace statyr_flag=0 if statyr==. gen bmi0_cat_flag=1 replace bmi0_cat_flag=0 if bmi0_cat==. gen cd4_0_flag=1 replace cd4_0_flag=0 if cd4_0==. foreach var of varlist anemia4_flag-statyr_flag{ display "'var'" } mi register imputed pstatus occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1 mi impute mvn pstatus occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1,add(10) rseed(53421) mi estimate: regress pstatus occup cd4_0 anemia_final sbpcat0 dbpcat0 artyear bmi12_cat child_alive1 ltfu mi estimate, vartable dftable *Sociodemo xtics ************************* **Binomial regression** ************************** *Sociodemo xtics xi:binreg ltfu ib2.sex, rr xi:binreg ltfu i.pat_type, rr xi:binreg ltfu i.statyr, rr xi:binreg ltfu i.dbpcat0, rr xi:binreg ltfu i.ccm1,rr xi:binreg ltfu i.ks1,rr xi:binreg ltfu i.tb1,rr xi:binreg ltfu i.viral_fail, rr xi:binreg ltfu i.mstatus, rr *MEDICAL XTICS* xi:binreg ltfu b1.artyear, rr xi:binreg ltfu i.ddi, rr *CLINICAL STATUS AT secondline INITIATION* xi:binreg ltfu ib1.cd4_cat, rr xi:binreg ltfu i.bmi0_cat, rr xi:binreg ltfu i.ks0, rr xi:binreg ltfu i.ccm0, rr xi:binreg ltfu i.tb0, rr xi:binreg ltfu ib1.bvl_cat, rr xi:binreg ltfu i.stage0, rr su lymp0, detail xi:binreg ltfu ib1.immuno_fail, rr xi:binreg ltfu i.viral_fail, rr xi:binreg ltfu i.clin_fail, rr xi:binreg ltfu i.adh, rr /***Final Model**/ ******************* //xi:binreg ltfu ib1.sex ib1.agecat i.pat_type b3.artyear ib4.cd4_cat i.bmi0_cat i.anemia_final ib1.ccm1 i.clin_fail, rr /////new m.i commands//// xi:binreg ltfu ib2.sex ib1.agecat i.pat_type i.bmi0_cat ib1.stage0, rr //// xi:binreg ltfu i.anemia_final,rr xi:binreg ltfu ib2.sex ib1.agecat i.pat_type i.bmi0_cat ib1.stage0 ib1.anemia_final b2.artyear, rr