The model must have the same likelihood structure, because this is what is picked up by the post processing methods such as posterior_predict
. That is, you may add additional parameters as long as they just come into play via the prior. See ?stanvar
for an example.
With regard to your workflow, I would replace the whole stan model in slot fit
. Slot model
is merely a high level storage point of the stan code that is actually also stored somewhere deeper in fit
. The workflow would be something like:
- Create an “empty” brmsfit object of your model via
brm(..., chains = 0)
. - Generate and amend the Stan code and replace slot
fit
with the output ofrstan::stan_model
(you may also want to change the Stan code in slotmodel
). - Run
update(<model>, recompile = FALSE)
Not entirely sure if it works exactly this way, but it should provide a start to play around with.