Re: [R] p values in coxph()

2011-09-23 Thread Terry Therneau
 1) The p values in the printout are a Wald test.  The Wald, score, and
likelihood ratio tests are asymptotically equivalent, but may differ
somewhat in finite samples.  (The Wald and score are both Taylor series
approximations to the LR).  If you want to do an LR test, fit the two
models and use the anova command.  But beware if your second variable
has missing values: the two fits have to be on the same sample.

 2) Yes, coxph(Surv(time, status) ~1) is a valid Cox model.  Not a
particularly interesting one -- it's the LR for the overall fit of the
baseline hazard which is equivalent to a Kaplan Meier when there are no
covariates.

 
Terry T.

---begin inclusion --

I'm interested in building a Cox PH model for survival modeling, using 2
covariates (x1 and x2).   x1 represents a 'baseline' covariate, whereas
x2
represents a 'new' covariate, and my goal is to figure out where x2 adds
significant predictive information over x1.

Ideally, I could get a p-value for doing this.  Originally, I thought of
doing some kind of likelihood ratio test (LRT), where i measure the
(partial) likelihood of the model with just x1, then with x1 and x2,
then it
becomes a LRT with 1 degree of freedom.  But when i use the summary()
function for coxph(), i get the following output (shown at the bottom).

I have two questions:

1) What exactly are the p-values in the Pr(|z|) representing?  I
understand
that the coefficients have standard errors, etc., but i'm not sure how
the
p-value there is calculated.

2) At the bottom, where it shows the results of an LRT with 2df, i don't
quite understand what model the ratio is being tested against.  If the
current model has two variables (x1 and x2), and those are the extra
degrees
of freedom, then the baseline should then have 0 variables, but that's
not
really a Cox model?

thanks for any help.

__
R-help@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.


[R] p values in coxph()

2011-09-22 Thread Brian Tsai
Hi,

I'm interested in building a Cox PH model for survival modeling, using 2
covariates (x1 and x2).   x1 represents a 'baseline' covariate, whereas x2
represents a 'new' covariate, and my goal is to figure out where x2 adds
significant predictive information over x1.

Ideally, I could get a p-value for doing this.  Originally, I thought of
doing some kind of likelihood ratio test (LRT), where i measure the
(partial) likelihood of the model with just x1, then with x1 and x2, then it
becomes a LRT with 1 degree of freedom.  But when i use the summary()
function for coxph(), i get the following output (shown at the bottom).

I have two questions:

1) What exactly are the p-values in the Pr(|z|) representing?  I understand
that the coefficients have standard errors, etc., but i'm not sure how the
p-value there is calculated.

2) At the bottom, where it shows the results of an LRT with 2df, i don't
quite understand what model the ratio is being tested against.  If the
current model has two variables (x1 and x2), and those are the extra degrees
of freedom, then the baseline should then have 0 variables, but that's not
really a Cox model?

thanks for any help.

Brian


 summary(coxph(Surv(myTime,Event)~x1+x2))
Call:
coxph(formula = Surv(myTime, Event) ~ x1 + x2)

  n= 211

  coef exp(coef) se(coef) z Pr(|z|)
x1 0.03594   1.03660  0.17738 0.203  0.83942
x2 0.53829   1.71308  0.17775 3.028  0.00246 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

   exp(coef) exp(-coef) lower .95 upper .95
x1 1.037 0.96470.7322 1.468
x2 1.713 0.58371.2091 2.427

Rsquare= 0.111   (max possible= 0.975 )
Likelihood ratio test= 21.95  on 2 df,   p=1.714e-05
Wald test= 20.29  on 2 df,   p=3.924e-05
Score (logrank) test = 22.46  on 2 df,   p=1.328e-05

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] p-values from coxph?

2010-10-18 Thread Terry Therneau
On Oct 15, 2010, at 9:21 AM, ?hagen Patrik wrote:


 Dear List,

 I each iteration of a simulation study, I would like to save the p- 
 value generated by coxph. I fail to see how to adress the p-value.  
 Do I have to calculate it myself from the Wald Test statistic?

No.  Look at help(coxph.object).  This list the components of a coxph
object and explains what they are.  You will find that
   fit - coxph(.
   fit$wald.test

contains the Wald test statistic.  I prefer the likelihood ratio test
myself 2*diff(fit$loglik), with fit$df degrees of freedom.

Hunting with str(...) is a good strategy, but even better is the
documentation (when it exists).

Terry T.

__
R-help@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.


[R] p-values from coxph?

2010-10-15 Thread Öhagen Patrik

Dear List,

I each iteration of a simulation study, I would like to save the p-value 
generated by coxph. I fail to see how to adress the p-value. Do I have to 
calculate it myself from the Wald Test statistic?


Cheers, Paddy

__
R-help@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.


Re: [R] p-values from coxph?

2010-10-15 Thread David Winsemius


On Oct 15, 2010, at 9:21 AM, Öhagen Patrik wrote:



Dear List,

I each iteration of a simulation study, I would like to save the p- 
value generated by coxph. I fail to see how to adress the p-value.  
Do I have to calculate it myself from the Wald Test statistic?


No. And the most important reason is that would not give you the same  
value as is print()-ed by coxph().


If you ask for the the str(print(coxph(...)) you get NULL (after the  
side-effect of prinitng. The print function only produces side- 
effects. On the other hand you can use the summary function and it  
gives you a richer set of output.  Using the first example on the help  
page for coxph:


str(summary(coxph(Surv(time, status) ~ x + strata(sex), test1)))
List of 12
 $ call: language coxph(formula = Surv(time, status) ~ x +  
strata(sex), data = test1)

 $ fail: NULL
 $ na.action   : NULL
 $ n   : int 7
 $ loglik  : num [1:2] -3.87 -3.33
 $ coefficients: num [1, 1:5] 0.802 2.231 0.822 0.976 0.329
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr x
  .. ..$ : chr [1:5] coef exp(coef) se(coef) z ...
 $ conf.int: num [1, 1:4] 2.231 0.448 0.445 11.18
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr x
  .. ..$ : chr [1:4] exp(coef) exp(-coef) lower .95 upper .95
 $ logtest : Named num [1:3] 1.087 1 0.297
  ..- attr(*, names)= chr [1:3] test df pvalue
 $ sctest  : Named num [1:3] 1.051 1 0.305
  ..- attr(*, names)= chr [1:3] test df pvalue
 $ rsq : Named num [1:2] 0.144 0.669
  ..- attr(*, names)= chr [1:2] rsq maxrsq
 $ waldtest: Named num [1:3] 0.95 1 0.329
  ..- attr(*, names)= chr [1:3] test df pvalue
 $ used.robust : logi FALSE

So the fifth element of  coefficients leaf of the list structure has  
the same p-value as that print()-ed.


Try:

 summary(fit)$coefficients[5]
[1] 0.3292583

(It does seem to me that the name for that leaf of the fit object is  
not particularly in accord with what I would have considered  
coefficients., but I am really in no solid position to criticize  
Terry Therneau to whom we all owe a great deal of gratitude.)



--
David.
__
R-help@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.