cd "C:\Users\ssarma2\Documents\Teaching\Winter 2014\Lectures\Survival Analysis\Extraction from KM" use Example /*Step 1: declare the data as count-time data by informing STATA key variables: time, events, censored*/ ctset time_month n_events n_censored /*Step 2: Convert count-time data to survival-time data using cttost command*/ cttost save Example_ct /*Step 3: Check your K-M curve -- should appear close to the published K-M curve*/ sts graph /*Fit a Weibull Distribution*/ streg, dist(weibull) time nohr /*Weibull shape parameter gamma=p*/ /*Weibull scale parameter lambada that SAS produces is exp(_cons) in STATA*/ /*Compare estimators*/ streg, dist(exp) estimates store exp streg, dist(weib) estimates store weib streg, dist(lnormal) estimates store lnorm streg, dist(gomp) estimates store gomp streg, dist(gamma) estimates store gamma estimates stats _all /*generalized gamma model*/ streg, dist(gamma) time /*log-normal*/ test [kappa]_b[_cons]=0 streg, dist(gamma) time lrtest, saving(0) streg, dist(lnormal) time lrtest, force /*Weibull*/ streg, dist(gamma) time test [kappa]_b[_cons]=1 /*Exponential*/ streg, dist(gamma) time test [kappa]_b[_cons]=0, notest test [ln_sig]_b[_cons]=0, accum