secmal: Get risk and CI from competing risk

Extract risk and calculate competing risk at specific timepoint.
This commit is contained in:
Jens Sauer 2021-01-17 18:53:08 +01:00
parent 48be520bb0
commit f29a5f1ef5

View File

@ -82,6 +82,23 @@ sma_plot_secmal_cmprsk <- function() {
legend = "none", title = "", ylim = c(0:1))
}
# Calculate cumuative risk with ci from cuminc.
# CI calculation shamelessly stolen from ggcompetingrisks()
sma_secmal_cmprsk_time <- function(c, t) {
coef <- 1.96
tp <- timepoints(c[1], t)
df <- as.data.frame(matrix(nrow = 1, ncol = 6))
colnames(df) <- c("est", "var", "time", "std", "ci.lower", "ci.upper")
df$var <- as.numeric(tp$var)
df$est <- as.numeric(tp$est)
df$time <- t
df$std <- sqrt(df$var)
df$ci.lower <- df$est - coef * df$std
df$ci.upper <- df$est + coef * df$std
return(df)
}
# Write secondary malignancy plots to files
sma_plot_file_secmal <- function() {
sma_plot_file("secmal_event.png", png, sma_plot_secmal_event)