[R] SURVDIFF()

David Winsemius dwin@emiu@ @ending from comc@@t@net
Sat Jan 12 18:15:43 CET 2019


On 1/12/19 1:18 AM, Medic wrote:
> How to note (in code) a few (!) adjusting covariates for cox
> regression. I had an example for one covariate, and tried (according
> to my own understanding) two variantes of code  (pls, see below), and
> got ... a different p-value. What is the right code? Many thanks!!!
>
> (1)
> survdiff (Surv(survt,status)~clinic+strata(prison, dose, gender),data=addicts)
> N Observed Expected (O-E)^2/E (O-E)^2/V
> clinic=1 163      122    106.2      2.35        14
> clinic=2  75       28     43.8      5.70        14
> Chisq= 14  on 1 degrees of freedom, p= 2e-04
>
> (2)
> survdiff (Surv(survt,status)~clinic+strata(prison+dose+gender),data=addicts)
> N Observed Expected (O-E)^2/E (O-E)^2/V
> clinic=1 163      122    106.2      2.35      12.1
> clinic=2  75       28     43.8      5.69      12.1
> Chisq= 12.1  on 1 degrees of freedom, p= 5e-04


Read the help page:


> ?strata
>
>
> Usage
>
> strata(..., na.group=FALSE, shortlabel, sep=', ')
> Arguments
>
> ...
> any number of variables. All must be the same length.
>
So the function is documented to accept a list of variable names, but 
_not_ as accepting a formula. So I read the help page as endorsing your 
first option. Since you didn't include a suitable dataset for testing I 
borrowed the ovarian dataframe and checked to see whether the sum of 
variables submitted with a "+" sign was being calculated and can confirm 
that it is:


 >  coxph(Surv(futime, fustat) ~ age + strata(I(rx+ecog.ps)), data=ovarian)
Call:
coxph(formula = Surv(futime, fustat) ~ age + strata(I(rx + ecog.ps)),
     data = ovarian)

        coef exp(coef) se(coef)     z       p
age 0.11942   1.12684  0.04528 2.637 0.00836

Likelihood ratio test=9.48  on 1 df, p=0.002073
n= 26, number of events= 12
 >  coxph(Surv(futime, fustat) ~ age + strata( rx+ecog.ps) , data=ovarian)
Call:
coxph(formula = Surv(futime, fustat) ~ age + strata(rx + ecog.ps),
     data = ovarian)

        coef exp(coef) se(coef)     z       p
age 0.11942   1.12684  0.04528 2.637 0.00836

-- 

David.



More information about the R-help mailing list