I have trouble including a spline transformation to one of the variables in the ‘event’ submodel of a stan_jm() joint model.

No issues with splines in the longitudinal submodel as you can see with the model specification below (using sample data/notation from stan_jm vignette)

`mod1 <- stan_jm(formulaLong = logBili ~ sex + trt + bSpline(year,degree=3,knots=4) + (bSpline(year,degree=3,knots=4) | id), dataLong = pbcLong, formulaEvent = survival::Surv(futimeYears, death) ~ sex + trt + age, dataEvent = pbcSurv, cores=parallel::detectCores(), time_var = "year", assoc = NULL, chains = 2, refresh = 20, iter=5000, seed = 12345) `

However, the code below which attempts to use a b-spline on the age covariate in the event submodel gives as error.

`mod2 <- stan_jm(formulaLong = logBili ~ sex + trt + bSpline(year,degree=3,knots=4) + (bSpline(year,degree=3,knots=4) | id), dataLong = pbcLong, formulaEvent = survival::Surv(futimeYears, death) ~ sex + trt + bSpline(age,degree = 3,knot=3), dataEvent = pbcSurv, cores=parallel::detectCores(), time_var = "year", assoc = NULL, chains = 2, refresh = 20, iter=5000, seed = 12345)`

This is the error message:

`Error in rcpp_bSpline_basis(x = xx, df = df, degree = degree, internal_knots = knots, : Internal knots must be set inside of boundary knots.`

I have tried to use other spline packages or polynomial transformation, all give different types of errors (splines, splines2, rms:rcs(), poly() etc.). Is there any way to work around this? Thank you!