[R] NA/NaN/Inf in foreign function call (arg 6) error from coxph function

David Winsemius dwinsemius at comcast.net
Wed Feb 13 19:06:31 CET 2013


On Feb 13, 2013, at 7:46 AM, Cindy Yao wrote:

> Dear R-helpers:
> 
> I am trying to fit a multivariate Cox proportional hazards model,
> modelling survival outcome as a function of treatment and receptor
> status. The data look like below:
> 
> # structure of the data
> str(sample.data)
> List of 4
> $ survobj  : Surv [1:129, 1:2] 0.8925+ 1.8836+ 2.1191+ 5.3744+
> 1.6099+ 5.2567  0.2081+ 0.2108+ 0.2683+ 0.4873+ ...
>  ..- attr(*, "dimnames")=List of 2
>  .. ..$ : NULL
>  .. ..$ : chr [1:2] "time" "status"
>  ..- attr(*, "type")= chr "right"
> $ therapy  : Factor w/ 2 levels "treatment1","treatment2": 1 1 1 1 1
> 1 1 2 2 1 ...
> $ ReceptorA: Factor w/ 2 levels "0","1": 1 2 2 2 1 2 2 2 2 1 ...
> $ ReceptorB: Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 1 1 1 ...
> 
> But when I tried to fit a multivariate Cox proportional model, I got
> the following error. I'm not quite what that means. Any help would be
> much appreciated!
> 
> # perform multivariate Cox proportional hazards model
> coxph(sample.data$survobj ~ sample.data$therapy +
> sample.data$ReceptorA + sample.data$ReceptorB)
> 
> Error in fitter(X, Y, strats, offset, init, control, weights = weights,  :
>  NA/NaN/Inf in foreign function call (arg 6)
> In addition: Warning message:
> In fitter(X, Y, strats, offset, init, control, weights = weights,  :
>  Ran out of iterations and did not converge

I cannot tell whether your method of calling coxph() could be part of the problem, or whether you just have a dataset that creates numerical difficulties. I would have constructed a dataset that did not have a Surv-object incorporated into that dataframe, sbut rather it would have been a list of five columns with 'time' and 'status' kept separate, and the call would have looked like:

coxph( Surv(time, status) ~ therapy + ReceptorA + ReceptorB , data= sample.data)

I know that people have had (occasional) problems in the past related merely to creating Surv-objects outside of the formula interface and your approach appears even more dangerous than that approach.

Once you have a more more data arrangement, you could investigate the possibility of a pathological arrangement of data with this since it appears all of you predictors are binomial.

with(sample.data, table( status, therapy,  ReceptorA ,  ReceptorB) )

-- 
David.

> 
> Best regards,
> Cindy
> 
> -- output of sessionInfo():
> 
> sessionInfo()
> R version 2.15.2 (2012-10-26)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> locale:
> [1] C
> 
> attached base packages:
> [1] grid      splines   stats     graphics  grDevices datasets  utils
> [8] methods   base
> 
> other attached packages:
> [1] MASS_7.3-23
> [2] hexbin_1.26.1
> [3] cluster_1.14.3
> [4] latticeExtra_0.6-24
> [5] RColorBrewer_1.0-5
> [6] lattice_0.20-13
> [7] survival_2.37-2
> 
> loaded via a namespace (and not attached):
> [1] tools_2.15.2
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list