https://github.com/cran/quantreg
Raw File
Tip revision: 029a6bd97dd27d89db125da22a3b5a4b585cd97f authored by Roger Koenker on 22 March 2012, 00:00:00 UTC
version 4.78
Tip revision: 029a6bd
KMvCRQ.R

# Example Comparison of Kaplan-Meier vs crq fitting
# The red crq estimate should overplot the black KM Survival Curve.
require(quantreg)
require(survival)
n <- 100
y <- rchisq(n,3)
c <- rchisq(n,5)
Y <- pmin(y,c)
d <- (y < c)
plot(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)

back to top