Message-ID: <20090314081516.E687E5955DC@borg.st.net.au>
Date: 2009-03-14T08:14:41Z
From: Bob Green
Subject: obtaining the values for the hazard function in a cox regression
In-Reply-To: <mailman.27.1236855616.24346.r-help@r-project.org>
Hello ,
I am hoping for some advice regarding obtaining the values for the
hazard function in a cox regression that I have undertaken. I have a
model in the following form, analysed with the package survival (v.
2.34-1) and a log-log plot obtained using Design (v. 2.1-2).
For two variables, the lines in the survival curves crossed. The
statistician I been obtaining advice from (who does not use R) asked
me to obtain the hazard function values. I am wanting to confirm
whether basehaz is the correct command to obtain such values, to
better understand what is occurring in the log plots.
Below is the code that I have been using. Any assistance is appreciated,
regards
Bob
library(survival)
recidivismv <- read.csv("g://Chapsurv_v.csv",header=T)
cox.V <- coxph(Surv(intDaysUntilFVPO, Event_v) ~ intAgeAtMHCIndex +
PRE + group + MHC + strGender, data = recidivismv)
summary (cox.V)
# produces a log-log plot
mvfit <- survfit (Surv(recidivismv$intDaysUntilFVPO,
recidivismv$Event_v) ~ MHC, data = recidivismv)
neg.ll <- function(mvfit) -log(-log(mvfit))
library (Design)
survplot(mvfit, fun = neg.ll, conf = "none", logt=TRUE)
# hazard values
mhc2 <- coxph (Surv(recidivismv$intDaysUntilFVPO,
recidivismv$Event_v) ~ MHC, data = recidivismv)
basehaz(mhc2)