Created
July 11, 2019 15:43
-
-
Save statwonk/03bee60af71173ac2ee66cba7be00c6e to your computer and use it in GitHub Desktop.
Time to 10% ending / converting / failure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(survival) | |
rweibull_cens <- function(n, shape, scale) { | |
# http://statwonk.com/weibull.html | |
a_random_death_time <- rweibull(n, shape = shape, scale = scale) | |
a_random_censor_time <- rweibull(n, shape = shape, scale = scale) | |
observed_time <- pmin(a_random_censor_time, a_random_death_time) | |
censor <- observed_time == a_random_death_time | |
tibble(time = observed_time, censor = censor) | |
} | |
rweibull_cens(1e3, 1, scale = 1e3) %>% | |
survfit(Surv(time, censor) ~ 1, data = .) %>% | |
quantile(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment