Announcement

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

  • Xtpoisson returning incorrect incidence rate ratios

    Hi stata masters here, I am working on an analysis but getting quite frustrated with xtpoisson. I am a new Stata user and I may be getting things wrong. I would love advice from someone here who is more familiar with xtpoisson. I am happy if anyone could point me to any mistake that I am making and how I should do things differently.

    I have attached a do file with an example of the dataset and the stata commands I am employing. I am also explaining the dataset and the trouble I am having here.

    So, I have a dataset in long format (panel) of patients (idz) who are at risk of developing diabetes (event) and are followed up over time. The baseline date is the date of recruitment into the cohort. The participants are observed at different time points and their treatment (tx) is recorded and updated (so it changes).In the original dataset, I have the visit date (date) on which participants are reviewed. There is no visit schedule and visits are unbalanced. I would like to determine the incidence rate ratios of the event by treatment participants are receiving (tx_c). idrec is the cumulative number of times the patient has been reviewed at each visit. id is just another group variable (idz group)

    I have been advised by colleagues to use snapspan to to Convert snapshot data to time-span data and determine person_years of follow-up and then determine the crude incidence rates (which I would also like to have).

    I then proceeded to stset the data and then used xtpoisson with random effects and pyfu as exposure time. However, the incidence rate ratios I am getting are discordant with the crude incidence rates. My thinking is that in unadjusted estimates, the incidence rate ratios should be almost equal (if not exactly similar) to the ratios of crude incidence rates; from my dataset, for example the ratio of incidence rates for tx_c==1 is 1.75, but xtpoisson gives me a ratio of 1.95.

    The codes and the data are also pasted below for quick reference .

    Thanks a lot,

    Dathan Byonanebye

    ------------------ Data code below this line ------------------

    clear
    input float(idrec idz id) int date byte(tx_c event gender)
    1 1 1 18997 4 0 0
    2 1 1 19134 4 0 0
    3 1 1 19148 4 0 0
    4 1 1 19269 4 0 0
    5 1 1 19283 4 0 0
    6 1 1 19442 4 0 0
    7 1 1 19454 4 0 0
    8 1 1 19589 4 0 0
    9 1 1 19591 4 0 0
    10 1 1 19688 4 0 0
    11 1 1 19759 4 0 0
    12 1 1 19801 4 0 0
    13 1 1 19857 4 0 0
    14 1 1 19907 4 0 0
    15 1 1 19920 4 0 0
    16 1 1 20170 4 0 0
    17 1 1 20433 4 0 0
    18 1 1 20438 4 0 0
    19 1 1 21029 4 0 0
    20 1 1 21049 4 0 0
    21 1 1 21098 4 0 0
    22 1 1 21175 4 0 0
    23 1 1 21194 4 0 0
    24 1 1 21339 4 0 0
    25 1 1 21409 4 0 0
    26 1 1 21525 2 1 0
    1 26 2 19137 4 0 1
    2 26 2 19149 4 0 1
    3 26 2 19330 4 0 1
    4 26 2 19340 4 0 1
    5 26 2 19505 4 0 1
    6 26 2 19515 4 0 1
    7 26 2 19688 4 0 1
    8 26 2 19701 4 0 1
    9 26 2 19865 4 0 1
    10 26 2 19876 4 0 1
    11 26 2 20047 4 0 1
    12 26 2 20243 4 0 1
    13 26 2 20422 4 0 1
    14 26 2 20611 4 0 1
    15 26 2 20789 4 0 1
    16 26 2 20965 4 0 1
    17 26 2 21152 4 0 1
    18 26 2 21334 4 0 1
    19 26 2 21515 4 0 1
    20 26 2 21700 4 0 1
    21 26 2 21886 4 0 1
    22 26 2 22137 4 0 1
    1 41 3 19074 4 0 1
    2 41 3 19100 4 0 1
    3 41 3 19101 4 0 1
    4 41 3 19227 4 0 1
    5 41 3 19240 4 0 1
    6 41 3 19367 4 0 1
    7 41 3 19387 4 0 1
    8 41 3 19492 4 0 1
    9 41 3 19506 4 0 1
    10 41 3 19584 4 0 1
    11 41 3 19646 4 0 1
    12 41 3 19730 4 0 1
    13 41 3 19744 4 0 1
    14 41 3 19824 4 0 1
    15 41 3 19845 4 0 1
    16 41 3 19870 4 0 1
    17 41 3 19877 4 0 1
    18 41 3 19884 4 0 1
    19 41 3 19949 4 0 1
    20 41 3 19975 4 0 1
    21 41 3 20090 4 0 1
    22 41 3 20102 4 0 1
    23 41 3 20188 4 0 1
    24 41 3 20206 4 0 1
    25 41 3 20299 4 0 1
    26 41 3 20390 4 0 1
    27 41 3 20523 4 0 1
    28 41 3 20697 4 0 1
    29 41 3 20871 4 0 1
    30 41 3 21039 4 0 1
    1 43 4 19491 1 1 0
    1 51 5 19051 4 0 1
    2 51 5 19061 4 0 1
    3 51 5 19159 4 0 1
    4 51 5 19180 4 0 1
    5 51 5 19302 4 0 1
    6 51 5 19320 4 0 1
    7 51 5 19430 4 0 1
    8 51 5 19446 4 0 1
    9 51 5 19543 4 0 1
    10 51 5 19597 4 0 1
    11 51 5 19695 4 1 1
    1 52 6 19066 4 0 1
    2 52 6 19081 4 0 1
    3 52 6 19262 4 0 1
    4 52 6 19277 4 0 1
    5 52 6 19451 4 0 1
    6 52 6 19466 4 0 1
    7 52 6 19613 4 0 1
    8 52 6 19641 4 0 1
    9 52 6 19795 4 0 1
    10 52 6 19809 4 0 1
    11 52 6 19810 4 0 1
    12 52 6 19837 4 0 1
    13 52 6 19855 4 0 1
    14 52 6 19998 4 0 1
    15 52 6 20012 4 0 1
    16 52 6 20158 4 0 1
    17 52 6 20173 4 0 1
    18 52 6 20354 4 0 1
    19 52 6 20544 4 0 1
    20 52 6 20732 4 0 1
    21 52 6 20929 4 0 1
    22 52 6 21090 4 0 1
    23 52 6 21298 4 0 1
    24 52 6 21412 4 1 1
    1 58 7 19059 4 0 0
    2 58 7 19152 4 0 0
    3 58 7 19241 4 0 0
    4 58 7 19257 4 0 0
    5 58 7 19410 4 0 0
    6 58 7 19600 4 0 0
    7 58 7 19614 4 0 0
    8 58 7 19775 4 0 0
    9 58 7 19961 4 0 0
    10 58 7 19971 4 0 0
    11 58 7 20132 4 0 0
    12 58 7 20326 4 0 0
    13 58 7 20438 4 0 0
    14 58 7 20676 4 0 0
    15 58 7 20803 4 0 0
    16 58 7 20937 4 0 0
    17 58 7 21088 4 0 0
    18 58 7 21252 4 0 0
    19 58 7 21476 4 0 0
    20 58 7 21564 2 0 0
    21 58 7 21657 2 0 0
    22 58 7 21797 2 0 0
    1 59 8 19108 2 0 1
    2 59 8 19120 2 0 1
    3 59 8 19284 2 0 1
    4 59 8 19344 2 0 1
    5 59 8 19492 2 0 1
    6 59 8 19505 2 0 1
    7 59 8 19638 2 0 1
    8 59 8 19652 2 0 1
    9 59 8 19761 2 0 1
    10 59 8 19771 2 0 1
    11 59 8 19856 2 0 1
    12 59 8 19869 2 0 1
    13 59 8 19992 2 0 1
    14 59 8 20107 2 0 1
    15 59 8 20191 2 0 1
    16 59 8 20198 2 0 1
    17 59 8 20314 2 0 1
    18 59 8 20355 4 0 1
    19 59 8 20461 4 0 1
    20 59 8 20566 4 0 1
    21 59 8 20727 4 0 1
    22 59 8 20884 4 0 1
    23 59 8 21129 4 0 1
    24 59 8 21284 4 0 1
    25 59 8 21424 4 0 1
    26 59 8 21546 4 0 1
    27 59 8 21617 4 0 1
    28 59 8 21691 3 0 1
    29 59 8 21819 3 0 1
    30 59 8 21844 3 0 1
    1 60 9 19232 2 0 0
    1 80 10 19128 4 0 1
    2 80 10 19312 4 1 1
    1 81 11 19015 4 0 0
    2 81 11 19040 4 0 0
    3 81 11 19134 4 0 0
    4 81 11 19145 4 0 0
    5 81 11 19148 4 0 0
    6 81 11 19149 4 0 0
    7 81 11 19150 4 0 0
    8 81 11 19151 4 0 0
    9 81 11 19184 4 0 0
    10 81 11 19191 4 0 0
    11 81 11 19264 4 0 0
    12 81 11 19267 4 0 0
    13 81 11 19310 4 0 0
    14 81 11 19320 4 0 0
    15 81 11 19456 4 0 0
    16 81 11 19467 4 0 0
    17 81 11 19590 4 0 0
    18 81 11 19607 4 0 0
    19 81 11 19750 4 0 0
    20 81 11 19761 4 0 0
    21 81 11 19913 4 0 0
    22 81 11 19926 4 0 0
    23 81 11 20094 4 0 0
    24 81 11 20304 4 0 0
    25 81 11 20515 4 0 0
    26 81 11 20690 4 0 0
    27 81 11 20884 4 0 0
    28 81 11 21073 4 0 0
    29 81 11 21293 4 0 0
    30 81 11 21461 4 0 0
    31 81 11 21634 4 0 0
    1 99 8 19108 2 0 1
    2 99 8 19120 3 0 1
    3 99 8 19284 3 0 1
    4 99 8 19344 3 0 1
    5 99 8 19492 2 0 1
    6 99 8 19505 2 0 1
    7 99 8 19638 2 0 1
    8 99 8 19652 2 0 1
    9 99 8 19761 2 0 1
    10 99 8 19771 2 0 1
    11 99 8 19856 2 0 1
    12 99 8 19869 2 0 1
    13 99 8 19992 2 0 1
    14 99 8 20107 2 0 1
    15 99 8 20191 1 0 1
    16 99 8 20198 1 0 1
    17 99 8 20314 1 0 1
    18 99 8 20355 1 0 1
    19 99 8 20461 1 0 1
    20 99 8 20566 1 0 1
    21 99 8 20727 1 0 1
    22 99 8 20884 1 0 1
    23 99 8 21129 1 0 1
    24 99 8 21284 1 0 1
    25 99 8 21424 1 0 1
    26 99 8 21546 1 0 1
    27 99 8 21617 1 0 1
    28 99 8 21691 1 0 1
    29 99 8 21819 1 0 1
    30 99 8 21844 1 1 1
    end

    format %td date
    label values tx_c tx_c
    label def tx_c 1 "Drug1+Drug2", modify
    label def tx_c 2 "Drug1+Placebo", modify
    label def tx_c 3 "Drug2+Placebo", modify
    label def tx_c 4 "Placebo+Placebo", modify
    label values event htn_event
    label def event 0 "No", modify
    label def event 1 "Yes", modify
    label values gender gender
    label def gender 0 "Female", modify
    label def gender 1 "Male", modify

    save orig_ds,replace

    //code for crude incidence rates

    *Snapspan the data ;
    snapspan id date event, generate(date0) replace
    generate pyfu=(date-date0)/365.25 /*There are blank pyfu for row 1 since date0 for row 1 is missisng after snapspan.*/
    sort idz
    gen fkid=_n /*This creates an ID, fkid that counts rows per id*/

    *Then stset
    stset pyfu, id(fkid) f(event==1)

    *Determine incidence rates by ART categories;
    stptime, by(tx_c) per(1000) dd(1)


    //code for incidence rates ratios using xtpoisson

    clear
    use orig_ds
    /*Use snapspan command to conver snapshot data for a given subject to time-span data required for use with survival analysis commands*/
    snapspan id date event, generate(date0) replace
    *generate follow-up periods (person days of follow-up),pyfu_htn
    generate pyfu = (date-date0)/365.25
    *There will be some blanks for row 1 that were created after spanning and these are now removed
    drop if pyfu ==.
    *xtset- will first create a cumulative count of patients by patient (idrec);
    sort idz date0
    bysort idz: gen fkid=_n
    *Now xtset;
    xtset id fkid
    *Determine unadjusted IRRs using random effects and poisson for panel data (xtpoisson);
    xtpoisson event ib4.tx_c, re irr exp(pyfu) cformat(%9.2f) nolog
    Attached Files

  • #2
    Hi Dathan, I hope your research is going well! Please tell me if I'm understanding: you are estimating incidence using a poisson model, comparing the incidence with your predicted variable, and are not coming up with the ratios that are comparable? You mention above the incidence rate for 'tx_c'. I get this is not an extremely helpful first comment, but I'd suggest looking through this command using
    Code:
    viewsource stptime.ado
    and perhaps there's a clear code fragment that would tell you how they arrived at this estimate, and what is different from the crude incidence rate.

    Researchers should expect their empirical estimates to differ from actual results. The extent to which they should differ is more a matter for statisticians and experts in your field. After considering this, have you perhaps identified some statistical tests you might do? Otherwise, is your aim to get the predicted values closer to the known incidence rates?

    Comment

    Working...
    X