Thierry Julian Panje
2011-Dec-10 21:13 UTC
[R] p-value for hazard ratio in Cox proportional hazards regression?
Hi, I'm new to R and using it for Cox survival analysis. Thanks to this great forum I learned how to compute the HR with its confidence interval. My question would be: Is there any way to get the p-value for a hazard ratio in addition to the confidence interval? Thanks, Thierry -- Thierry Panje Visiting Student Researcher Department of Psychology Stanford Psychophysiology Lab 450 Serra Mall, Bldg 420 Stanford University
Joshua Wiley
2011-Dec-10 21:53 UTC
[R] p-value for hazard ratio in Cox proportional hazards regression?
Hi Thierry, Could you give us an example of what exactly you are doing (preferablly reproducible R code)? I may be misunderstanding you, but if you are fitting cox proportional hazard models using the coxph() function from the surival package, summary(yourmodel) should give the SE, p-value based on the wald statistic, and 95% CI. Cheers, Josh On Sat, Dec 10, 2011 at 1:13 PM, Thierry Julian Panje <tpanje at stanford.edu> wrote:> Hi, > > I'm new to R and using it for Cox survival analysis. Thanks to this great forum I learned how to compute the HR with its confidence interval. > My question would be: Is there any way to get the p-value for a hazard ratio in addition to the confidence interval? > > Thanks, > Thierry > > > > -- > Thierry Panje ? ? ? ? ? ? ? ? ?Visiting Student Researcher > Department of Psychology ? ? ? Stanford Psychophysiology Lab > 450 Serra Mall, Bldg 420 ? ? ? Stanford University > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
Joshua Wiley
2011-Dec-11 05:45 UTC
[R] p-value for hazard ratio in Cox proportional hazards regression?
Hi Thierry, I see what you want now---a significance test for the HR specifically. See inline below On Sat, Dec 10, 2011 at 6:40 PM, Thierry Julian Panje <tpanje at stanford.edu> wrote:> Hi Josh, > > Thank you for your quick response! > > In several papers the results of a Cox Regression were presented in a table showing the variable name, the hazard ratio for two values of this variable, the 95% confidence interval of the hazard ratio and a p-value. > (e.g., Lett 2007. Social support and prognosis in patients at increased psychosocial risk recovering from myocardial infarction. Health psychology "http://psycnet.apa.org/journals/hea/26/4/418.pdf" page 6 Table 2) > > When I use summary() for a coxph() function, for example: > >> summary(mod.allison) > Call: > coxph(formula = Surv(week, arrest) ~ fin + age + race + wexp + > ? ?mar + paro + prio, data = Rossi) > > ?n= 432, number of events= 114 > > ? ? ? ? ? ? ? ? ? coef exp(coef) se(coef) ? ? ?z Pr(>|z|) > finyes ? ? ? ? -0.37942 ? 0.68426 ?0.19138 -1.983 ?0.04742 * > age ? ? ? ? ? ?-0.05744 ? 0.94418 ?0.02200 -2.611 ?0.00903 ** > raceother ? ? ?-0.31390 ? 0.73059 ?0.30799 -1.019 ?0.30812 > wexpyes ? ? ? ?-0.14980 ? 0.86088 ?0.21222 -0.706 ?0.48029 > marnot married ?0.43370 ? 1.54296 ?0.38187 ?1.136 ?0.25606 > paroyes ? ? ? ?-0.08487 ? 0.91863 ?0.19576 -0.434 ?0.66461 > prio ? ? ? ? ? ?0.09150 ? 1.09581 ?0.02865 ?3.194 ?0.00140 ** > --- > Signif. codes: ?0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > ? ? ? ? ? ? ? exp(coef) exp(-coef) lower .95 upper .95 > finyes ? ? ? ? ? ?0.6843 ? ? 1.4614 ? ?0.4702 ? ?0.9957 > age ? ? ? ? ? ? ? 0.9442 ? ? 1.0591 ? ?0.9043 ? ?0.9858 > raceother ? ? ? ? 0.7306 ? ? 1.3688 ? ?0.3995 ? ?1.3361 > wexpyes ? ? ? ? ? 0.8609 ? ? 1.1616 ? ?0.5679 ? ?1.3049 > marnot married ? ?1.5430 ? ? 0.6481 ? ?0.7300 ? ?3.2614 > paroyes ? ? ? ? ? 0.9186 ? ? 1.0886 ? ?0.6259 ? ?1.3482 > prio ? ? ? ? ? ? ?1.0958 ? ? 0.9126 ? ?1.0360 ? ?1.1591 > > Concordance= 0.64 ?(se = 0.027 ) > Rsquare= 0.074 ? (max possible= 0.956 ) > Likelihood ratio test= 33.27 ?on 7 df, ? p=2.362e-05 > Wald test ? ? ? ? ? ?= 32.11 ?on 7 df, ? p=3.871e-05 > Score (logrank) test = 33.53 ?on 7 df, ? p=2.11e-05 > > > I thought, the value in the "Pr(>|z|)" column indicated the significance of the coefficient and not of a hazard ratio.That is correct.> > Is it possible to assess the statistical significance of a hazard ratio not only with a confidence interval but also with a p-value and to compute that in R?I am hoping someone else will chime in here. I might naively try this (but do validate before publishing). For the standard error of the hazard ratio, I use exp(coef) * se, and then assume that (exp(coef) - 1)/(exp(coef) * se) is ~ x2(1). A quick look through Terry Therneau's book, Modeling Survival Data did not turn up any particular ways to get this automatically in R. Note that the confidence interval (and this is consistent with summary()) is based on exponentiating the linear predictor's lower and upper limits, not the SE of the exponetiated predictor. require(survival) set.seed(1) d <- data.frame( start = start <- sample(1:10, 600, TRUE), stop = start + sample(1:7, 600, TRUE), event = event <- rbinom(600, 1, .7), x1 = event * rbinom(600, 1, .7), x2 = rnorm(600, 0, 1)) m <- coxph(Surv(start, stop, event) ~ x1 + x2, d) beta <- coef(m) se <- sqrt(diag(vcov(m))) HR <- exp(beta) HRse <- HR * se summary(m) round(cbind(coef = beta, se = se, z = beta/se, p = 1 - pchisq((beta/se)^2, 1), HR = HR, HRse = HRse, HRz = (HR - 1) / HRse, HRp = 1 - pchisq(((HR - 1)/HRse)^2, 1), HRCILL = exp(beta - qnorm(.975, 0, 1) * se), HRCIUL = exp(beta + qnorm(.975, 0, 1) * se)), 3)> Or is it usual to present a hazard ratio together with the p-value of the coefficient?"usual" probably depends on the area. I have seen the coefficients presented with p-values, and the 95%CI of the hazard ratio. I do not know that there is any one required set of statistics to be reported.> Or do the coefficient and any defined hazard ratio of a variable have in fact the same p-value?No, it is a nonlinear transformation and the p-values are not the same.> > I would like to apologize if these were trivial questions and I fear they are not totally R-specific. Thus I understand if you don't have the time to answer them. However, I would greatly appreciate any help.Aspects are not, but aspects are. Certainly, asking if there is a way to get a test of the hazard ratio in R (without hacking something together like I did) seems reasonable to me at least to ask. Cheers, Josh> > Best, > Thierry > > > > ----- Urspr?ngliche Mail ----- > Von: "Joshua Wiley" <jwiley.psych at gmail.com> > An: "Thierry Julian Panje" <tpanje at stanford.edu> > CC: r-help at r-project.org > Gesendet: Samstag, 10. Dezember 2011 13:53:00 > Betreff: Re: [R] p-value for hazard ratio in Cox proportional hazards regression? > > Hi Thierry, > > Could you give us an example of what exactly you are doing > (preferablly reproducible R code)? ?I may be misunderstanding you, but > if you are fitting cox proportional hazard models using the coxph() > function from the surival package, summary(yourmodel) should give the > SE, p-value based on the wald statistic, and 95% CI. > > Cheers, > > Josh > > On Sat, Dec 10, 2011 at 1:13 PM, Thierry Julian Panje > <tpanje at stanford.edu> wrote: >> Hi, >> >> I'm new to R and using it for Cox survival analysis. Thanks to this great forum I learned how to compute the HR with its confidence interval. >> My question would be: Is there any way to get the p-value for a hazard ratio in addition to the confidence interval? >> >> Thanks, >> Thierry >> >> >> >> -- >> Thierry Panje ? ? ? ? ? ? ? ? ?Visiting Student Researcher >> Department of Psychology ? ? ? Stanford Psychophysiology Lab >> 450 Serra Mall, Bldg 420 ? ? ? Stanford University >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > Programmer Analyst II, Statistical Consulting Group > University of California, Los Angeles > https://joshuawiley.com/-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/