Passing Pre-specified Model Coefficients


I wanted to ask, is there a way to pass pre-specified model coefficients to a model in tidymodels? My goal is to evaluate the performance of a pre-existing model in published literature in a survival model scenario. I have attempted to use the offset function for each of the individual variables to no avail. Thank you very much in advance for your help!

parsnip and its extension packages generally "only" wrap other modelling packages, so if you can pass coefficients depends on the underlying engine. For a Cox PH model with the survival package, you could pass the model coefficients as the initialization values and then restrict the number of iterations for the estimation process to 0. So something along these lines:

# with the survival package directly
engine_fit <- survival::coxph(formula, data = train_dat,
                          init = model_coef,
                          control = survival::coxph.control(iter.max = 0))

# wrapped in the tidymodels framework
censored_fit <- proportional_hazards() %>% 
  set_engine("survival", init = model_coef,
             control = survival::coxph.control(iter.max = 0)) %>% 
  fit(formula, data = train_dat)

Hi Hannah, thank you very much for your help!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.