Dear all
Still working on my Stata skills and very grateful for this forum!
I working on estimating the diabetes incidence rate (cases per person-years) over four periods using Poisson regression models with log person-years as offset and the follow-up person cut into 1-year age bands. The four periods; 2001-2005; 2005-2009; 2009-2013; 2013-2017. It a open cohort with both left and right censoring.
I have set up the data using stset and stsplit for followup time, age and calendar year:
My first problem arises when I want to compare the incidence rates across two years as I get two quite different IRR if I include year_split (calendar year) or not:
My second problem arises when I want to look at the incidence rate ratio by sex:
Kind regards
Jannie
Still working on my Stata skills and very grateful for this forum!
I working on estimating the diabetes incidence rate (cases per person-years) over four periods using Poisson regression models with log person-years as offset and the follow-up person cut into 1-year age bands. The four periods; 2001-2005; 2005-2009; 2009-2013; 2013-2017. It a open cohort with both left and right censoring.
I have set up the data using stset and stsplit for followup time, age and calendar year:
Code:
svyset ER31997 [pweight = SW], singleunit(scaled) strata(ER31996) stset FUT_overall, id(id) failure(DM==1) stsplit splitime, every(1) gen FUT_split = _t - _t0 gen age_split = Age + _t0 gen logtimerisk = ln(FUT_split) gen year_split = year +_t0
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id int year byte sex float ER31996 byte ER31997 float(Age DM FUT_overall SW) byte splitime float(FUT_split age_split logtimerisk year_split) byte(_st _d) double _t byte _t0 1 2005 1 31 2 49.32494 . 1 17082.857 0 1 49.32494 0 2005 1 0 1 0 1 2005 1 31 2 49.32494 . 2 17082.857 1 1 50.32494 0 2006 1 0 2 1 1 2005 1 31 2 49.32494 . 3 17082.857 2 1 51.32494 0 2007 1 0 3 2 1 2005 1 31 2 49.32494 1 3.057648 17082.857 3 .0576477 52.32494 -2.853405 2008 1 1 3.057647705078125 3 2 2013 1 31 2 57.35999 . 1 17082.857 0 1 57.35999 0 2013 1 0 1 0 2 2013 1 31 2 57.35999 0 1.971794 17082.857 1 .9717941 58.35999 -.0286113 2014 1 0 1.9717941284179688 1 3 2005 2 31 2 47.84883 . 1 21386.875 0 1 47.84883 0 2005 1 0 1 0 3 2005 2 31 2 47.84883 . 2 21386.875 1 1 48.84883 0 2006 1 0 2 1 3 2005 2 31 2 47.84883 . 3 21386.875 2 1 49.84883 0 2007 1 0 3 2 3 2005 2 31 2 47.84883 0 3.7354546 21386.875 3 .7354546 50.84883 -.3072665 2008 1 0 3.735454559326172 3 4 2009 2 31 2 51.58428 . 1 21386.875 0 1 51.58428 0 2009 1 0 1 0 4 2009 2 31 2 51.58428 . 2 21386.875 1 1 52.58428 0 2010 1 0 2 1 4 2009 2 31 2 51.58428 . 3 21386.875 2 1 53.58428 0 2011 1 0 3 2 4 2009 2 31 2 51.58428 . 4 21386.875 3 1 54.58428 0 2012 1 0 4 3 4 2009 2 31 2 51.58428 0 4.012047 21386.875 4 .012046814 55.58428 -4.418955 2013 1 0 4.012046813964844 4 5 2013 2 31 2 55.59633 . 1 21386.875 0 1 55.59633 0 2013 1 0 1 0 5 2013 2 31 2 55.59633 . 2 21386.875 1 1 56.59633 0 2014 1 0 2 1 5 2013 2 31 2 55.59633 . 3 21386.875 2 1 57.59633 0 2015 1 0 3 2 5 2013 2 31 2 55.59633 . 4 21386.875 3 1 58.59633 0 2016 1 0 4 3 5 2013 2 31 2 55.59633 0 4.2694817 21386.875 4 .26948166 59.59633 -1.311255 2017 1 0 4.269481658935547 4 6 2005 2 31 2 45.58127 . 1 7963.667 0 1 45.58127 0 2005 1 0 1 0 6 2005 2 31 2 45.58127 . 2 7963.667 1 1 46.58127 0 2006 1 0 2 1 6 2005 2 31 2 45.58127 0 2.1224136 7963.667 2 .12241364 47.58127 -2.1003494 2007 1 0 2.1224136352539063 2 7 2009 2 31 2 47.30933 . 1 26118.1 0 1 47.30933 0 2009 1 0 1 0 7 2009 2 31 2 47.30933 . 2 26118.1 1 1 48.30933 0 2010 1 0 2 1 7 2009 2 31 2 47.30933 . 3 26118.1 2 1 49.30933 0 2011 1 0 3 2 7 2009 2 31 2 47.30933 0 3.951801 26118.1 3 .9518013 50.30933 -.04939898 2012 1 0 3.951801300048828 3 8 2013 2 31 2 51.26113 . 1 26118.1 0 1 51.26113 0 2013 1 0 1 0 8 2013 2 31 2 51.26113 . 2 26118.1 1 1 52.26113 0 2014 1 0 2 1 8 2013 2 31 2 51.26113 . 3 26118.1 2 1 53.26113 0 2015 1 0 3 2 8 2013 2 31 2 51.26113 . 4 26118.1 3 1 54.26113 0 2016 1 0 4 3 8 2013 2 31 2 51.26113 0 4.5734596 26118.1 4 .5734596 55.26113 -.55606776 2017 1 0 4.573459625244141 4 9 2017 2 31 2 55.83459 . 1 26118.1 0 1 55.83459 0 2017 1 0 1 0 9 2017 2 31 2 55.83459 . 2 26118.1 1 1 56.83459 0 2018 1 0 2 1 9 2017 2 31 2 55.83459 . 3 26118.1 2 1 57.83459 0 2019 1 0 3 2 9 2017 2 31 2 55.83459 0 3.510887 26118.1 3 .51088715 58.83459 -.6716065 2020 1 0 3.5108871459960938 3 10 2005 2 31 2 41.39121 . 1 26216.125 0 1 41.39121 0 2005 1 0 1 0 10 2005 2 31 2 41.39121 . 2 26216.125 1 1 42.39121 0 2006 1 0 2 1 10 2005 2 31 2 41.39121 . 3 26216.125 2 1 43.39121 0 2007 1 0 3 2 10 2005 2 31 2 41.39121 0 3.7628365 26216.125 3 .7628365 44.39121 -.2707116 2008 1 0 3.762836456298828 3 11 2009 2 31 2 45.15405 . 1 26216.125 0 1 45.15405 0 2009 1 0 1 0 11 2009 2 31 2 45.15405 . 2 26216.125 1 1 46.15405 0 2010 1 0 2 1 11 2009 2 31 2 45.15405 . 3 26216.125 2 1 47.15405 0 2011 1 0 3 2 11 2009 2 31 2 45.15405 0 3.776531 26216.125 3 .7765312 48.15405 -.25291842 2012 1 0 3.776531219482422 3 12 2013 2 31 2 48.93058 . 1 26216.125 0 1 48.93058 0 2013 1 0 1 0 12 2013 2 31 2 48.93058 . 2 26216.125 1 1 49.93058 0 2014 1 0 2 1 12 2013 2 31 2 48.93058 . 3 26216.125 2 1 50.93058 0 2015 1 0 3 2 12 2013 2 31 2 48.93058 . 4 26216.125 3 1 51.93058 0 2016 1 0 4 3 12 2013 2 31 2 48.93058 0 4.5734634 26216.125 4 .57346344 52.93058 -.5560611 2017 1 0 4.573463439941406 4 13 2017 2 31 2 53.50404 . 1 26216.125 0 1 53.50404 0 2017 1 0 1 0 13 2017 2 31 2 53.50404 . 2 26216.125 1 1 54.50404 0 2018 1 0 2 1 13 2017 2 31 2 53.50404 . 3 26216.125 2 1 55.50404 0 2019 1 0 3 2 13 2017 2 31 2 53.50404 0 3.990139 26216.125 3 .990139 56.50404 -.009909934 2020 1 0 3.9901390075683594 3 14 2005 1 31 2 36.346706 . 1 13876 0 1 36.346706 0 2005 1 0 1 0 14 2005 1 31 2 36.346706 . 2 13876 1 1 37.346706 0 2006 1 0 2 1 14 2005 1 31 2 36.346706 . 3 13876 2 1 38.34671 0 2007 1 0 3 2 14 2005 1 31 2 36.346706 0 3.705326 13876 3 .7053261 39.34671 -.34909505 2008 1 0 3.7053260803222656 3 15 2009 1 31 2 40.05203 . 1 13876 0 1 40.05203 0 2009 1 0 1 0 15 2009 1 31 2 40.05203 . 2 13876 1 1 41.05203 0 2010 1 0 2 1 15 2009 1 31 2 40.05203 . 3 13876 2 1 42.05203 0 2011 1 0 3 2 15 2009 1 31 2 40.05203 . 4 13876 3 1 43.05203 0 2012 1 0 4 3 15 2009 1 31 2 40.05203 0 4.611805 13876 4 .611805 44.05203 -.4913417 2013 1 0 4.611804962158203 4 16 2013 1 31 2 44.66384 . 1 13876 0 1 44.66384 0 2013 1 0 1 0 16 2013 1 31 2 44.66384 0 1.4733658 13876 1 .4733658 45.66384 -.7478868 2014 1 0 1.4733657836914063 1 17 2005 2 31 2 27.583185 . 1 13071.7 0 1 27.583185 0 2005 1 0 1 0 17 2005 2 31 2 27.583185 . 2 13071.7 1 1 28.583185 0 2006 1 0 2 1 17 2005 2 31 2 27.583185 . 3 13071.7 2 1 29.583185 0 2007 1 0 3 2 17 2005 2 31 2 27.583185 . 4 13071.7 3 1 30.583185 0 2008 1 0 4 3 17 2005 2 31 2 27.583185 0 4.0449123 13071.7 4 .04491234 31.583185 -3.103043 2009 1 0 4.044912338256836 4 18 2009 2 31 2 31.6281 . 1 13071.7 0 1 31.6281 0 2009 1 0 1 0 18 2009 2 31 2 31.6281 . 2 13071.7 1 1 32.628098 0 2010 1 0 2 1 18 2009 2 31 2 31.6281 1 2.9891815 13071.7 2 .9891815 33.628098 -.010877427 2011 1 1 2.9891815185546875 2 19 2005 1 31 2 26.463097 . 1 16000 0 1 26.463097 0 2005 1 0 1 0 19 2005 1 31 2 26.463097 . 2 16000 1 1 27.463097 0 2006 1 0 2 1 19 2005 1 31 2 26.463097 . 3 16000 2 1 28.463097 0 2007 1 0 3 2 19 2005 1 31 2 26.463097 0 3.729975 16000 3 .7299747 29.463097 -.3147453 2008 1 0 3.7299747467041016 3 20 2009 1 31 2 30.19307 . 1 16000 0 1 30.19307 0 2009 1 0 1 0 20 2009 1 31 2 30.19307 . 2 16000 1 1 31.19307 0 2010 1 0 2 1 20 2009 1 31 2 30.19307 . 3 16000 2 1 32.19307 0 2011 1 0 3 2 20 2009 1 31 2 30.19307 . 4 16000 3 1 33.19307 0 2012 1 0 4 3 20 2009 1 31 2 30.19307 0 4.1982746 16000 4 .1982746 34.19307 -1.6181023 2013 1 0 4.198274612426758 4 21 2005 1 31 2 25.55662 . 1 8697.875 0 1 25.55662 0 2005 1 0 1 0 21 2005 1 31 2 25.55662 . 2 8697.875 1 1 26.55662 0 2006 1 0 2 1 21 2005 1 31 2 25.55662 . 3 8697.875 2 1 27.55662 0 2007 1 0 3 2 21 2005 1 31 2 25.55662 0 3.740929 8697.875 3 .7409286 28.55662 -.2998509 2008 1 0 3.7409286499023438 3 22 2009 1 31 2 29.29755 . 1 8697.875 0 1 29.29755 0 2009 1 0 1 0 22 2009 1 31 2 29.29755 1 1.0119114 8697.875 1 .011911392 30.29755 -4.43026 2010 1 1 1.011911392211914 1 23 2017 1 31 2 37.844723 . 1 8697.875 0 1 37.844723 0 2017 1 0 1 0 23 2017 1 31 2 37.844723 . 2 8697.875 1 1 38.84472 0 2018 1 0 2 1 23 2017 1 31 2 37.844723 1 2.889221 8697.875 2 .8892212 39.84472 -.11740927 2019 1 1 2.88922119140625 2 24 2005 1 31 2 24.87197 . 1 11872.5 0 1 24.87197 0 2005 1 0 1 0 24 2005 1 31 2 24.87197 . 2 11872.5 1 1 25.87197 0 2006 1 0 2 1 24 2005 1 31 2 24.87197 . 3 11872.5 2 1 26.87197 0 2007 1 0 3 2 24 2005 1 31 2 24.87197 . 4 11872.5 3 1 27.87197 0 2008 1 0 4 3 24 2005 1 31 2 24.87197 0 4.064083 11872.5 4 .0640831 28.87197 -2.7475746 2009 1 0 4.064083099365234 4 25 2009 1 31 2 28.936054 . 1 11872.5 0 1 28.936054 0 2009 1 0 1 0 25 2009 1 31 2 28.936054 . 2 11872.5 1 1 29.936054 0 2010 1 0 2 1 25 2009 1 31 2 28.936054 . 3 11872.5 2 1 30.936054 0 2011 1 0 3 2 25 2009 1 31 2 28.936054 . 4 11872.5 3 1 31.936054 0 2012 1 0 4 3 25 2009 1 31 2 28.936054 0 4.0093117 11872.5 4 .009311676 32.936054 -4.676486 2013 1 0 4.009311676025391 4 end label values sex sex2 label def sex2 1 "male", modify label def sex2 2 "female", modify
My first problem arises when I want to compare the incidence rates across two years as I get two quite different IRR if I include year_split (calendar year) or not:
Code:
* Age, sex and calenderyear adjusted * without calendaryear svy: poisson _d i.year i.sex age_split, offset(logtimerisk) margins, over(year) expression(predict(n)/FUT_split) nlcom exp(_b[2017.year] - _b[2005.year]) /*1,166*/ * with calendaryear [year_split] svy: poisson _d i.year i.sex age_split year_split, offset(logtimerisk) margins, over(year) expression(predict(n)/FUT_split) nlcom exp(_b[2017.year] - _b[2005.year]) /*2,554*/
Code:
svy: poisson _d i.year i.sex age_split year_split, offset(logtimerisk) margins, over(year sex) expression(predict(n)/FUT_split) nlcom exp(_b[2017.year##1.sex] - _b[2005.year##1.sex]) /*invalid matrix stripe;/
Jannie
Comment