Skip to content
Prev 132254 / 398506 Next

Capture warning messages from coxph()

One way is to turn the 'warnings' into 'errors' and then trap the error:
+
+     aa <- try(fit <- summary(coxph(TIME~x[,i])))
+     if (class(aa) == "try-error"){
+         print(paste("i =", i, "had error"))
+         next   # skip iteration
+     }
+
+     results[i,1]=fit$coef[1]
+     results[i,2]=fit$coef[3]
+     results[i,3]=fit$coef[5]
+     rm(fit)
+ }
Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
  (converted from warning) Loglik converged before variable  1 ; beta
may be infinite.
[1] "i = 2 had error"

        
On Dec 17, 2007 10:16 AM, xinyi lin <x1lin at ucsd.edu> wrote: