. cd /Users/MALF/Dropbox/CANSURV-slides-course/Granada/
/Users/MALF/Dropbox/CANSURV-slides-course/Granada
. use melanoma
(Skin melanoma, diagnosed 1975-94, follow-up to 1995)
. stset surv_mm, failure(status=1 2) scale(12) exit(time 120.5) id(id)
Survival-time data settings
ID variable: id
Failure event: status==1 2
Observed time interval: (surv_mm[_n-1], surv_mm]
Exit on or before: time 120.5
Time for analysis: time/12
--------------------------------------------------------------------------
7,775 total observations
0 exclusions
--------------------------------------------------------------------------
7,775 observations remaining, representing
7,775 subjects
2,777 failures in single-failure-per-subject data
43,384.625 total analysis time at risk and under observation
At risk from t = 0
Earliest observed entry t = 0
Last observed exit t = 10.04167
. gen _age = min(int(age + _t),99)
. gen _year = int(yydx + _t)
. sort _year sex _age
. merge m:1 _year sex _age using popmort, keep(match master)
Result Number of obs
-----------------------------------------
Not matched 0
Matched 7,775 (_merge==3)
-----------------------------------------
. tab agegrp, gen(agegrp)
Age in 4 |
categories | Freq. Percent Cum.
------------+-----------------------------------
0-44 | 2,046 26.32 26.32
45-59 | 2,238 28.78 55.10
60-74 | 2,280 29.32 84.42
75+ | 1,211 15.58 100.00
------------+-----------------------------------
Total | 7,775 100.00
. gen female = sex == 2
.
. /* Fit initial model */
.
. stpm2, df(3) scale(hazard) bhazard(rate)
Iteration 0: log likelihood = -8731.8053
Iteration 1: log likelihood = -8590.4493
Iteration 2: log likelihood = -8590.0259
Iteration 3: log likelihood = -8590.0249
Iteration 4: log likelihood = -8590.0249
Log likelihood = -8590.0249 Number of obs = 7,775
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
xb |
_rcs1 | .8252308 .0249859 33.03 0.000 .7762595 .8742022
_rcs2 | .2110309 .0235833 8.95 0.000 .1648085 .2572534
_rcs3 | .0631928 .0109672 5.76 0.000 .0416974 .0846881
_cons | -1.813097 .0314253 -57.70 0.000 -1.87469 -1.751505
------------------------------------------------------------------------------
. predict h1, hazard per (1000) ci
. predict s1, survival ci
.