[R] survival package can't find Ccoxfit6
Duncan Murdoch
murdoch.duncan at gmail.com
Thu Apr 27 18:54:41 CEST 2017
On 27/04/2017 10:53 AM, SeshanV at mskcc.org wrote:
> Thank you Drs. Therneau and Murdoch.
>
> "Why not use coxph.fit?" -- My use case scenario is that I needed the Cox model coefficients for resampled data. I was trying to reduce the computational overhead of coxph.fit (since it will repeated a large number of times) by stripping all the parts that I don't need such as sorting of the data prior to coxfit6.c call and Martingale residual and concordance computations after the parameters are estimated.
>
> Under the R v3.4.0 model one cannot create any modified form of coxph.fit and expect it to work. Worse yet is the following where I copy "coxph.fit" to my workspace as "mycoxph.fit" (works initially because the environment is namespace:survival and fails when environment changed to R_GlobalEnv)
Under the R 3.3.1 model the problems are the same. When a change is
made to the internals, your code will break. That's why your code broke.
>
>> set.seed(12345)
>> x <- rep(0:1, c(20,20))
>> y <- cbind(c(-log(runif(20)), -2*log(runif(20))), rep(1,40))
>> mycoxph.fit <- coxph.fit
>> control <- coxph.control()
>> oo1 <- coxph.fit(as.matrix(as.double(x)), y, NULL, NULL, NULL, control, NULL, "efron", NULL)
>> oo2 <- mycoxph.fit(as.matrix(as.double(x)), y, NULL, NULL, NULL, control, NULL, "efron", NULL)
>> all.equal(oo1, oo2)
> [1] TRUE
>> environment(mycoxph.fit)
> <environment: namespace:survival>
>> environment(mycoxph.fit) <- .GlobalEnv
>> environment(mycoxph.fit)
> <environment: R_GlobalEnv>
>> mycoxph.fit(as.matrix(as.double(x)), y, NULL, NULL, NULL, control, NULL, "efron", NULL)
> Error in mycoxph.fit(as.matrix(as.double(x)), y, NULL, NULL, NULL, control, :
> object 'Ccoxfit6' not found
>
> So the question is can a user create new functions modeled after existing functions os is the new model going to hinder it?
The new model actually helps in this. It offers the possibility that
the run-time code will detect internal changes that break your code,
rather than segfaulting when the argument list is wrong.
Duncan Murdoch
More information about the R-help
mailing list