I am currently doing survival analysis for a project and wanted to calculate the event rate (Number of events / Person-time) at the median follow-up time for a study population.
A snippet of my data would be:
library(survival)
dat1 <- structure(list(days2death = c(627, 577, 2, 73, 518, 711, 1, 3,
1, 197, 7, 1492, 8, 374, 1), death = c(0, 0, 1, 1, 1, 0, 1, 1,
1, 1, 1, 0, 1, 1, 1)), row.names = c(NA, -15L), class = c("tbl_df",
"tbl", "data.frame"))
I am currently using the pyears() function from the survival library but this only gives me the number of events in observed person-years at the end of follow-up. I would like to calculate them at the median follow-up time.