epiverse-trace / serofoi

Estimates the Force-of-Infection of a given pathogen from population based sero-prevalence studies
https://epiverse-trace.github.io/serofoi/
Other
17 stars 4 forks source link

Divergent Transitions in fit_seromodel #203

Closed JDConejeros closed 3 weeks ago

JDConejeros commented 3 weeks ago

Is your feature request related to a problem? Please describe.

I encountered an issue while fitting a seromodel using the serofoi package. Specifically, when using the fit_seromodel function with the following parameters:

seromodel_log_time <- fit_seromodel(
  serosurvey = veev2012,
  model_type = "time",
  foi_prior = sf_uniform(min = 0, max = 10),
  is_log_foi = TRUE,
  foi_index = get_foi_index(veev2012, group_size = 10),
  is_seroreversion = TRUE,
  iter = 10000
)

The process resulted in a warning about 52 divergent transitions after warmup, which suggests potential problems with the model's sampling and posterior reliability. Despite increasing the number of iterations, the issue persists, indicating that the model might not explore the parameter space effectively.

Describe the solution you'd like

Maybe:

Additional context

Warning messages: 1: There were 52 divergent transitions after warmup. See https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup to find out why this is a problem and how to eliminate them. 2: Examine the pairs() plot to diagnose sampling problems.

ben18785 commented 3 weeks ago

Thanks @JDConejeros.

This is relatively few divergent iterations if you are running a model with 10,000 iterations (I think across 4 chains) in total. To be honest, I only tend to pay attention to these warnings if the number of divergent iterations becomes a reasonable proportion (say ~a few % or more) of the overall number of iterations.

This isn't me saying that divergent iterations aren't important to look at; just that I think that, on this example alone, I don't think we necessarily need to modify the package / tutorials to cover this, particularly because Stan already has ample info on this. Happy to revisit this if examples turn up in the future which have more widespread divergent iterations.