epinowcast / epidist

An R package for estimating epidemiological delay distributions
http://epidist.epinowcast.org/
Other
12 stars 4 forks source link

Add option to pass custom additional priors #123

Open athowes opened 3 months ago

athowes commented 3 months ago

The model has some parameters which are not brms defaults. These parameters are introduced by epidist_stancode. Currently, users do not have an easy way to modify these priors.

We could add some way for users to do so. Likely, this would be within the epidist_prior function.

See my comment on #78 suggesting:

Add ability to pass in custom Stan prior to epidist_stancode.latent_individual for additional Stan parameters Alter epidist_stancode within epidist to take prior as an argument But then the blocker here is that epidist_prior should be edited to contain brmsprior and custom Stan code or something like that.. so it's unclear how well it works

Doing this would reopen for me the argument that custom Stan code for model components should be grouped together with the other parts. (For example the family Stan code should be with epidist_family).

athowes commented 1 day ago

There are no model priors in here. Add functionality for latent parameter priors at some point?

_Originally posted by @athowes in https://github.com/epinowcast/epidist/pull/183#discussion_r1691552579_

(This is challenging because it requires changes to the Stan code)

athowes commented 1 day ago

After the updates to prior interface we now have model-specific priors stored in epidist_model_prior.default.

We need to be careful because changes to these priors will require editing the Stan code, which is created as follows (after the priors):

epidist_prior <- epidist_prior(
  data = data, family = epidist_family, formula = formula
)
epidist_stancode <- epidist_stancode(data = data, family = epidist_family)

As well, we probably can't do Reduce with replace_prior when the prior is in Stan code. Unless we make it so that these priors are specified as brms priors and then in the Stan code part (or at least somewhere before the model) we remove them and make the Stan code out of them. That might be a big ask.