Hi, first time poster, long-term reader. I hope this post meets the standards of the community.
I have single-entry time to event data and am trying to calculate SMRs at various intervals. Per the documentation, my strategy has been use stset and then using stptime with the smr() option. I’ve encountered several issues. (1)The first is that certain intervals entered using the required at() option return errors, but those same interval works as expected without the option. (2) When I use an interval that does not return an error using the smr() and at() options, the output does not include intervals that involve t 0. Likewise, these same intervals do return the expected output when not using the smr() option. I could calculate these using first principles, but I would strongly prefer not to. Thanks in advance, statalist! Examples below.
Below is the dataex for the master data
Below is the dataex for the using data
I have single-entry time to event data and am trying to calculate SMRs at various intervals. Per the documentation, my strategy has been use stset and then using stptime with the smr() option. I’ve encountered several issues. (1)The first is that certain intervals entered using the required at() option return errors, but those same interval works as expected without the option. (2) When I use an interval that does not return an error using the smr() and at() options, the output does not include intervals that involve t 0. Likewise, these same intervals do return the expected output when not using the smr() option. I could calculate these using first principles, but I would strongly prefer not to. Thanks in advance, statalist! Examples below.
Below is the dataex for the master data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double person_id float(xdate edate death age) 141519 23011 22800 0 3 81012 23011 22930 0 2 288182 23011 22490 0 3 26532 23011 22879 0 4 175078 23011 22530 0 1 86634 23011 22773 0 1 162747 23011 22086 0 3 9806 23011 22514 0 3 263603 23011 22718 0 2 126191 23011 22216 0 3 273175 23011 22642 0 3 104381 23011 22889 0 3 250159 23011 22451 0 3 126515 23011 22635 0 2 120638 23011 22651 0 2 193221 23011 22523 0 3 169955 23011 22755 0 3 4607 23011 22890 0 3 113375 23011 22815 0 1 177779 23011 22594 0 3 190823 22769 22295 1 2 3985 22821 22707 1 4 134368 22946 22937 1 1 132360 22866 22799 1 4 103874 22605 22019 1 4 281683 22987 22848 1 3 108042 22578 22091 1 4 167960 22933 22876 1 5 275741 22909 22117 1 3 172929 22674 22617 1 2 275467 22625 22172 1 4 120755 22182 22134 1 2 232857 22921 22565 1 3 231021 22376 22120 1 5 282788 22623 22396 1 5 89902 22661 22537 1 4 252220 22655 22516 1 1 174545 22965 22439 1 2 149541 22900 22873 1 3 153484 22265 22163 1 5 end format %td edate label values death lbl_deaht label def lbl_deaht 0 "Not Dead", modify label def lbl_deaht 1 "Dead", modify label values age AGE_SHORT label def AGE_SHORT 1 "18-24", modify label def AGE_SHORT 2 "25-34", modify label def AGE_SHORT 3 "35-44", modify label def AGE_SHORT 4 "45-54", modify label def AGE_SHORT 5 "55-84", modify
Below is the dataex for the using data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float age long gender str8 race float(D N rate) 1 1 "all" 4232 5398760 .0007838837 2 1 "all" 10722 8445804 .001269506 3 1 "all" 15305 7501596 .0020402325 4 1 "all" 28033 7328830 .003825031 5 1 "all" 254931 13886634 .018358013 end label values age AGE_SHORT label def AGE_SHORT 1 "18-24", modify label def AGE_SHORT 2 "25-34", modify label def AGE_SHORT 3 "35-44", modify label def AGE_SHORT 4 "45-54", modify label def AGE_SHORT 5 "55-84", modify label values gender gender2 label def gender2 1 "all", modify
Code:
*** ISSUE #1 *** . stset xdate, failure(death = 1) origin(edate) exit(time edate + 365.25) id(person_id) id: person_id failure event: death == 1 obs. time interval: (xdate[_n-1], xdate] exit on or before: time edate + 365.25 t for analysis: (time-origin) origin: time edate ------------------------------------------------------------------------------ 40 total observations 0 exclusions ------------------------------------------------------------------------------ 40 observations remaining, representing 40 subjects 14 failures in single-failure-per-subject data 9,576 total analysis time at risk and under observation at risk from t = 0 earliest observed entry t = 0 last observed exit t = 365.25 r; t=0.02 11:40:16 . stptime, at(0(7)14) trim failure _d: death == 1 analysis time _t: (xdate-origin) origin: time edate exit on or before: time edate + 365.25 id: person_id note: _group>14 trimmed Cohort | person-time failures rate [95% Conf. Interval] -----------+----------------------------------------------------------- (0 - 7]| 280 0 0 . . (7 - 14]| 275 1 .00363636 .0005122 .0258148 -----------+----------------------------------------------------------- total | 555 1 .0018018 .0002538 .0127911 r; t=0.06 11:40:16 . stptime,smr(age rate) using("working\sample_std_pop_test.dta") per(1) at(0(7)14) trim no observations merged, at() option not specified or incorrectly specified r(2000); t=0.02 11:40:16 . *** ISSUE #2 *** . stptime,smr(age rate) using("working\sample_std_pop_test.dta") per(1) at(0(5)14) trim failure _d: death == 1 analysis time _t: (xdate-origin) origin: time edate exit on or before: time edate + 365.25 id: person_id note: _group>10 trimmed | observed expected Cohort | person-time failures failures SMR [95% Conf. Interval] -----------+------------------------------------------------------------------- (5 - 10]| 199 1 3.65324 .27373 .0385585 1.943224 -----------+------------------------------------------------------------------- total | 199 1 3.65324 .27373 .0385585 1.943224 r; t=0.11 11:40:54 . stptime, at(0(5)14) trim failure _d: death == 1 analysis time _t: (xdate-origin) origin: time edate exit on or before: time edate + 365.25 id: person_id note: _group>10 trimmed Cohort | person-time failures rate [95% Conf. Interval] -----------+----------------------------------------------------------- (0 - 5]| 200 0 0 . . (5 - 10]| 199 1 .00502513 .0007079 .0356737 -----------+----------------------------------------------------------- total | 399 1 .00250627 .000353 .0177922 r; t=0.05 11:40:54 . end of do-file
Comment