1
library(coxphf)
library(survival)
im <- data.frame(X1 <- c(0.482, 0.283, 0.806, 0.510, 0.828, 0.675, 0.430, 0.743,
                         0.285, 0.954, 0.323, 0.349, 0.338, 0.818, 0.688), 
                 X2 <- c(0.750, 0.690, 0.604, 0.566, 0.770, 0.022, 0.475, 0.052,
                         0.259, 0.604, 0.946, 0.052, 0.292, 0.052, 0.058),
                 X3 <- c(0.798, 0.082, 0.177, 0.506, 0.047, 0.506, 0.759, 0.711,
                         0.876, 0.773, 0.075, 0.799, 0.327, 0.711, 0.614),
                 X4 <- c(0.444, 0.440, 0.679, 0.167, 0.553, 0.647, 0.239, 0.417,
                         0.945, 0.000, 0.859, 0.216, 0.069, 0.885, 0.786),
                 y <- c( 1.494,  1.143,  1.362,  7.256,  2.759,  1.788, 23.941,
                         5.174,  3.025, 15.585,  0.296, 26.531,  1.932, 3.404, 1.324),
                 failed <- c(1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1,0))

coxphf(Surv(y, failed)~offset(X1)+X2+X3+X), data=im)    #does not work
coxph(Surv(y, failed)~offset(X1)+X2+X3+X4, data=im)     #returns results

I am trying to fit the Cox model with Firth penalization (through coxphf() under package coxphf) while keeping the first variable(any one) as offset. It returns error: "Error: protect(): protection stack overflow." I am getting corresponding results with the coxph() function. Is there any way to incorporate an offset term in the coxphf() function? Also how can I estimate the baseline hazard, given that the survival::basehaz() does not work for a coxphf fit?

SaJa
  • 11
  • 2

0 Answers0