https://github.com/cran/quantreg
Tip revision: 3ad414306dc4e0be8f04abb2f3abff2cb11a429b authored by Roger Koenker on 13 December 2019, 10:10:02 UTC
version 5.54
version 5.54
Tip revision: 3ad4143
KMvCRQ.R
# Example Comparison of Kaplan-Meier vs crq fitting
# The red crq estimate should overplot the black KM Survival Curve.
if (requireNamespace("survival", quietly = TRUE)){
n <- 100
y <- rchisq(n,3)
c <- rchisq(n,5)
Y <- pmin(y,c)
d <- (y < c)
Surv <- survival::Surv
plot(survival::survfit(Surv(Y,d)~1))
f <- crq(Surv(Y,d)~1, method = "Portnoy", grid = "pivot")
x <- f$sol[2,]
p <- 1-f$sol[1,]
p <- c(p,p[length(p)])
par(col = "red")
fs <- plot(stepfun(x, p),do.points = FALSE, add = TRUE)
}