The question was why coxph.detail(fit) and survfit(fit) give different answers
for a fitted Cox model. The answer is that they do give the same answers for
me.
fit <- coxph(Surv(time, status) ~ ph.ecog + wt.loss, lung)
dt <- coxph.detail(fit)
sfit <- survfit(fit)
h1 <- cumsum(dt$hazard)
h2 <- -log(sfit$surv)
all.equal(h1, h2)
T
fit$mean
[1] 0.9342723 9.7276995
Now, my guess as to what may have gone wrong for you: the coxph.detail
function returns the baseline hazard for a fiction subject with covariates =
mean of the data set. It has no other option.
The survfit function, however, will give the baseline hazard for an arbitrary
setting of the covariates, for instance
survfit(fit, newdata=data.frame(ph.ecog=1, wt.loss=20)
to get the survival for a subject with physician's ECOG score of 1 and a 20 lb
weight loss. If no values are given it defaults to the mean.
I think you compared a "mean" patient (rarely a reasonable value) in
coxph.detail to a more realistic set of covariate values from survfit. One
would not expect the same baseline survival.
Terry Therneau
------------ begin included message ---------------------
Dear all,
There is something I do not understand in fitting a cox regression model
in Splus.
Ok, I have a model fitted that way:
fit<-coxph(Surv(start,stop,event)~ "list of covariates")
I know I can collect back the y-coordinates of the cumulative baseline
hazard function that way:
cumsum(coxph.detail(fit)$hazard)
(and I can collect back the corresponding x-coordinates with:
coxph.detail(fit)$time)
What I do not understand is that we should also be able to collect this
through an estimate of the baseline survivor function, S0(t). This
function can be estimated that way:
S0t<-survfit(fit,list("here a list of values for the covariates
corresponding to the baseline hazard"))$surv
Then, since by definition H(t)=-log(S(t)), I was sure that
-log(S0t) should exactly correspond the cumulative baseline hazard
function, but this is not the case.
Can someone explain me where I'm wrong?
Thanks in advance for that.
Eric.
-