Closed Erikwjoh closed 2 years ago
If a model doesn't work, it's best to simplify it until it does work, and then build it up bit by bit. In this case, you could use the parameters from a fitted model with one internal knot to initialise the two-knot model. But it doesn't converge in this case. This is very small dataset with only 12 distinct event times, so I wouldn't be surprised if this (four-parameter) model were not identifiable.
fl1 <- flexsurvspline(Surv(time,dead)~1,data=input_df,k=1)
plot(survfit(Surv(time, dead) ~ 1, data=input_df))
lines(fl1, t=seq(0,10,1))
flexsurvspline(Surv(time,dead)~1,data=input_df,k=2,
inits = c(coef(fl1), 0))
Many thanks for the explanation @chjackson! I found that I am able to fit a 2-knot model when I specify my own internal knot values. Is there any disadvantage to doing this? I'm new to using splines and don't have any experience in using custom knot locations.
Thanks again!
The exact location of the knots doesn't usually make a big difference, as I've found.
When I run flexsurvspline on the attached dataset (flexsurvspline(Surv(time,dead)~1,data=input_df,k=2)), I get the following error for any k>1: Error in optim(method = "BFGS", par = c(gamma0 = 0, gamma1 = 0, gamma2 = 0, : initial value in 'vmmin' is not finite
From reading other posts with similar issues, I gather this is likely an issue with the inits parameter, and that I might have to generate my own inits function for this particular dataset. But I haven't found any guidance on how to do this for spline fits or what goes into that parameter. Am I correct that this is what's causing the error, and if so how should an inits function be determined?
input_df: input_df.xlsx
Thanks in advance!