If you use the debugger you can see what's going on inside the function. By specifying debugonce(flexsurvspline)
, and then running the function, you can step through and see what's happening on each step. (NB: capital Q
gets you out of the debugging browser). When I did that, I found that the because more than 30% of the data is in the first time (2), which is also the left boundary know, the function is setting the knots at:
Browse[2]> knots
33.33333% 66.66667%
0.6931472 0.6931472 1.0986123 2.5649494
Note that the first two knots are at the same value, which essentially breaks the function. You can fix this by specifying the interior knot values directly on the log-time scale.
flexsurvspline(Surv(time,dead)~1,data=input_df, knots=c(1.8,2.3))
# Call:
# flexsurvspline(formula = Surv(time, dead) ~ 1, data = input_df,
# knots = c(1.8, 2.3))
#
# Estimates:
# est L95% U95% se
# gamma0 -3.475 -3.783 -3.167 0.157
# gamma1 3.021 2.785 3.257 0.120
# gamma2 4.294 3.341 5.248 0.487
# gamma3 -7.908 -10.305 -5.510 1.223
#
# N = 428, Events: 428, Censored: 0
# Total time at risk: 1401
# Log-likelihood = -725.7712, df = 4
# AIC = 1459.542
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…