Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Crude incidence rate straitfied by calendar year

    I have estimated the overall crude incidence rate of diabetes in people with hypertension (the study population) between 2010-2019.

    I used the following command to calculate the overall incidence rate: -stset enddate, failure(diabetes==1) enter(startdate) id(id) scale(365.25)-
    enddate = earliest of diabetes diagnosis, death, exit from database or 31st Dec 2019.
    startdate = date of first hypertension diagnosis

    I now would like to stratify the incidence rate by calendar year and produce a graph with calendar year on the x-axis and incidence rate per 1000 on the y-axis.

    I attempted to use the command: -stptime, by (startyear) per(100) dd(2)- where (startyear) is the year hypertension was diagnosed for each id. However, I do not think this is correct.

    I have done some reading and come across -stsplit- and -strate-. How would I go about stratifying incidence rate and graph it by calendar year? I've put a dummy example of my data below.

    Thank you.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str2 id byte diabetes int(startdate enddate) float survival_time
    "1"  0 19304 21816  6.877481
    "2"  0 20021 20973  2.606434
    "3"  0 18497 21796  9.032169
    "4"  0 18883 21762  7.882272
    "5"  1 20273 21209  2.562628
    "6"  0 18868 21803  8.035592
    "7"  1 18512 20755  6.140999
    "8"  0 19908 20408 1.3689255
    "9"  0 19547 20828  3.507187
    "10" 0 20409 20983 1.5715264
    "11" 1 19643 21817  5.952087
    "12" 0 21019 21638 1.6947297
    "13" 0 20614 21091 1.3059548
    "14" 1 19207 21817  7.145791
    "15" 0 20619 21817  3.279945
    "16" 1 18517 20078  4.273785
    "17" 0 19036 19591  1.519507
    "18" 0 19598 20752   3.15948
    "19" 1 20988 21628 1.7522244
    "20" 0 18713 21816  8.495551
    end
    format %td startdate
    format %td enddate

  • #2
    In case other statalist users are interested. I figured it out:

    After you -stset- your data:

    stsplit year, after(time = mdy(1,1,1960)) at(50(1)59)
    replace year = year+1960

    strate year, per(100) output("diabetes rate year.dta", replace)

    use "diabetes rate year.dta", clear
    twoway (rcap _Upper _Lower year if year, lcol(black) msym(o)) ///
    (connect _R year if year, lcol(black) msym(o) mcol(black) msize(medlarge)) ///
    , title("Incidence of Diabetes in Hypertensive Population") xtitle("Calendar Year") ///
    ytitle("Diabetes Incidence per 100 PYAR") ylab(0(1)15, gmin gmax format(%9.0f)) xlab(2010(1)2019) legend(off)


    Comment


    • #3
      Hi Statalist,

      If anyone knows how to graph the annual incidence by gender. I would appreciate being shown how. For example a connected line graph with the incidence reported by male, female and total (3 lines) on one graph...

      Comment

      Working...
      X