[R] Coxph with factors

Kylie-Anne Richards kar at itga.com.au
Fri Jul 15 15:39:37 CEST 2005


My apologies for lack of clarity.

Sample data:

      time.sec po vo done f.pom
      55 0 4402 1 -0.25
      378 -0.5 50000 1 -0.25
      51 0 1000 1 -0.25
      43 0 71581 1 -0.25

etc

>        DATA<-data.frame(time.sec,done,f.pom=factor(f.pom),po,vo)
>        final<-coxph(Surv(time.sec,done)~f.pom+vo+po,data=DATA)
                      coef exp(coef) se(coef)       z       p
f.pom-2.5  1.30e+00      3.65 1.66e-01   7.822 5.2e-15
f.pom-2    1.11e+00      3.02 1.68e-01   6.604 4.0e-11
f.pom-1.5  1.37e+00      3.95 1.59e-01   8.656 0.0e+00
f.pom-1    1.76e+00      5.79 1.56e-01  11.286 0.0e+00
f.pom-0.5  2.10e+00      8.14 1.52e-01  13.757 0.0e+00
f.pom0     4.96e+00    142.10 1.95e-01  25.433 0.0e+00
f.pom0.5   4.69e+00    108.71 1.53e-01  30.573 0.0e+00
f.pom1     4.66e+00    105.50 1.58e-01  29.575 0.0e+00
f.pom1.5   4.66e+00    105.62 1.60e-01  29.051 0.0e+00
f.pom2     4.61e+00    100.77 1.60e-01  28.792 0.0e+00
vo           -6.93e-05      1.00 6.57e-06 -10.548 0.0e+00
po           2.65e-03      1.00 1.29e-03   2.047 4.1e-02

 >final.surv<-survfit((final), individual=T,conf.type="log-log")
 >print(final.surv)

  time n.risk n.event survival  std.err lower 95% CI upper 95% CI
     0  13922    3914 8.10e-01 3.82e-03     8.02e-01      0.81712
     1   9726      91 7.98e-01 3.97e-03     7.90e-01      0.80547
     2   9457      46 7.92e-01 4.04e-03     7.84e-01      0.79949
     3   9297      36 7.87e-01 4.10e-03     7.79e-01      0.79477
etc

FIRST Q: The default uses the mean of 'vo' and mean of 'po', but what is it 
using for the factors?? Is it the sum of the coef of the factors divided by 
the number of factors??

SECOND Q: For a model with covariates I would normally specify: 
final.surv<-survfit((final), data.frame(po=0,vo=0,pom=0,individual=T)) to 
get the baseline survival prob.; what would I specify for a model with a 
factor, i.e., 'f.pom' ??

E.g. one of the many variations I have tried:
>         final.surv<-survfit((final), 
> data.frame(po=0,vo=0,f.pom=0,individual=T))
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ
In addition: Warning message:
'newdata' had 1 rows but variable(s) found have 13922 rows
Execution halted

I appreciate the time anyone can spare to help me with my problem, and 
apologies for it's simplistic nature.

Many thanks,

Kylie-Anne



Adaikalavan Ramasamy ramasamy at cancer.org.uk
Fri Jul 15 09:58:19 CEST 2005

  a.. Previous message: [R] Coxph with factors
  b.. Next message: [R] Pearson dispersion statistic
  c.. Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

--------------------------------------------------------------------------------

Yes, and please show us a reproducible example or small section of thedata 
as well as the error output. On Thu, 2005-07-14 at 15:36 +0000, Dieter Menne 
wrote:> Kylie-Anne Richards <kar <at> itga.com.au> writes:> > > > > I am 
fitting a coxph model with factors. I am running into problems when> > using 
'survfit'. I am unsure how R is treating the factors when I fit, say:> > > 
DATA<-data.frame(time.sec,done,f.pom=factor(f.pom),po,vo)> > > 
final<-coxph(Surv(time.sec,done)~f.pom*vo+po,data=DATA)> > > 
final.surv<-survfit((final), individual=T,conf.type="log-log")> > > 
print(final.surv)> ....> > Better chances to get a reply when you tell us 
what problems you are running > into.> > Dieter Menne




More information about the R-help mailing list