[R] Error using newdata argument in survfit

From: Hanke, Alex <HankeA_at_mar.dfo-mpo.gc.ca>
Date: Thu 16 Jun 2005 - 04:17:56 EST


Dear R-helpers,
To get curves for a pseudo cohort other than the one centered at the mean of the covariates, I have been trying to use the newdata argument to survfit with no success. Here is my model statement, the newdata and the ensuing error. What am I doing wrong?

> summary(fit)

Call:
coxph(formula = Surv(Start, Stop, Event, type = "counting") ~

    Week + LagAOO + Prior.f + cluster(interaction(Station, Year)),     data = data8, method = "breslow", x = T, y = T)

  n= 1878

            coef exp(coef) se(coef) robust se     z       p
Week     0.00582      1.01   0.0323    0.0239 0.244 8.1e-01
LagAOO   0.71929      2.05   0.1238    0.1215 5.918 3.3e-09
Prior.f2 0.12927      1.14   0.4402    0.4025 0.321 7.5e-01
Prior.f3 0.79082      2.21   0.5484    0.4460 1.773 7.6e-02
Prior.f4 2.04189      7.71   0.6008    0.4685 4.358 1.3e-05
Prior.f5 1.20450      3.34   0.6423    0.5481 2.198 2.8e-02

         exp(coef) exp(-coef) lower .95 upper .95
Week          1.01      0.994     0.960      1.05
LagAOO        2.05      0.487     1.618      2.61
Prior.f2      1.14      0.879     0.517      2.50
Prior.f3      2.21      0.453     0.920      5.29
Prior.f4      7.71      0.130     3.076     19.30
Prior.f5      3.34      0.300     1.139      9.76

Rsquare= 0.047 (max possible= 0.25 )

Likelihood ratio test= 91  on 6 df,   p=0
Wald test            = 209  on 6 df,   p=0
Score (logrank) test = 142  on 6 df,   p=0,   Robust = 17.4  p=0.00803

  (Note: the likelihood ratio and score tests assume independence of
     observations within a cluster, the Wald and robust score tests do not).

>

newdat
      Week   LagAOO Prior.f2 Prior.f3 Prior.f4 Prior.f5
1 17.55218 1.191693        1        0        0        0
2 17.55218 1.191693        0        0        0        0

> survfit(fit,newdata=newdat)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames, :

        variable lengths differ
In addition: Warning message:
'newdata' had 2 rows but variable(s) found have 1878 rows

Regards,
Alex

Alex Hanke
Department of Fisheries and Oceans
St. Andrews Biological Station
531 Brandy Cove Road
St. Andrews, NB
Canada
E5B 2L9

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 16 04:28:40 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:42 EST