[R] cox regression warning/error messages

Bob Green bgreen at dyson.brisnet.org.au
Sun Dec 28 10:00:06 CET 2008


Hello,

I am hoping for some advice regarding warning/error messages I 
received when running a Cox regression

# message 1 - obtained while creating a plot of residuals

 > plot (NV.zph, main = "groupNUSM - UNFIT", var= 'groupNUSM')
Warning messages:
1: In approx(xx, xtime, seq(min(xx), max(xx), length.out = 17)[2 *  :
   collapsing to unique 'x' values
2: In approx(xtime, xx, temp) : collapsing to unique 'x' values

Ques 1- A plot is generated, is there a solution to the warnings or 
can they be ignored?

#  message #2 - obtained while trying to obtain a plot of outliers

 > plot(group, rr.n[,5], xlab = 'groupUSM', ylab = 'influence of MHC decision')
Error in plot(group, rr.n[, 5], xlab = "groupUSM", ylab = "influence 
of MHC decision") :
   object "group" not found

Ques 2 - A plot can be generated only when the original $group 
variable is used rather than the R generated dummy variables. Is it 
the case that plots should be run for each dummy variable, or is it 
correct simply to run the analysis on the original variable?

The code employed to generate the analysis follows:

Any assistance is appreciated,

Bob


cox.NV <- coxph(Surv(recidivism$intDaysUntilFNVPO, 
recidivism$Event_nv) ~ recidivism$strGender + 
recidivism$intAgeAtMHCIndex + recidivism$PRE.nv + group + 
recidivism$MHC.nv + recidivism$SNFP , data = recidivism)

 > summary(cox.NV)
Call:
coxph(formula = Surv(recidivism$intDaysUntilFNVPO, recidivism$Event_nv) ~
     recidivism$strGender + recidivism$intAgeAtMHCIndex + recidivism$PRE.nv +
         group + recidivism$MHC.nv + recidivism$SNFP, data = recidivism)

   n= 1647
                                coef exp(coef) se(coef)      z       p
recidivism$strGenderM        0.1053     1.111  0.13400  0.786 4.3e-01
recidivism$intAgeAtMHCIndex -0.0442     0.957  0.00506 -8.729 0.0e+00
recidivism$PRE.nvNV          1.3072     3.696  0.12213 10.703 0.0e+00
recidivism$PRE.nvV          -1.2676     0.281  1.00720 -1.259 2.1e-01
groupNUSM                    1.2379     3.449  0.38570  3.210 1.3e-03
groupUSM                     0.7277     2.070  0.38270  1.901 5.7e-02
recidivism$MHC.nvV          -0.1730     0.841  0.10255 -1.687 9.2e-02
recidivism$SNFPSNFP         -0.8839     0.413  0.17269 -5.118 3.1e-07

                             exp(coef) exp(-coef) lower .95 upper .95
recidivism$strGenderM           1.111      0.900    0.8545     1.445
recidivism$intAgeAtMHCIndex     0.957      1.045    0.9473     0.966
recidivism$PRE.nvNV             3.696      0.271    2.9091     4.695
recidivism$PRE.nvV              0.281      3.552    0.0391     2.027
groupNUSM                       3.449      0.290    1.6193     7.344
groupUSM                        2.070      0.483    0.9779     4.383
recidivism$MHC.nvV              0.841      1.189    0.6880     1.028
recidivism$SNFPSNFP             0.413      2.420    0.2945     0.580

Rsquare= 0.205   (max possible= 0.987 )
Likelihood ratio test= 377  on 8 df,   p=0
Wald test            = 286  on 8 df,   p=0
Score (logrank) test = 317  on 8 df,   p=0

 >  NV.zph <- cox.zph(cox.NV)
 > NV.zph
                                 rho  chisq        p
recidivism$strGenderM       -0.0323  0.538 4.63e-01
recidivism$intAgeAtMHCIndex -0.0295  0.481 4.88e-01
recidivism$PRE.nvNV         -0.0289  0.417 5.18e-01
recidivism$PRE.nvV          -0.0360  0.664 4.15e-01
groupNUSM                   -0.0181  0.168 6.82e-01
groupUSM                     0.0467  1.120 2.90e-01
recidivism$MHC.nvV          -0.0132  0.091 7.63e-01
recidivism$SNFPSNFP          0.0843  3.717 5.39e-02
GLOBAL                           NA 37.405 9.69e-06

NV.zph <- cox.zph(cox.NV)
NV.zph
plot (NV.zph, main = "gender ", var= 'recidivism$strGenderM')
plot (NV.zph, main = "age at first hearing", var= 
'recidivism$intAgeAtMHCIndex')
plot (NV.zph, main = "Preoffending NV compared to nil", var= 
'recidivism$PRE.nvNV')
plot (NV.zph, main = "Preoffending V compared to nil", var= 
'recidivism$PRE.nvV')
plot (NV.zph, main = "groupNUSM - UNFIT", var= 'groupNUSM')
plot (NV.zph, main = "groupUSM - UNFIT", var= 'groupUSM')
plot (NV.zph, main = "nonviolent MHT offence", var= 'recidivism$MHC.nvV')
plot (NV.zph, main = "SNFP", var= 'recidivism$SNFPSNFP')

# warning message same for all plot commands

 >Warning messages:
 >1: In approx(xx, xtime, seq(min(xx), max(xx), length.out = 17)[2 *  :
   >collapsing to unique 'x' values
 > 2: In approx(xtime, xx, temp) : collapsing to unique 'x' values

 > par(mfrow=c(3:2))
 > cox.NV <- coxph(Surv(recidivism$intDaysUntilFNVPO, 
recidivism$Event_nv) ~ recidivism$strGender + 
recidivism$intAgeAtMHCIndex + recidivism$PRE.nv + group + 
recidivism$MHC.nv + recidivism$SNFP , data = recidivism)
 > rr.n <- resid(cox.NV, type = 'dfbeta')
 > plot (recidivism$strGender, rr.n[,1], xlab = 'sex', ylab = 
'influence of sex')
 > plot(recidivism$intAgeAtMHCIndex, rr.n[,2], xlab = 'age', ylab = 
'influence of age')
 > plot(recidivism$PRE.nvNV, rr.n[,3], xlab = 'prior', ylab = 
'influence of prior offence')
Error in xy.coords(x, y, xlabel, ylabel, log) :
   'x' and 'y' lengths differ
 > plot(recidivism$PRE.nvV, rr.n[,4], xlab = 'prior', ylab = 
'influence of prior offence')
Error in xy.coords(x, y, xlabel, ylabel, log) :
   'x' and 'y' lengths differ
 > plot(group, rr.n[,5], xlab = 'groupNUSM', ylab = 'influence of MHC 
decision')
Error in plot(group, rr.n[, 5], xlab = "groupNUSM", ylab = "influence 
of MHC decision") :
   object "group" not found
 > plot(group, rr.n[,6], xlab = 'groupUSM', ylab = 'influence of MHC decision')
Error in plot(group, rr.n[, 6], xlab = "groupUSM", ylab = "influence 
of MHC decision") :
   object "group" not found



More information about the R-help mailing list