# jh 2015.11.13 # Data used in Albertsen et al. JAMA 2005. # Gleason score ( 2, least aggressive, to 10, most aggressive) # age at diagnosis, # when (no. years post diagnosis) when follow up was terminated, and # why (1= because men died, 0 because man still alive when anaysis was done) # and (if dead), cause of death : # 1=Pr ca, 222 instances # 2=Other causes, 470 instances # 3=Cause not known, 25 instances # or # 0=not applicable (man still alive at time of analysis) x=scan() 2 57 11.1 1 2 2 59 16.9 1 2 2 59 22.0 1 2 2 58 19.7 0 0 2 63 26.3 1 2 2 63 23.3 0 0 2 62 15.0 1 3 2 63 21.6 0 0 2 64 3.8 1 2 2 63 10.4 1 2 2 63 8.0 1 2 2 63 12.4 1 2 2 62 12.6 1 2 2 63 20.2 0 0 2 64 27.1 0 0 2 63 19.8 0 0 2 69 7.1 1 1 2 69 4.8 1 2 2 69 4.1 1 1 2 66 17.6 1 3 2 67 9.3 1 2 2 69 15.8 1 2 2 68 12.6 1 2 2 69 11.1 1 1 2 68 3.4 1 2 2 68 19.7 0 0 2 67 2.7 1 2 2 65 8.5 1 2 2 73 9.0 1 2 2 73 20.8 1 3 2 70 14.1 1 2 2 72 1.8 1 2 2 74 1.6 1 2 2 74 10.7 1 1 2 72 13.0 1 2 2 73 19.9 0 0 2 72 23.0 1 2 2 74 16.9 1 1 2 72 10.8 1 2 2 72 18.1 1 2 2 70 1.2 1 2 2 71 21.4 1 2 2 72 13.6 1 2 3 59 25.6 0 0 3 58 17.3 1 2 3 58 20.3 1 2 3 62 13.8 1 2 3 62 16.1 1 2 3 64 14.4 1 2 3 64 16.3 1 2 3 64 16.9 1 2 3 64 15.1 1 2 3 62 20.6 0 0 3 63 4.5 1 2 3 69 1.0 1 2 3 68 23.0 0 0 3 66 8.4 1 2 3 67 3.5 1 2 3 65 20.3 1 2 3 65 8.6 1 2 3 65 4.7 1 2 3 67 3.7 1 2 3 69 6.3 1 2 3 66 24.5 0 0 3 68 22.2 1 2 3 67 9.1 1 2 3 68 13.6 1 2 3 69 2.6 1 2 3 69 16.0 1 2 3 66 9.2 1 2 3 66 2.8 1 2 3 70 8.8 1 2 3 72 18.0 1 2 3 70 1.3 1 1 3 72 0.8 1 2 3 70 15.6 1 2 3 71 7.0 1 2 3 70 0.8 1 1 3 72 13.8 1 2 3 70 19.0 1 2 3 73 19.8 1 2 3 70 6.8 1 2 3 74 3.3 1 2 3 71 5.7 1 2 4 59 5.6 1 2 4 59 3.9 1 2 4 57 8.7 1 2 4 59 22.7 0 0 4 64 21.3 1 2 4 62 20.4 1 3 4 64 26.5 1 2 4 62 14.2 1 2 4 64 5.3 1 2 4 62 15.7 1 2 4 64 7.2 1 2 4 64 19.7 1 1 4 61 27.6 1 2 4 64 23.3 0 0 4 62 14.0 1 2 4 62 17.3 1 2 4 63 17.2 1 2 4 60 14.0 1 2 4 61 21.0 1 2 4 67 17.8 0 0 4 69 22.2 1 2 4 65 16.3 1 2 4 68 0.7 1 2 4 67 19.3 1 2 4 68 5.5 1 2 4 68 11.5 1 3 4 65 19.6 0 0 4 65 5.2 1 2 4 65 20.6 1 2 4 67 19.0 1 2 4 69 5.8 1 2 4 68 3.8 1 2 4 73 13.2 1 3 4 73 15.5 1 2 4 73 1.3 1 1 4 70 3.0 1 2 4 70 4.7 1 2 4 72 9.1 1 1 4 72 11.9 1 2 4 72 18.6 1 3 4 74 3.6 1 2 4 70 17.5 1 2 4 74 18.9 0 0 4 72 4.0 1 2 4 74 12.6 1 2 4 70 20.8 1 2 4 73 12.1 1 2 4 72 21.3 1 3 4 70 19.8 1 2 4 72 11.1 1 2 4 71 2.6 1 2 4 70 18.3 1 2 4 70 6.6 1 2 4 74 1.6 1 2 5 58 22.5 1 2 5 59 19.4 0 0 5 59 27.1 1 2 5 59 17.8 1 3 5 59 21.0 1 2 5 59 16.7 0 0 5 56 19.7 0 0 5 59 28.1 1 1 5 60 15.6 1 2 5 62 22.6 1 2 5 61 30.1 1 2 5 60 16.8 1 2 5 62 28.0 1 2 5 60 16.9 1 2 5 62 20.6 0 0 5 60 4.3 1 2 5 63 19.5 0 0 5 61 11.9 1 2 5 63 3.9 1 2 5 64 27.7 1 1 5 60 21.0 0 0 5 63 12.1 1 2 5 64 12.6 1 1 5 61 0.9 1 1 5 63 11.7 1 2 5 61 5.2 1 2 5 62 14.9 1 2 5 61 24.0 1 2 5 64 22.0 0 0 5 61 21.6 1 3 5 60 7.7 1 2 5 61 2.5 1 2 5 67 4.3 1 1 5 69 8.4 1 2 5 69 10.5 1 1 5 65 23.6 0 0 5 67 7.4 1 1 5 67 7.0 1 2 5 66 20.0 1 2 5 65 5.2 1 2 5 68 19.7 0 0 5 67 26.3 1 2 5 68 6.5 1 2 5 68 19.0 1 2 5 65 8.3 1 2 5 69 9.9 1 2 5 65 9.5 1 2 5 67 18.3 1 2 5 68 3.6 1 2 5 67 20.1 1 2 5 66 4.6 1 2 5 65 17.6 1 2 5 67 10.1 1 2 5 69 19.6 1 2 5 67 22.7 0 0 5 65 21.5 0 0 5 65 15.0 1 2 5 66 6.6 1 2 5 69 1.3 1 1 5 69 7.9 1 2 5 69 2.9 1 2 5 69 19.9 1 1 5 67 18.9 1 2 5 69 9.5 1 2 5 67 13.0 1 2 5 66 0.4 1 2 5 66 8.4 1 2 5 65 11.9 1 2 5 69 2.4 1 2 5 68 23.1 1 1 5 68 6.7 1 2 5 68 10.4 1 2 5 65 6.5 1 3 5 65 17.8 1 2 5 67 13.4 1 2 5 70 10.8 1 2 5 73 10.4 1 2 5 70 4.9 1 2 5 73 8.4 1 1 5 74 12.1 1 2 5 74 9.3 1 2 5 74 11.4 1 2 5 74 12.6 1 2 5 73 19.7 0 0 5 71 6.8 1 2 5 73 4.6 1 2 5 72 4.8 1 2 5 70 9.6 1 1 5 72 2.5 1 1 5 70 9.4 1 2 5 74 5.4 1 2 5 74 6.9 1 2 5 70 4.2 1 2 5 74 0.8 1 2 5 70 7.8 1 2 5 74 6.4 1 2 5 73 7.6 1 2 5 72 2.3 1 3 5 71 8.9 1 2 5 70 15.2 1 2 5 74 9.1 1 1 5 70 9.4 1 1 5 72 10.0 1 2 5 74 18.6 1 2 5 73 5.9 1 2 5 72 10.7 1 2 5 73 4.4 1 2 5 71 7.1 1 1 5 72 6.9 1 2 5 72 1.5 1 2 5 70 5.8 1 2 5 71 12.5 1 2 5 73 16.9 1 2 5 73 1.1 1 2 5 72 6.5 1 2 5 74 4.4 1 2 5 73 10.9 1 2 5 74 3.1 1 2 6 56 0.6 1 2 6 59 2.1 1 2 6 57 23.8 0 0 6 59 25.1 0 0 6 59 22.5 1 2 6 58 15.9 0 0 6 59 25.2 1 2 6 55 0.9 1 2 6 59 2.8 1 2 6 56 28.7 0 0 6 55 23.2 0 0 6 55 21.6 1 2 6 59 7.8 1 1 6 58 24.2 0 0 6 58 26.3 0 0 6 59 6.1 1 2 6 55 14.8 1 1 6 55 7.9 1 2 6 58 3.4 1 2 6 59 1.7 1 1 6 58 25.1 0 0 6 58 27.0 0 0 6 57 1.5 1 1 6 55 2.1 1 1 6 59 6.7 1 2 6 60 25.4 0 0 6 64 8.2 1 2 6 63 0.2 1 2 6 64 2.6 1 1 6 64 19.0 1 2 6 63 13.0 1 2 6 63 14.2 1 2 6 60 10.9 1 1 6 63 26.4 1 3 6 63 5.4 1 3 6 61 4.4 1 1 6 64 7.6 1 1 6 60 3.4 1 1 6 61 3.3 1 1 6 63 25.4 1 2 6 60 7.7 1 2 6 61 14.1 1 2 6 61 22.3 0 0 6 64 12.0 1 2 6 64 24.3 1 2 6 61 23.3 1 2 6 63 27.8 0 0 6 61 8.0 1 1 6 63 1.1 1 1 6 60 1.3 1 2 6 61 17.8 1 2 6 60 21.4 1 2 6 63 26.3 1 2 6 60 7.2 1 1 6 63 7.5 1 2 6 60 5.4 1 2 6 64 4.7 1 2 6 64 1.9 1 1 6 64 23.0 0 0 6 63 13.8 1 1 6 63 13.1 1 2 6 62 9.7 1 1 6 64 25.4 1 2 6 61 15.5 1 2 6 62 17.8 1 2 6 60 4.9 1 2 6 63 25.1 1 1 6 64 7.8 1 2 6 61 7.9 1 2 6 60 24.5 0 0 6 65 6.8 1 2 6 67 4.5 1 2 6 69 9.9 1 2 6 68 4.2 1 2 6 65 5.4 1 1 6 67 25.9 0 0 6 66 1.8 1 2 6 67 12.7 1 3 6 68 24.6 1 2 6 69 8.8 1 2 6 68 6.9 1 1 6 65 1.9 1 1 6 69 7.8 1 2 6 68 4.5 1 2 6 68 2.7 1 2 6 65 10.5 1 2 6 69 3.0 1 2 6 69 6.6 1 2 6 66 4.9 1 1 6 68 4.6 1 2 6 69 7.5 1 1 6 69 15.5 1 2 6 65 11.7 1 2 6 69 4.8 1 2 6 65 21.5 1 2 6 67 5.3 1 2 6 66 26.3 1 2 6 69 3.6 1 1 6 67 10.5 1 1 6 67 19.0 0 0 6 67 5.8 1 2 6 68 13.3 1 2 6 67 17.7 1 1 6 68 13.9 1 1 6 67 20.4 0 0 6 68 12.6 1 2 6 69 7.9 1 2 6 69 9.6 1 2 6 66 9.0 1 2 6 68 18.8 0 0 6 68 12.8 1 1 6 69 9.2 1 2 6 69 4.4 1 1 6 69 1.7 1 1 6 65 5.8 1 2 6 67 15.7 1 2 6 69 4.0 1 2 6 69 3.1 1 2 6 69 14.0 1 2 6 65 25.0 1 2 6 68 13.4 1 1 6 68 12.6 1 2 6 66 10.4 1 1 6 69 4.3 1 2 6 67 9.4 1 3 6 66 10.2 1 2 6 68 3.5 1 1 6 67 5.5 1 2 6 68 7.6 1 2 6 68 12.2 1 2 6 66 13.9 1 1 6 69 3.8 1 2 6 67 5.5 1 1 6 66 2.8 1 2 6 67 10.1 1 2 6 68 2.7 1 1 6 67 8.4 1 1 6 68 5.4 1 1 6 66 12.0 1 2 6 65 6.4 1 1 6 65 18.2 1 1 6 66 18.3 1 2 6 65 6.6 1 2 6 66 7.2 1 1 6 67 15.0 1 3 6 67 16.6 1 2 6 68 13.0 1 2 6 66 11.8 1 2 6 67 9.3 1 2 6 65 23.9 1 2 6 69 19.8 1 2 6 69 2.4 1 2 6 66 7.1 1 1 6 69 8.8 1 2 6 74 7.9 1 2 6 74 4.4 1 2 6 72 6.6 1 2 6 73 7.1 1 2 6 73 4.2 1 1 6 71 3.6 1 1 6 72 5.7 1 2 6 74 17.8 1 2 6 71 14.6 1 2 6 73 1.1 1 2 6 74 8.3 1 2 6 72 14.6 1 2 6 74 7.0 1 2 6 74 9.1 1 2 6 70 8.9 1 1 6 72 19.0 1 2 6 74 0.7 1 2 6 71 8.5 1 1 6 73 3.3 1 2 6 73 1.9 1 1 6 73 1.2 1 2 6 73 7.8 1 2 6 73 4.7 1 2 6 70 11.5 1 2 6 70 8.3 1 1 6 72 14.6 1 1 6 72 3.8 1 1 6 72 1.3 1 2 6 73 13.2 1 1 6 74 20.6 1 2 6 72 8.4 1 2 6 70 3.8 1 2 6 73 10.4 1 2 6 70 6.2 1 1 6 71 6.9 1 2 6 73 6.7 1 1 6 70 5.6 1 2 6 72 6.4 1 2 6 72 5.3 1 2 6 71 7.2 1 2 6 73 4.0 1 2 6 74 1.2 1 2 6 70 0.3 1 2 6 72 0.6 1 2 6 74 4.5 1 2 6 70 9.7 1 3 6 74 3.9 1 2 6 74 11.2 1 1 6 72 15.0 1 2 6 71 17.2 1 2 6 70 7.4 1 1 6 72 3.8 1 2 6 71 8.4 1 2 6 71 4.5 1 2 6 73 0.4 1 2 6 72 8.1 1 2 6 71 18.4 1 2 6 70 13.8 1 1 6 71 7.8 1 2 6 71 7.9 1 1 6 71 1.0 1 2 6 70 1.9 1 2 6 70 7.4 1 2 6 73 6.1 1 2 6 71 15.8 1 2 6 74 3.4 1 2 6 73 2.3 1 2 6 70 6.4 1 2 6 72 1.5 1 2 6 74 14.2 1 2 6 70 5.8 1 1 6 74 17.1 1 1 6 72 7.3 1 2 6 70 9.9 1 2 6 70 20.8 1 1 6 73 4.6 1 2 6 73 9.9 1 3 6 73 3.5 1 2 6 73 8.1 1 1 6 71 8.3 1 2 6 71 9.9 1 1 6 74 0.5 1 1 6 70 4.9 1 1 6 72 1.8 1 2 6 70 9.8 1 1 6 74 2.5 1 2 6 73 12.1 1 2 6 70 5.7 1 1 6 72 15.8 1 2 6 70 17.3 1 2 6 72 2.4 1 2 6 74 14.2 1 1 6 72 9.2 1 3 6 71 3.6 1 1 6 71 10.1 1 2 6 70 0.8 1 2 6 73 10.7 1 2 6 70 8.0 1 2 6 72 10.1 1 2 6 72 9.4 1 2 6 74 2.2 1 2 6 71 4.6 1 2 6 74 9.0 1 1 6 73 1.4 1 1 6 74 3.1 1 2 6 70 7.8 1 2 6 73 9.5 1 2 6 74 1.2 1 2 6 73 4.0 1 1 6 73 2.7 1 1 6 73 4.6 1 2 6 74 9.4 1 2 6 73 4.5 1 1 6 73 10.9 1 2 6 74 1.2 1 1 6 74 1.4 1 2 6 70 2.4 1 2 6 72 1.8 1 2 6 74 6.0 1 2 6 73 10.8 1 2 6 72 6.1 1 2 6 72 0.7 1 2 6 70 10.3 1 2 6 72 10.5 1 1 6 70 9.9 1 1 6 71 1.0 1 2 6 70 8.4 1 2 6 71 3.9 1 2 6 73 4.3 1 2 6 71 1.2 1 2 6 73 14.1 1 2 6 73 13.0 1 2 6 74 4.4 1 2 6 71 14.2 1 1 6 70 4.5 1 2 6 70 12.7 1 1 6 73 6.7 1 2 6 71 11.7 1 1 6 72 2.9 1 1 6 70 8.2 1 1 7 59 22.5 1 3 7 59 4.8 1 1 7 55 5.2 1 1 7 59 20.4 1 2 7 59 12.5 1 1 7 59 12.9 1 2 7 56 1.8 1 1 7 58 7.2 1 3 7 63 14.2 1 1 7 63 15.5 1 1 7 64 23.0 0 0 7 64 6.7 1 1 7 64 0.7 1 2 7 64 4.6 1 1 7 61 3.0 1 1 7 64 8.9 1 1 7 62 5.1 1 1 7 63 12.2 1 1 7 61 4.2 1 1 7 61 10.1 1 1 7 63 6.9 1 1 7 62 16.7 1 2 7 61 4.0 1 1 7 62 2.6 1 1 7 61 12.1 1 1 7 64 6.6 1 1 7 64 11.2 1 1 7 61 8.0 1 1 7 64 12.4 1 2 7 63 4.1 1 1 7 68 12.8 1 1 7 67 3.2 1 2 7 67 0.9 1 2 7 67 8.8 1 1 7 68 2.9 1 2 7 66 3.6 1 1 7 65 6.2 1 1 7 65 2.7 1 2 7 67 7.9 1 2 7 69 15.5 1 2 7 68 5.5 1 2 7 69 7.1 1 2 7 66 9.1 1 1 7 66 8.0 1 2 7 69 2.6 1 2 7 68 2.5 1 1 7 69 9.5 1 2 7 65 7.3 1 2 7 68 6.5 1 2 7 69 8.2 1 1 7 65 3.7 1 2 7 68 15.9 1 2 7 67 10.7 1 1 7 67 12.3 1 2 7 67 0.9 1 2 7 66 2.4 1 2 7 67 5.8 1 2 7 69 15.2 1 2 7 69 6.4 1 2 7 69 6.1 1 2 7 66 6.6 1 2 7 69 5.1 1 1 7 68 9.0 1 2 7 65 2.3 1 1 7 69 1.3 1 2 7 69 3.0 1 1 7 66 10.1 1 2 7 68 2.3 1 1 7 69 5.7 1 1 7 66 6.9 1 2 7 68 16.6 1 1 7 69 11.0 1 2 7 69 2.5 1 2 7 73 0.1 1 2 7 74 15.9 1 2 7 73 8.7 1 2 7 74 2.5 1 2 7 74 7.8 1 2 7 74 10.1 1 1 7 73 0.4 1 2 7 70 8.2 1 1 7 74 5.0 1 1 7 72 5.9 1 2 7 73 19.3 0 0 7 73 3.5 1 2 7 72 4.3 1 1 7 71 10.4 1 1 7 70 8.7 1 1 7 74 6.7 1 2 7 72 5.5 1 2 7 73 2.3 1 1 7 72 4.5 1 2 7 73 1.5 1 1 7 74 6.4 1 1 7 73 8.6 1 2 7 74 16.2 1 1 7 72 1.3 1 1 7 73 3.3 1 2 7 72 2.5 1 2 7 72 0.2 1 2 7 73 0.1 1 2 7 71 4.0 1 1 7 71 9.0 1 2 7 70 2.5 1 1 7 73 2.3 1 2 7 74 9.7 1 1 7 70 11.0 1 1 7 71 9.5 1 2 7 73 8.1 1 2 7 70 9.4 1 2 7 73 2.2 1 2 7 73 3.4 1 2 7 72 12.1 1 1 7 74 7.3 1 1 7 71 5.5 1 2 7 74 8.2 1 2 7 70 2.2 1 1 7 74 4.4 1 2 7 71 1.9 1 2 7 74 12.9 1 1 7 73 10.9 1 1 7 73 17.1 1 3 7 73 3.8 1 2 7 71 3.2 1 1 7 74 8.1 1 2 7 72 2.6 1 2 7 74 4.6 1 1 7 70 4.3 1 1 7 72 4.8 1 2 7 72 3.6 1 1 7 73 9.6 1 2 7 73 6.4 1 2 7 72 3.2 1 1 7 70 4.1 1 2 7 72 7.4 1 2 7 73 7.1 1 2 7 70 7.7 1 1 8 56 2.2 1 3 8 64 8.0 1 1 8 63 13.4 1 1 8 60 10.6 1 1 8 63 10.6 1 1 8 61 4.0 1 1 8 63 8.0 1 1 8 62 9.3 1 1 8 60 5.9 1 1 8 61 10.1 1 1 8 66 11.3 1 1 8 68 3.7 1 1 8 66 1.2 1 2 8 66 4.4 1 1 8 66 8.2 1 2 8 69 3.5 1 1 8 66 3.8 1 1 8 69 1.5 1 1 8 65 3.9 1 1 8 68 3.4 1 1 8 66 10.3 1 1 8 69 7.0 1 1 8 69 1.4 1 1 8 66 13.7 1 1 8 69 17.9 1 1 8 69 3.6 1 2 8 65 1.5 1 1 8 66 20.0 0 0 8 66 0.9 1 2 8 67 4.3 1 2 8 68 2.6 1 2 8 69 4.8 1 1 8 72 2.7 1 2 8 73 3.3 1 1 8 74 13.2 1 2 8 74 4.9 1 1 8 73 10.3 1 1 8 74 2.3 1 1 8 72 8.1 1 1 8 71 8.0 1 1 8 73 9.6 1 2 8 74 6.1 1 2 8 74 12.4 1 1 8 73 4.4 1 1 8 73 13.2 1 2 8 71 4.8 1 1 8 71 8.5 1 2 8 72 8.7 1 2 8 73 3.7 1 1 9 63 2.3 1 1 9 63 3.2 1 1 9 63 7.0 1 3 9 60 2.6 1 1 9 62 8.6 1 1 9 66 0.8 1 2 9 65 2.1 1 1 9 65 2.6 1 2 9 73 2.7 1 2 9 73 16.8 1 2 9 74 2.2 1 1 10 57 0.5 1 1 10 63 3.4 1 2 10 69 3.3 1 2 10 69 2.3 1 1 10 69 1.6 1 2 10 67 0.6 1 2 10 67 6.8 1 1 10 74 0.8 1 1 10 74 1.6 1 1 10 71 2.0 1 1 10 71 1.5 1 1 10 70 2.8 1 1 10 70 3.2 1 1 10 72 6.9 1 2 10 73 4.2 1 1 10 70 6.8 1 2 10 72 6.2 1 2 10 72 0.2 1 1 10 73 2.6 1 1 10 70 3.6 1 1 # ####### show data on Lexis diagram M = matrix(x,ncol=5,byrow=TRUE) ; GleasonCat = c(0,rep(2.4,3),5,6,7,rep(8910,3)) M=cbind(M, GleasonCat[M[,1]] ) colnames(M)=c("gleason.score","age.at.dx", "years", "dead", "cause", "Gleason.category") head(M) ; tail(M) table(M[,6]) library(Epi) par(mfrow=c(2,3),mar = c(4.5,4,1,1)) YLIM=c(-1.5,37) ; XLIM=c(50,100) MANYEARS.by.age = rep(0,100) DEATHS.other.causes.by.age = rep(0,100) N=0 GleasonCategory = unique(GleasonCat) for (cat in GleasonCategory[2:6] ) { print(cat) if(cat >0) m = M[M[,6]==cat,] n=length(m[,1]) print(n) Age = m[,2]+runif(n,-0.2,0.2) L = Lexis(entry=list(Age=Age), exit=list(year.post.dx=m[,3],Age=Age+m[,3]), entry.status = 0, exit.status = m[,4] ) plot(L,main=paste("Gleason Score",cat),ylim=YLIM,xlim=XLIM, lwd=0.25,col="grey50") if(cat==2.4) { #text(XLIM[2]-0.5,-0.5,"Pr Ca",col="red",adj=c(1,1)) text(XLIM[1]+0.5,YLIM[2]-0.5,"Other Causes",col="blue",adj=c(0,1)) text(XLIM[2],YLIM[2]-2,"> Population Time ^",col="grey75",adj=c(1,1)) } for(Age in 50:95) { segments(Age,0,Age,33,lwd=0.5,col="lightblue") } for(y in 1:33) { segments(50,y,95,y,lwd=0.5,col="lightblue") } for (i in 1:n) { if(m[i,5]==1) points(c(m[i,2]+m[i,3]),c(m[i,3]),col="red",pch=19,cex=0.2) if(m[i,5]==2) points(c(m[i,2]+m[i,3]),c(m[i,3]),col="blue",pch=19,cex=0.2) } # marginal picture.. man.years.by.age = rep(0,100) n.deaths.other.causes.by.age = rep(0,100) man.years.by.fu.year = rep(0,35) n.deaths.pr.cancer.by.fu.year = rep(0,35) for (i in 1:n) { a = m[i,2] a.last = a + floor(m[i,3]) fu.year=0 for ( A in a:a.last ) { fu.year = fu.year + 1 if(A < a.last) { man.years.by.age[A] = man.years.by.age[A] + 1 man.years.by.fu.year[fu.year] = man.years.by.fu.year[fu.year] + 1 } # < if(A == a.last) { man.years.by.age[A] = man.years.by.age[A] + ( m[i,3] - floor(m[i,3]) ) man.years.by.fu.year[fu.year] = man.years.by.fu.year[fu.year] + ( m[i,3] - floor(m[i,3]) ) } # == } # a:a.last n.deaths.other.causes.by.age[a.last] = n.deaths.other.causes.by.age[a.last] + 1*( m[i,5] == 2 ) +0.5*( m[i,5] == 3) last.fu.year = ceiling(m[i,3]) n.deaths.pr.cancer.by.fu.year[last.fu.year] = n.deaths.pr.cancer.by.fu.year[last.fu.year] + 1*( m[i,5] == 1 )+0.5*( m[i,5] == 3) } # 1:n dy=0.06 for (a in 1:100) { if(man.years.by.age[a] > 0 ) { rect(a,YLIM[2], a+1,YLIM[2]-dy*man.years.by.age[a], col="grey80", border=NA) n.d=n.deaths.other.causes.by.age[a] if(n.d > 0 ) points( runif(n.d,a,a+1), YLIM[2]-runif(n.d,0,dy*man.years.by.age[a]), col="blue", cex=0.15, pch=19) } # > 0 } # 1:100 for (y in 1:35) { if(man.years.by.fu.year[y] > 0 ) { rect(XLIM[2]-dy*man.years.by.fu.year[y],y-1, XLIM[2],y, col="grey80", border=NA) n.d=n.deaths.pr.cancer.by.fu.year[y] if(n.d > 0 ) points( runif(n.d,XLIM[2]-dy*man.years.by.fu.year[y],XLIM[2]), y-1+runif(n.d,0,1), col="red", cex=0.15, pch=19) } # > 0 } # 1:35 MY= sum(man.years.by.fu.year) D = sum(n.deaths.pr.cancer.by.fu.year) text( 50, -0.5, paste(toString(n),"men",toString(MY),"man-Years"), adj=c(0,1),col="grey80" ) text( 100, -0.5, paste(toString(D),"Pr Ca Deaths"), adj=c(1,1), col="red" ) # for later (one other.cause rate model for pooled categories ) MANYEARS.by.age = MANYEARS.by.age + man.years.by.age DEATHS.other.causes.by.age = DEATHS.other.causes.by.age + n.deaths.other.causes.by.age N=N+n fu.year=1:35 ds=data.frame(fu.year, n.deaths.pr.cancer.by.fu.year, man.years.by.fu.year) ds=ds[man.years.by.fu.year > 0,] fitted.death.rate.pr.cancer = glm(n.deaths.pr.cancer.by.fu.year ~ fu.year, family=poisson, offset=log( man.years.by.fu.year ), data=ds) ; DY=100 text (XLIM[1],28, "Pr Ca Deaths per ManYear",col="red", adj=c(0,0)) segments(XLIM[1], 0, XLIM[1], 26.5, col="grey50") for(rate in seq(0.05,0.25,0.05)) { segments(XLIM[1]+rate*DY, 25.5, XLIM[1]+rate*DY, 26.5,col="grey50") text (XLIM[1]+rate*DY,25, toString(rate),col="red",adj=c(0.5,1)) } rate.y = exp( fitted.death.rate.pr.cancer$coefficients[1] + fitted.death.rate.pr.cancer$coefficients[2] * ds$fu.year) lines(XLIM[1]+rate.y*DY,ds$fu.year-0.5, col="red") for(y in seq(5,20,5) ) { points(XLIM[1]+rate.y[y]*DY,y-0.5,col="red",cex=0.75) text(XLIM[1]+rate.y[y]*DY,y-0.5, toString(round(rate.y[y],2)),adj=c(-0.25,0.5),col="red") } b.0=toString(round(fitted.death.rate.pr.cancer$coefficients[1],2)) b.fu.t=toString(round(fitted.death.rate.pr.cancer$coefficients[2],2)) text(72,20,"Fitted log[rate]",adj=c(1,0), col="red") text(72,17,paste(b.0,"+",b.fu.t,"t"), adj=c(1,0), col="red") } # OTHER CAUSES age=1:100 ds=data.frame(age,DEATHS.other.causes.by.age,MANYEARS.by.age) ds=ds[ds$MANYEARS.by.age>0,] # INTERCEPT ONLY MODEL fitted.death.rate.other.causes = glm(DEATHS.other.causes.by.age ~ 1, family=poisson, offset=log( MANYEARS.by.age ), data=ds ) ; fitted.death.rate.other.causes = glm(DEATHS.other.causes.by.age ~ age, family=poisson, offset=log( MANYEARS.by.age ), data=ds ) ; rate = exp(fitted.death.rate.other.causes$coefficients[1] + fitted.death.rate.other.causes$coefficients[2] * ds$age ) B.55=toString(round(fitted.death.rate.other.causes$coefficients[1]+ fitted.death.rate.other.causes$coefficients[2]*55,2)) B.age=toString(round(fitted.death.rate.other.causes$coefficients[2],2)) m.rate=max(rate) m.MANY = max(MANYEARS.by.age) plot(ds$age,rate, ylab="deaths.other.cause/ManYear", col="white", xlim=XLIM,type="l", col.lab = "blue",xlab="Age", ylim=c(-0.04,m.rate),main="All, regardless of Gleason category") text(68,0.090,"Fitted log[rate] function",adj=c(1,0), col="blue") text(68,0.070,B.55,adj=c(1,0), col="blue") text(68,0.050,paste("+",B.age," x (Age-55)"), adj=c(1,0), col="blue") dy=0.9*m.rate/m.MANY for (a in 1:100) { if(MANYEARS.by.age[a] > 0 ) { rect(a,m.rate, a+1,m.rate-dy*MANYEARS.by.age[a], col="grey80", border=NA) n.d=DEATHS.other.causes.by.age[a] if(n.d > 0 ) points( runif(n.d,a,a+1), m.rate-runif(n.d,0,dy*MANYEARS.by.age[a]), col="blue", cex=0.1, pch=19) if(a %in% seq(60,90,5)) { rate.a = rate[ds$age==a] points(a,rate.a,cex=0.5,pch=19,col="blue") text(a,rate.a,toString(round(rate.a,2)),adj=c(-0.25,1),cex=0.75) } } # > 0 } # 1:100 MY= sum(MANYEARS.by.age) D = sum(DEATHS.other.causes.by.age) log.rate= toString(round(log(D/MY),2)) r8= toString( round(D/MY,3) ) text( 100, 0.00, paste("men:",toString(N), "man-Years",toString(MY) ), adj=c(1,1),col="grey80" ) text( 100, 0.025, paste("Deaths other causes:",toString(D)), adj=c(1,1), col="blue" ) text( 100, -0.025, paste( "log[",toString(D),"/",toString(MY),"] = log[", r8, "] =",log.rate), adj=c(1,1), col="blue" ) lines(ds$age,rate, col="blue",type="l")