Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
77cc3f5
Simplify estimate_truncation return structure
sbfnk Dec 17, 2025
1641101
Add get_samples.estimate_truncation method
sbfnk Dec 17, 2025
20f45dd
Add summary.estimate_truncation method
sbfnk Dec 17, 2025
0518970
Update estimate_truncation tests for new structure
sbfnk Dec 17, 2025
9574383
Update documentation for estimate_truncation changes
sbfnk Dec 17, 2025
3bdfe36
Add NEWS entry for estimate_truncation changes
sbfnk Dec 17, 2025
fb8a172
Merge main into branch
sbfnk Dec 19, 2025
1d7f587
Add get_dist() generic and estimate_truncation method
sbfnk Dec 19, 2025
9a4fe40
Remove dist from return, use get_dist() accessor
sbfnk Dec 19, 2025
6d9a516
Update summary.estimate_truncation to use get_dist()
sbfnk Dec 19, 2025
04b1143
Update tests to use get_dist() accessor
sbfnk Dec 19, 2025
0fd9e90
Update NEWS for get_dist() accessor
sbfnk Dec 19, 2025
a948b41
Rename get_dist() to get_delay() for consistency
sbfnk Dec 19, 2025
e142e65
Merge branch 'main' into refactor/estimate-truncation-s3
sbfnk Jan 5, 2026
8f4e7f8
Fix backward compat accessors to return values and use I()
sbfnk Jan 5, 2026
b95bc67
Update vignette to use get_delay() instead of $dist
sbfnk Jan 5, 2026
0b8684d
Consolidate NEWS.md entry for get_delay()
sbfnk Jan 5, 2026
aa6b449
Clarify get_delay() extracts truncation delay distribution
sbfnk Jan 5, 2026
3df3e60
Merge remote-tracking branch 'origin/refactor/estimate-truncation-s3'…
sbfnk Jan 5, 2026
b69669c
Add regression tests for deprecated accessor return values
sbfnk Jan 5, 2026
18d3f18
Use as.data.frame() in snapshots to avoid data.table print format issues
sbfnk Jan 5, 2026
08cc931
Merge branch 'main' into refactor/estimate-truncation-s3
sbfnk Jan 5, 2026
f89e251
Replace get_delay() with get_delays() returning named list
sbfnk Jan 6, 2026
086ff37
Update documentation
epiforecasts-workflows[bot] Jan 9, 2026
a66ec9f
Revert "Use as.data.frame() in snapshots to avoid data.table print fo…
sbfnk Jan 9, 2026
12ace0a
Add test for get_delays() fixed parameter values
sbfnk Jan 9, 2026
fb73240
Remove internal element access from estimate_truncation example
sbfnk Jan 9, 2026
dc5ceeb
Remove extra components from stan_data in estimate_truncation
sbfnk Jan 9, 2026
1ad9b07
Refactor get_delays and summary methods
sbfnk Jan 9, 2026
3602868
Use get_predictions() in plot.estimate_truncation
sbfnk Jan 9, 2026
98f7636
Add print method for summary and improve deprecated accessors
sbfnk Jan 9, 2026
246f861
Fix line length lint issues in summarise.R
sbfnk Jan 9, 2026
f98dd05
Update estimate_truncation example to reflect summary changes
sbfnk Jan 9, 2026
44d427a
Rename obs to preds in plot.estimate_truncation for clarity
sbfnk Jan 9, 2026
b442658
Use x$observations for raw data and get_predictions for CrIs in plot
sbfnk Jan 9, 2026
2f40b7f
Refactor [[.estimate_truncation to delegate to $ method
sbfnk Jan 9, 2026
8dba8ff
Compute predictions on demand from samples
sbfnk Jan 9, 2026
d527a59
Remove last_confirm from get_predictions output
sbfnk Jan 9, 2026
65afc2c
get_predictions returns only predictions, no observations
sbfnk Jan 9, 2026
506bfc8
Add epinowfit superclass to estimate_truncation
sbfnk Jan 9, 2026
dcc27d3
Simplify get_samples and fix dt variable naming
sbfnk Jan 9, 2026
c23863f
Fix line length and indentation lint issues
sbfnk Jan 12, 2026
99620bc
Consolidate get_delays methods into get_delays.epinowfit
sbfnk Jan 12, 2026
327cbaa
Refactor reconstruct_delay into smaller helper functions
sbfnk Jan 12, 2026
72cd0dc
Update documentation
epiforecasts-workflows[bot] Jan 12, 2026
95f5621
Add get_observations generic and document helpers
sbfnk Jan 12, 2026
a60b8a4
Merge remote-tracking branch 'origin/refactor/estimate-truncation-s3'…
sbfnk Jan 12, 2026
bf297c2
Add full documentation for internal helper functions
sbfnk Jan 13, 2026
6950fb6
Rename dist_types() and fix get_samples consistency
sbfnk Jan 13, 2026
e49ce6a
Fix test to use correct parameter names after get_samples change
sbfnk Jan 13, 2026
fad9fb7
Refactor extract_delays/parameters to take args separately
sbfnk Jan 13, 2026
bdfdff6
Update documentation
epiforecasts-workflows[bot] Jan 13, 2026
cb341ff
Make args required in extract_delays and extract_parameters
sbfnk Jan 13, 2026
aaa1a06
Merge branch 'refactor/estimate-truncation-s3' of github.com:epiforec…
sbfnk Jan 13, 2026
2bad2bf
Update documentation
epiforecasts-workflows[bot] Jan 13, 2026
d60dfbf
Fix extract_* calls after making args required
sbfnk Jan 13, 2026
64bc1d9
Merge branch 'refactor/estimate-truncation-s3' of github.com:epiforec…
sbfnk Jan 13, 2026
2fbb304
Address reviewer nitpicks for code clarity
sbfnk Jan 13, 2026
6d240d7
Address reviewer nitpicks for robustness
sbfnk Jan 13, 2026
f4910c9
Remove get_observations in favour of direct access
sbfnk Jan 13, 2026
fce855a
Fix stray newline in test comment and add issue reference
sbfnk Jan 13, 2026
8fec943
Fix delay parameter naming with mixed parametric/nonparametric delays…
sbfnk Jan 14, 2026
2105154
Update documentation
epiforecasts-workflows[bot] Jan 14, 2026
4bc0867
Refactor extract_delays to reduce cyclomatic complexity
sbfnk Jan 14, 2026
bdbeddd
Update documentation
epiforecasts-workflows[bot] Jan 14, 2026
e3abba4
Add unit tests for build_delay_name_lookup
sbfnk Jan 15, 2026
75df2a7
Simplify parameter recovery test now that bug #1236 is fixed
sbfnk Jan 15, 2026
5132032
Simplify get_delays.estimate_truncation to use reconstruct_delay
sbfnk Jan 15, 2026
38a9a60
Extract prepare_truncation_obs helper function
sbfnk Jan 15, 2026
67d10e3
Fix deprecated accessor methods returning NULL
sbfnk Jan 15, 2026
6939b15
Add tests for estimate_truncation data processing and correctness
sbfnk Jan 15, 2026
6e0e0c4
Document get_predictions for estimate_truncation in NEWS
sbfnk Jan 15, 2026
b87e930
Merge remote-tracking branch 'origin/refactor/estimate-truncation-s3'…
sbfnk Jan 15, 2026
8b2e654
Update documentation
epiforecasts-workflows[bot] Jan 15, 2026
a6003a9
Fix flaky estimate_truncation tests
sbfnk Jan 16, 2026
53dd219
Merge remote-tracking branch 'origin/refactor/estimate-truncation-s3'…
sbfnk Jan 16, 2026
d74d860
Add get_delay() convenience function
sbfnk Jan 19, 2026
776fea1
Remove redundant get_delays.estimate_truncation method
sbfnk Jan 19, 2026
946a9bc
Add parameter recovery integration test for estimate_truncation
sbfnk Jan 19, 2026
06fee49
Fix documentation reference to removed method
sbfnk Jan 19, 2026
14f6146
Extract merge_predictions_obs helper and use get_delay in examples
sbfnk Jan 19, 2026
e89e1e5
Rename merge_predictions_obs to merge_truncation_predictions_obs
sbfnk Jan 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
S3method("!=",dist_spec)
S3method("$",epinow)
S3method("$",estimate_secondary)
S3method("$",estimate_truncation)
S3method("+",dist_spec)
S3method("==",dist_spec)
S3method("[[",epinow)
S3method("[[",estimate_truncation)
S3method(c,dist_spec)
S3method(collapse,dist_spec)
S3method(collapse,multi_dist_spec)
S3method(discretise,dist_spec)
S3method(discretise,multi_dist_spec)
S3method(fix_parameters,dist_spec)
S3method(fix_parameters,multi_dist_spec)
S3method(get_delay,default)
S3method(get_delays,epinowfit)
S3method(get_predictions,estimate_infections)
S3method(get_predictions,estimate_secondary)
S3method(get_predictions,estimate_truncation)
S3method(get_predictions,forecast_infections)
S3method(get_predictions,forecast_secondary)
S3method(get_samples,estimate_infections)
S3method(get_samples,estimate_secondary)
S3method(get_samples,estimate_truncation)
S3method(get_samples,forecast_infections)
S3method(get_samples,forecast_secondary)
S3method(is_constrained,dist_spec)
Expand All @@ -35,12 +41,14 @@ S3method(plot,forecast_infections)
S3method(plot,forecast_secondary)
S3method(print,dist_spec)
S3method(print,epinowfit)
S3method(print,summary.estimate_truncation)
S3method(sd,default)
S3method(sd,dist_spec)
S3method(sd,multi_dist_spec)
S3method(summary,epinow)
S3method(summary,estimate_infections)
S3method(summary,estimate_secondary)
S3method(summary,estimate_truncation)
S3method(summary,forecast_infections)
export(Fixed)
export(Gamma)
Expand Down Expand Up @@ -86,6 +94,8 @@ export(forecast_infections)
export(forecast_opts)
export(forecast_secondary)
export(generation_time_opts)
export(get_delay)
export(get_delays)
export(get_distribution)
export(get_parameters)
export(get_pmf)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ The function interface remains unchanged.
- The `output` argument now controls what is saved to disk, not the return structure.
- **Deprecated**: The previous return structure with `$estimates`, `$estimated_reported_cases`, `$summary`, `$plots`, and `$estimate_infections` elements is deprecated. Backward compatibility is provided via `$` and `[[` operators with deprecation warnings.
- `plot.estimate_infections()` and `plot.forecast_infections()` now accept a `CrIs` argument to control which credible intervals are displayed.
- Refactored `estimate_truncation()` to return a proper S3 object with a simplified structure.
- Renamed return elements: `obs` → `observations`, `data` → `args`.
- Removed elements: `last_obs` (now included in `observations`), `cmf` and `dist`.
- Use `get_delays(object)$truncation` to extract the estimated truncation distribution for use in `epinow()` or `estimate_infections()`.
- Use `get_predictions(object)` to extract truncation-adjusted (nowcast) estimates that can be compared to observed data.
- Use `get_samples(object)` to extract posterior samples.
- Use `summary(object)` to get parameter estimates as a data.table.
- **Deprecated**: Accessing `$dist` via `$` or `[[` triggers deprecation warnings. Use `get_delays()$truncation` instead.
- Added `get_delays()` generic function to extract delay distributions from fitted models as a named list of `dist_spec` objects. Works with `estimate_infections()`, `estimate_secondary()`, and `estimate_truncation()`. Also added `get_delay(object, type)` as a convenience function to extract a single delay by name (e.g., `get_delay(fit, "truncation")`).
- Added a `style` argument to `plot_estimates()` and related plot methods to display credible intervals as error bars (`"linerange"`) instead of the default ribbons (`"ribbon"`). Error bars can be clearer for weekly or aggregated data.
- **Internal**: Stan model delay identifiers have been renamed for semantic clarity (`delay_id` → `delay_id_reporting`, `gt_id` → `delay_id_generation_time`, `trunc_id` → `delay_id_truncation`). This may affect users who access Stan models directly.
- **Internal**: Stan model parameter names have been renamed for clarity (`dispersion` → `reporting_overdispersion`, `frac_obs` → `fraction_observed`). This simplifies internal code by removing post-hoc parameter renaming. This may affect users who access Stan models directly or use custom priors with the old parameter names.
Expand Down
2 changes: 1 addition & 1 deletion R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ create_stan_delays <- function(..., time_points = 1L) {
ret$weight <- array(rep(1, ret$n_p))
ret$weight[weight_priors] <- time_points
## assign distribution
ret$dist <- array(match(distributions, c("lognormal", "gamma")) - 1L)
ret$dist <- array(match(distributions, dist_spec_distributions()) - 1L)

names(ret) <- paste("delay", names(ret), sep = "_")
ret <- c(ret, as.list(delay_ids))
Expand Down
16 changes: 16 additions & 0 deletions R/dist_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,22 @@ natural_params <- function(distribution) {
)
}

#' Get parametric distribution types
#'
#' @description `r lifecycle::badge("experimental")`
#' Returns the mapping of Stan integer codes to distribution names.
#' Stan uses 0 for lognormal, 1 for gamma.
#' @return A character vector of distribution names in Stan order.
#' @keywords internal
#' @examples
#' \dontrun{
#' dist_spec_distributions()
#' dist_spec_distributions()[1] # "lognormal"
#' }
dist_spec_distributions <- function() {
c("lognormal", "gamma")
}

#' Get the lower bounds of the parameters of a distribution
#'
#' @description `r lifecycle::badge("experimental")`
Expand Down
2 changes: 1 addition & 1 deletion R/estimate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,6 @@ estimate_infections <- function(data,
)

## Join stan fit if required
class(ret) <- c("epinowfit", "estimate_infections", class(ret))
class(ret) <- c("estimate_infections", "epinowfit", class(ret))
ret
}
2 changes: 1 addition & 1 deletion R/estimate_secondary.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ estimate_secondary <- function(data,
observations = reports
)

class(ret) <- c("epinowfit", "estimate_secondary", class(ret))
class(ret) <- c("estimate_secondary", "epinowfit", class(ret))
ret
}

Expand Down
Loading
Loading