diff --git a/NEWS.md b/NEWS.md index 3f261c7bd..784ce1572 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,7 @@ - a bug was fixed where `forecast_secondary()` did not work with fixed delays. By @sbfnk in #717 and reviewed by @seabbs. - a bug was fixed that caused delay option functions to report an error if only the tolerance was specified. By @sbfnk. - a bug was fixed that led to the truncation PMF being shortened from the wrong side when the truncation PMF was longer than the supplied data. By @seabbs in #736 and reviewed by @sbfnk and @jamesmbaazam. +- a bug was fixed that caused internal validation checks on delay distributions to fail if they contained non-parametric distributions. By @jamesmbaazam in #750 and reviewed by @seabbs. ## Documentation diff --git a/R/checks.R b/R/checks.R index 4ad82662a..a43d8eb29 100644 --- a/R/checks.R +++ b/R/checks.R @@ -81,12 +81,14 @@ check_stan_delay <- function(dist) { # Check that `dist` has parameters that are either numeric or normal # distributions with numeric parameters and infinite maximum numeric_or_normal <- unlist(lapply(seq_len(ndist(dist)), function(id) { - params <- get_parameters(dist, id) - vapply(params, function(x) { - is.numeric(x) || - (is(x, "dist_spec") && get_distribution(x) == "normal" && - is.infinite(max(x))) - }, logical(1)) + if (get_distribution(dist, id) != "nonparametric") { + params <- get_parameters(dist, id) + vapply(params, function(x) { + is.numeric(x) || + (is(x, "dist_spec") && get_distribution(x) == "normal" && + is.infinite(max(x))) + }, logical(1)) + } })) if (!all(numeric_or_normal)) { stop( diff --git a/README.md b/README.md index 1f86d6207..d21b2dcde 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,20 @@ cost of the granularity of estimates or real-time performance, include: - Adjustment for the remaining susceptible population beyond the forecast horizon. +By default, all these models are fit with [MCMC +sampling](https://mc-stan.org/docs/reference-manual/mcmc.html) using the +[`rstan`](https://mc-stan.org/users/interfaces/rstan) R package as the +backend. Users can, however, switch to use approximate algorithms like +[variational +inference](https://en.wikipedia.org/wiki/Variational_Bayesian_methods), +the +[pathfinder](https://mc-stan.org/docs/reference-manual/pathfinder.html) +algorithm, or [Laplace +approximation](https://mc-stan.org/docs/reference-manual/laplace.html) +especially for quick prototyping. The latter two methods are provided +through the [`cmdstanr`](https://mc-stan.org/cmdstanr/) R package, so +users will have to install that separately. + The documentation for `estimate_infections` provides examples of the implementation of the different options available. @@ -175,6 +189,12 @@ the two main functions in the package and how to set up them up. It also discusses how to summarise and visualise the results after running the models. +More broadly, users can also learn the details of estimating delay +distributions, nowcasting, and forecasting in a structured way through +the free and open short-course, [“Nowcasting and forecasting infectious +disease dynamics”](https://nfidd.github.io/nfidd/), developed by some +authors of this package. +