----------------------------------------------------------------------------------------- log: C:\MyDocs\MPH\LectureNotes\Class do, log and data files\Survival\7.9.4.Fram > ingham.ClassVersion.log log type: text opened on: 1 Dec 2005, 14:18:20 . * 7.9.4.Framingham.ClassVersion.log . * . * Plot Kaplan-Meier cumulative CHD morbidity curves as a function of age. . * Patients from the Framingham Heart Study enter the analysis when they . * reach the age of their baseline exam. . * . use C:\WDDtext\2.20.Framingham.dta, clear . histogram age, bin(39) fraction ylabel(0(.01).04) xlabel(30(5)65) (bin=39, start=30, width=.97435897) . more . generate time= followup/365.25 . label variable time "Follow-up in Years" . generate exitage = age+time . stset exitage, enter(time age) failure(chdfate) failure event: chdfate != 0 & chdfate < . obs. time interval: (0, exitage] enter on or after: time age exit on or before: failure ------------------------------------------------------------------------------ 4699 total obs. 0 exclusions ------------------------------------------------------------------------------ 4699 obs. remaining, representing 1473 failures in single record/single failure data 103710.1 total analysis time at risk, at risk from t = 0 earliest observed entry t = 30 last observed exit t = 94 . sts graph, by(sex) failure ytitle(Cumulative CHD Morbidity) xtitle(Age) /// > ylabel(0(.1).8, angle(0)) legend(ring(0) position(11) col(1)) /// > clcolor(blue pink) clwidth(medthick medthick) xlabel(30(10)90) noorigin failure _d: chdfate analysis time _t: exitage enter on or after: time age . more . * . * Calculate the logrank test corresponding to these morbidity functions . * . sts test sex failure _d: chdfate analysis time _t: exitage enter on or after: time age Log-rank test for equality of survivor functions | Events Events sex | observed expected ------+------------------------- Men | 823 571.08 Women | 650 901.92 ------+------------------------- Total | 1473 1473.00 chi2(1) = 182.91 Pr>chi2 = 0.0000 . * . * Calculate the relative risk of CHD for men relative to women using . * age as the time variable. . * . generate male = sex==1 . stcox male failure _d: chdfate analysis time _t: exitage enter on or after: time age Iteration 0: log likelihood = -11307.359 Iteration 1: log likelihood = -11218.917 Iteration 2: log likelihood = -11218.785 Refining estimates: Iteration 0: log likelihood = -11218.785 Cox regression -- Breslow method for ties No. of subjects = 4699 Number of obs = 4699 No. of failures = 1473 Time at risk = 103710.0914 LR chi2(1) = 177.15 Log likelihood = -11218.785 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ _t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- male | 2.011662 .1060464 13.26 0.000 1.814192 2.230626 ------------------------------------------------------------------------------ . * . * Perform hazard regression with time dependent covariates for sex . * . tabulate chdfate male Coronary | Heart | male Disease | 0 1 | Total -----------+----------------------+---------- Censored | 2,000 1,226 | 3,226 CHD | 650 823 | 1,473 -----------+----------------------+---------- Total | 2,650 2,049 | 4,699 . generate records = 1 . replace records= 2 if age< 57 & exitage > 57 (3331 real changes made) . expand records (3331 observations created) . sort id . generate enter = age . replace enter = 57 if id==id[_n-1] (3331 real changes made) . generate exit = exitage . replace exit =57 if id==id[_n+1] (3331 real changes made) . generate fate=chdfate . replace fate= 0 if id==id[_n+1] (855 real changes made) . tabulate fate male | male fate | 0 1 | Total -----------+----------------------+---------- 0 | 3,946 2,611 | 6,557 1 | 650 823 | 1,473 -----------+----------------------+---------- Total | 4,596 3,434 | 8,030 . generate male1 = male*(enter < 57) . generate male2= male*(exit > 57) . tabulate male1 male2 | male2 male1 | 0 1 | Total -----------+----------------------+---------- 0 | 4,596 1,672 | 6,268 1 | 1,762 0 | 1,762 -----------+----------------------+---------- Total | 6,358 1,672 | 8,030 . stset exit, id(id) enter(time enter) failure(fate) id: id failure event: fate != 0 & fate < . obs. time interval: (exit[_n-1], exit] enter on or after: time enter exit on or before: failure ------------------------------------------------------------------------------ 8030 total obs. 0 exclusions ------------------------------------------------------------------------------ 8030 obs. remaining, representing 4699 subjects 1473 failures in single failure-per-subject data 103710.1 total analysis time at risk, at risk from t = 0 earliest observed entry t = 30 last observed exit t = 94 . stcox male1 male2 failure _d: fate analysis time _t: exit enter on or after: time enter id: id Iteration 0: log likelihood = -11307.359 Iteration 1: log likelihood = -11202.826 Iteration 2: log likelihood = -11202.652 Iteration 3: log likelihood = -11202.652 Refining estimates: Iteration 0: log likelihood = -11202.652 Cox regression -- Breslow method for ties No. of subjects = 4699 Number of obs = 8030 No. of failures = 1473 Time at risk = 103710.0914 LR chi2(2) = 209.41 Log likelihood = -11202.652 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ _t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- male1 | 3.636365 .4457209 10.53 0.000 2.859782 4.623831 male2 | 1.718114 .1024969 9.07 0.000 1.528523 1.93122 ------------------------------------------------------------------------------ . lincom male1 - male2 ( 1) male1 - male2 = 0 ------------------------------------------------------------------------------ _t | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .7497575 .1363198 5.50 0.000 .4825755 1.01694 ------------------------------------------------------------------------------ . log close log: C:\MyDocs\MPH\LectureNotes\Class do, log and data files\Survival\7.9.4.Fram > ingham.ClassVersion.log log type: text closed on: 1 Dec 2005, 14:18:46 ----------------------------------------------------------------------------------------