chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
55 stars 27 forks source link

call to offset() ignored in formula when using flexsurvspline #66

Closed NickSauve closed 5 years ago

NickSauve commented 5 years ago

Dear Christopher,

I am trying to use Royston-Parmar models with the flexsurvspline function, and it appears the offset() function from package stats is ignored.

What i mean is the two following call to flexsurvspline return the same model :

fit1<- flexsurvspline(Surv(time , status) ~ offset(age),data=mydata) fit2<- flexsurvspline(Surv(time , status) ~ 1,data=mydata)

while fit1 should have constrained the linear predictor of age to 1, age is instead simply discarded from the model.

Is there a way to make it work ?

chjackson commented 5 years ago

If you want a covariate in the model with a fixed coefficient of 1, simply use the inits argument to set the initial value for this parameter to 1, and use the fixedpars argument to indicate that this parameter should be fixed at its initial value and not estimated.