Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tbl.now
Type: Package
Title: Tidy Data and Workflow Layer for Epidemic Nowcasting
Version: 1.1.0
Version: 1.1.1
Authors@R:
c(person("Rodrigo", "Zepeda-Tello", , "rzepeda17@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4471-5270")),
Expand Down Expand Up @@ -60,19 +60,19 @@ Imports:
cli,
generics,
grid,
dplyr,
dplyr (>= 1.1.0),
ggplot2,
lifecycle,
lubridate,
methods,
pillar,
rlang,
rlang (>= 1.0.0),
S7,
scales,
stats,
tibble,
tidyr,
tidyselect,
tidyselect (>= 1.2.1),
utils
URL: https://rodrigozepeda.github.io/tbl.now/,
https://github.com/RodrigoZepeda/tbl.now
Expand Down
40 changes: 40 additions & 0 deletions DEVELOPMENT_SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,46 @@ S7 class names can contain `::`, which S3 method names cannot represent. Use
the existing `.onLoad()` registration pattern where required. Re-export
`generics::tidy`; do not create a competing generic.

## Backtests, checkpoints and combining

`nowcast_backtest()` fits every (engine, date) pair, dates outer and engines
inner. Two features are built on that order and must keep working when the
backtest changes:

- **`backtest_combine()`** joins backtests run separately -- other engines on
the same dates, or the same engines on new dates. Combining what one call
would have produced must return that call's object: same rows in the same
order, same `methods`, `now_dates`, `timings` and `truth`, differing only in
`elapsed_seconds`. Test that equality, with strata and a grouped `tbl_now`.
A (method, `now`) fit in two backtests aborts, a success replaces a failure of
the same fit, and backtests that differ in event date, strata, `truth_axis`,
`truth_type`, `keep_draws` or quantile levels are refused. If you add a field
or table to the `nowcast_backtest` object, teach `backtest_combine()` to
combine it.
- **`checkpoint_file`** lets an interrupted backtest resume. Only the main R
session touches the file; `future` workers return their fits and never see
the path, so every plan is safe. Never write from a worker, and never write
in place: write a temporary file beside it and rename. The file stores a
fingerprint of everything a fit depends on (data, `seed`, `keep_draws`, truth
settings, each engine by label); a mismatch aborts rather than mixing
backtests. A new argument that changes what a fit computes must join the
fingerprint. Failed fits are stored but retried on resume. A resumed backtest
must equal an uninterrupted one.

Test both under `parallel = TRUE` with a sequential plan and, where the
installed package is the code under test, real `multisession` workers.

## Dependencies and the environment

Test on the versions CI uses (the current R release and current CRAN
packages), not an old container. A failure that only an old R or old dependency
shows is a missing minimum: declare it with `>=` in `DESCRIPTION` (`Depends`,
`Imports` or `Suggests`) rather than working around it in the code, and say so
in the commit message. Give a minimum to every package whose newer function or
argument the code uses (`rlang::hash()` needs rlang 1.0.0, `.by` in dplyr needs
1.1.0). Compiled packages built under an older R do not load in a newer one;
reinstall them after upgrading R.

## Summaries and diagnostics

`validate_tbl_now()` and `diagnose()` share `.tbl_now_findings()`. Add structural
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export(align_weeks)
export(as_tbl_now)
export(as_tibble)
export(autoplot)
export(backtest_combine)
export(cases_per_date)
export(censor_reporting_delays)
export(censor_reporting_delays_above)
Expand Down
29 changes: 29 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# tbl.now 1.1.1

## `simulate_batch()` works on older R versions

`simulate_batch()` aborted with "Every report date is closed" on older R
versions (seen on R 4.3.3) whatever `closed_dates` was, because `setdiff()`
returns plain numbers there and `match()` cannot compare them with dates. The
open dates are now recovered from their numeric values, which is correct on
every R version.

## `nowcast_backtest()` can resume, and backtests can be combined

`nowcast_backtest()` gains `checkpoint_file` (#90). Each finished
(engine, date) fit is saved to that file; running the same call again refits
only the fits that are missing, and a fit that failed is retried. The file
records a fingerprint of the data, `seed`, `keep_draws`, the truth settings and
each engine, and a call that differs from it aborts rather than mixing fits from
two backtests; new `now_dates` and new engines are added to it. Only the main R
session writes the file (through a temporary file and a rename), so every
`future::plan()` is safe with `parallel = TRUE`, which then runs and saves the
fits in waves of `future::nbrOfWorkers()`.

The new `backtest_combine()` joins backtests that were run separately (#91):
different models on the same dates, the same model on new dates, or both. Combining
what one call would have produced gives the same object as that call. It aborts
when a (method, date) fit appears twice or when the backtests differ in strata,
`truth_axis`, `truth_type`, `keep_draws` or quantile levels, and
`only_common_dates = TRUE` keeps only the dates every method has.

# tbl.now 1.1.0

## Breaking: backtest methods are compared on the targets all of them scored
Expand Down
Loading
Loading