Download 03/08/13: Cox con exposición cambiante en tiempo
Document related concepts
no text concepts found
Transcript
COX CON EXPOSICIÓN CAMBIANTE (TIME-DEPENDENT) clear input /// id 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 q0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 q1 0 0 1 0 1 0 0 0 0 0 0 0 . . . 1 0 0 q2 0 0 1 . 1 0 0 0 0 0 0 . . . . . 0 0 q3 0 0 . . 1 0 0 0 0 0 1 . . . . . . . q4 1 0 . . 1 1 0 1 0 1 . . . . . . . . F 4.5 4.7 2.5 1.8 5.1 5.5 4.2 5.5 5.5 5.5 3.5 1.5 0.5 0.5 2.5 1.5 2.5 . d 1 0 1 0 0 1 0 0 1 1 1 0 0 1 1 1 0 0 end lab var F "follow-up (y)" lab var d "evento" stset F, fail(d==1) stcox q0 cor q* **primer paso: columnas de follow-up hasta el max seguim de cada visita foreach n of numlist 0/4{ g FU`n'=`n'+1 replace FU`n'=F if F>`n' & F<(`n'+1) replace FU`n'=. if F<`n' } replace FU4=F if F>4 sum FU0-FU4, d **2º paso: crear un evento para cada visita g d0=d==1 & F<1 g d1=d==1 & F>=1 & F<2 g d2=d==1 & F>=2 & F<3 g d3=d==1 & F>=3 & F<4 g d4=d==1 & F>=4 & F<. tab2 d d0-d4, firstonly **3º paso (opcional): carry forward última exposición disponible si faltan exposiciones replace q1=q0 if q1==. & F>=1 replace q2=q1 if q2==. & F>=2 replace q3=q2 if q3==. & F>=3 replace q4=q3 if q4==. & F>=4 rename d evento *esto de arriba NO es opcional, no se podra hacer reshape si ya existe d reshape long q FU d, i(id) j(visit) bys visit: tab q d stset FU, fail(d) id(id) stcox q Club STATA 2-08-2013 stset F, fail(d==1) stcox q0 -> tabulation of d by d0 | d0 evento | 0 1 | Total -----------+----------------------+---------0| 9 0| 9 1| 8 1| 9 -----------+----------------------+---------Total | 17 1| 18 | d1 evento | 0 1 | Total -----------+----------------------+---------0| 9 0| 9 1| 8 1| 9 -----------+----------------------+---------Total | 17 1| 18 | d2 evento | 0 1 | Total -----------+----------------------+---------0| 9 0| 9 1| 7 2| 9 -----------+----------------------+---------Total | 16 2| 18 | d3 evento | 0 1 | Total -----------+----------------------+---------0| 9 0| 9 1| 8 1| 9 -----------+----------------------+---------Total | 17 1| 18 | d4 evento | 0 1 | Total -----------+----------------------+---------0| 9 0| 9 1| 5 4| 9 -----------+----------------------+---------Total | 14 4| 18 -> visit = 0 | d q| 0 1 | Total -----------+----------------------+---------0| 11 0| 11 1| 6 1| 7 -----------+----------------------+---------Total | 17 1| 18 -> visit = 1 | d q| 0 1 | Total -----------+----------------------+---------0| 13 0| 13 1| 2 1| 3 -----------+----------------------+---------Total | 15 1| 16 -> visit = 2 | d q| 0 1 | Total -----------+----------------------+---------0| 10 1| 11 1| 1 1| 2 -----------+----------------------+---------Total | 11 2| 13 -> visit = 3 | d q| 0 1 | Total -----------+----------------------+---------0| 8 0| 8 1| 1 1| 2 -----------+----------------------+---------Total | 9 1| 10 -> visit = 4 | d q| 0 1 | Total -----------+----------------------+---------0| 3 1| 4 1| 2 3| 5 -----------+----------------------+---------Total | 5 4| 9 stset FU, fail(d) id(id) stcox q0 stset FU, fail(d) id(id) stcox q xtset id visit xtgee d q, family(binomial) link(logit) /// vce(r) cor(unstruct) eform xtgee d q, family(poisson) link(log) vce(r) /// cor(unstruct) exp(FU) eform **explicación predimed- per protocol (0=basal, 1=primer año, etc) **antes se debió preparer E0=energia basal, etc. foreach num of numlist 0/4 { qui regress ac_olivavir`num' E`num' predict res_evoo`num', res qui summ ac_olivavir`num' replace res_evoo`num'=res_evoo`num'+r(mean) cor res_evoo`num' E`num' ac_olivavir`num' } foreach num of numlist 1/4 { gen cambio_acumulado_evoo`num'=res_evoo`num'-res_evoo0 xtile a_evoo`num'=cambio_acumulado_evoo`num', nq(5) tabstat cambio_acumulado_evoo`num', by(a_evoo`num') /// s(n min max) } gen year_evento=floor(follcox) gen d0=0 replace d0=1 if evento1==1 & year_evento==0 gen d1=0 replace d1=1 if evento1==1 & year_evento==1 replace d1=. if follcox<1 | (d0==1) gen d2=0 ** (etc.) clonevar F=follcox capt drop FU0 FU1 FU2 FU3 FU4 foreach n of numlist 0/4{ g FU`n'=`n'+1 replace FU`n'=F if F>`n'& F<(`n'+1) replace FU`n'=. if F<`n' } replace FU4=F if F>4 rename a_evoo1 V0 rename a_evoo3 V1 rename a_evoo4 V2 … rename a_nuts1 N0 rename a_nuts3 N1 … rename a_p14_1 P0 rename a_p14_3 P1 … replace V1=V0 if V1==. & F>=1 replace V2=V1 if V2==. & F>=2 replace V3=V2 if V3==. & F>=3 replace V4=V3 if V4==. & F>=4 replace N1=N0 if N1==. & F>=1 replace N2=N1 if N2==. & F>=2 replace N3=N2 if N3==. & F>=3 replace N4=N3 if N4==. & F>=4 replace P1=P0 if P1==. & F>=1 replace P2=P1 if P2==. & F>=2 replace P3=P2 if P3==. & F>=3 replace P4=P3 if P4==. & F>=4 reshape long V N P FU d, i(id) /// j(visit) stset FU, fail(d) id(id) stcox VOO NUTS edad0 sexo diabetes0 hta0 i.fum ant_fam wth /// imc1 hipercol0, strata(ctr) /// vce(robust) *compruebo que basicamente es lo mismo stcox i.P VOO NUTS edad0 sexo /// diabetes0 hta0 i.fum ant_fam wth /// imc1 hipercol0, strata(ctr) /// vce(robust) cformat(%3.2f) stcox i.V VOO NUTS edad0 sexo /// diabetes0 hta0 i.fum ant_fam wth /// imc1 hipercol0, strata(ctr) vce(robust) cformat(%3.2f) stcox i.N VOO NUTS edad0 sexo diabetes0 hta0 i.fum ant_fam wth /// imc1 hipercol0, strata(ctr) vce(robust) cformat(%3.2f)
Related documents