Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Time to 10% ending / converting / failure.
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
You can’t perform that action at this time.