epinowcast / epidist

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

Automate setting prior in case where there is no model #305

Open athowes opened 3 weeks ago

athowes commented 3 weeks ago

As of PR #282 we have code like:

  if ("sigma" %in% names(formula$pforms)) {
    # Case with a model on sigma
    sigma_prior <- brms::prior(
      "normal(-0.7, 0.4)", class = "Intercept", dpar = "sigma"
    )
  } else if ("sigma" %in% names(formula$pfix)) {
    # Case with sigma fixed to a constant
    sigma_prior <- NULL
  } else {
    # Case with no model on sigma
    sigma_prior <- brms::prior(
      "lognormal(-0.7, 0.4)", class = "sigma", lb = 0, ub = "NA"
    )
  }

Within epidist_family_prior.lognormal. This is to deal with 3 cases:

  1. Model on the dpar
  2. No model on the dpar
  3. The dpar set to a constant

Ideally we should be automating parts of this. Specifically here, setting the prior in the case that there is no model. Can this be obtained as a tranformation of the case where there is a model? And then it can be done at a higher level e.g. in epidist_prior.

This also flags issues with the priors being connected to link functions, which can be changed by the user, and we don't currently account properly for.

Edit: we have also already discussed another issue which would provide a solution to this https://github.com/epinowcast/epidist/issues/266. Summary: just enforce there is always a model ~ 1. This is mentioned in #307.

seabbs commented 3 weeks ago

one of this and #306 seems like a duplicate. What do you mean by no model? Do you mean no linear model but still a parameter (i.e sigma vs no sigma)? if so can you clarify and add in the already discussed option of enforcing that we always have a linear model (i.e the default is sigma ~ 1.

athowes commented 3 weeks ago

There are 3 cases:

  1. Model on the dpar: then it'll be called Intercept_sigma
  2. No model on the dpar (https://github.com/epinowcast/epidist/issues/305): then it'll just be called sigma
  3. The dpar set to a constant (https://github.com/epinowcast/epidist/issues/306): then it'll be called sigma but will be set to a constant

I agree it's a bit confusing.