Gets person year (PY) contributions to a particular time since diagnosis (tsd) interval from survival times.
getPY(surv, bin, binS, brks)
The total survival time of the patient.
The label of the specific bin of interest.
The character vector of bin labels in which binLab exists.
The numeric vector of break points used by cut to create binS.
A vector as long as the survival vector input of PY at risk in a particular interval.
# NOT RUN {
library(SEERaBomb)
brks=c(0,0.25,1,3,6)
(binS=levels(cut(brks+0.1,breaks=c(brks,100)))) #make a vector of intervals
survTimes=c(8,16,1.5,3.7)
getPY(survTimes,binS[1],binS,brks)# all contribute 0.25 to first interval
getPY(survTimes,binS[4],binS,brks)# 3rd and 4th survivals contribute 0 and 0.7 to (3,6]
getPY(survTimes,binS[5],binS,brks)# 1st and 2nd survival contribute 2 and 10 years to (6,100]
# }
Run the code above in your browser using DataLab