I stumbled upon this question and wanted to do something similar on my plot (for exponential and weibull function).
I want to extract the x value for a specific y value. for me, the Y value would be 0.5.
here is my reproducible example:
library(survival)
attach(stanford2)
km = survfit(Surv(time, status)~ 1)
wykładniczy <- survreg(Surv(time, status) ~ 1, dist = 'exponential')
lambda_wyk <- exp(-wykładniczy$coef)
weibulla <- survreg(Surv(time, status) ~ 1, dist = 'weibull')
lambda_wei <- exp(-weibulla$icoef[1])
kappa_wei <- 1/weibulla$icoef[2]
plot(km, col = 'black', lwd = 2, conf.int = FALSE)
x = seq(0, max(time), length = 10000)
lines(x, exp(-lambda_wyk*x), col = 'red', lwd = 2)
lines(x, exp(-(lambda_wei*x)^kappa_wei), col = 'blue', lwd = 2)
grid()
legend('topright', c('Kaplan-Meier', 'Wykladniczy',
'Weibull'), col = c('black',
'red', 'blue'), lwd = 2)
I'm using the stanford2 data from the survival package.
I tried to do this like this.
x[which(exp(-(lambda_wei*x)^kappa_wei) == 0.5)])
But I'm missing something.
Explanation what should I do would be great.