https://github.com/cran/clinfun
Tip revision: 1f7c3b640a99589c9964be4419f51823a14da6d5 authored by Venkatraman E. Seshan on 15 October 2012, 00:00:00 UTC
version 1.0.3
version 1.0.3
Tip revision: 1f7c3b6
coxphQuantile.R
coxphQuantile <- function(phfit, xrange, p=0.5, whichx=1, otherx=NULL, ...)
{
if (class(phfit) != "coxph") stop("phfit shoud be coxph class object")
cvtmean <- phfit$means
loghr <- phfit$coef
S0 <- survfit(phfit)
ii <- S0$surv < 1 & S0$surv > 0
stime <- S0$time[ii]
ssurv <- S0$surv[ii]
if (!missing(otherx)) {
ssurv <- ssurv^(exp(sum(loghr[-whichx]*(otherx-cvtmean[-whichx]))))
}
sx <- cvtmean[whichx] + log(log(p)/log(ssurv))/loghr[whichx]
ii <- which(sx >= xrange[1] & sx <= xrange[2])
lines(sx[ii], stime[ii], type="S", ...)
invisible(as.data.frame(list(cvt=sx,time=stime)))
}