
Changelog
tbl.now 0.12.0
Batch detection, rebuilt around a conservation law
The report-batch detectors were rebuilt on a single, exact principle: a batch moves reports along the report axis without creating them, so a window of report dates spanning both the lull and the release has an unchanged total, whereas a genuine epidemic surge inflates it. The previous heuristic detect_report_batches() / plot_report_batches() (multi-signal robust-z, and the model-based conditional scan) are removed and replaced by three model-free, r lifecycle::badge("experimental") functions. Each derives its mathematics in a “The mathematics” section of its help page.
- New
batch_screen()returns, per (report date, stratum), thedeficit(reports missing beforehand — sensitive to a batch) anddelta(the window total minus its expected value — sensitive to a real surge), and classifies each date as"batch","surge","batch_and_surge","hold_or_deletion"or"none". The transport (batch) test conditions on the window total, so its size does not depend on the unknown incidence nor on the quality of the baseline; the baseline itself is refit from report dates outside each candidate window, which makesdeltainvariant to a within-window batch pathwise. It handles all data types, including"count-cumulative"(signed increments), and takes aperiodargument that absorbs a fixed reporting schedule (weekends, holidays). - New
batch_shape_test()tests whether a flagged report date drew on unusually old event dates, by a permutation rank-sum on the reporting delays. It is exactly distribution-free whenever incidence is locally log-linear. - New
simulate_batch()plants a known batch (a deterministic close-and-release) in atbl_now, for validation and teaching. - New Batch detection article, with worked examples on dengue (a planted batch), FluSight (count-cumulative), and a weekend reporting schedule.
tbl.now 0.10.1
-
autoplot()’s reporting-delay calendar panels (delay_weekday,delay_week,delay_month) are now normalized: each event date’s mean delay is divided by the overall mean delay, so1marks an average delay and a dashed reference line is drawn there. Previously the ungrouped panels plotted the raw mean delay while theby_strata = TRUEpanels were already normalized. They now share one scale, matching the case-count calendar panels and making the calendar pattern comparable across strata (y-axis:"Normalized delay"). -
plot_delay_drift()’swindownow defaults to7periods regardless of the time unit — 7 days for daily data, 7 weeks for weekly data. Previously the default was data-dependent (max(5, n_periods / 20)), which produced a very wide window on long series. Passwindow =to smooth a specific series. - Internal: replaced the remaining base-R data-frame subsetting and column assignment (
df[cond, ],df$col <- ...) outside the converters with the equivalentdplyrverbs (filter(),select(),slice(),mutate()). No user-facing behaviour change. The examples and vignettes now likewise usedplyr::filter()rather than[(e.g.dplyr::filter(batches, batch)).
tbl.now 0.10.0
New
get_nth_reported_cases(): the cumulative cases reported for each event date within a given delay.delay = 0gives the initial snapshot,delay = 1adds the delay-1 reports, and so on;delay = Inf(or the maximum delay) matchesget_latest_reported_cases(). Documented alongsideget_initial_reported_cases()andget_latest_reported_cases().Performance:
get_latest_reported_cases(),get_initial_reported_cases()andget_nth_reported_cases()are substantially faster (~3-4x on the bundled data) — the aggregation now runs on a declassed data frame and thetbl_nowis reconstructed once, with identical output.The experimental diagnostic functions (
plot_delay_drift(),test_delay_drift(),test_delay_changepoint(),detect_report_batches(),plot_report_batches()) now carry a lifecycle experimental badge.test_delay_drift()andtest_delay_changepoint()additionally emit acliwarning that they are experimental, their results are not guaranteed and their interface may change. Flagged batches, change points and trend changes are surfaced as potential (e.g. “potential batches”, “potential change point”).New
detect_report_batches()andplot_report_batches()to detect batch reporting — report dates on which a laboratory releases a backlog of many old cases at once. Working on the report-date axis, it flags a report date using up to four selectable robust-anomaly signals (volume,delay,span,gap), AND-ed together. Requiring thedelay(long/dispersed delays) signal alongsidevolumeis what distinguishes a batch from an epidemic peak: a peak also spikes the report volume, but its cases keep the normal short delay distribution, so its delay score stays low.detect_report_batches()returns a per-report-date table with the features, robust scores and abatchflag;plot_report_batches()shows the report-volume and mean-delay timelines with the flagged dates marked.New
test_delay_changepoint()complementstest_delay_drift(): where the latter tests for a gradual monotonic trend, this tests for a single abrupt change point in the per-period delay summaries using Pettitt’s nonparametric test (implemented directly, no extra dependency). It reports the estimated change date, the before/after level of the statistic, the shift and achangepoint_detectedverdict, per stat (median / mean / IQR / 10-90 spread) and per stratum, on mature data only.plot_delay_drift()gained achangepointargument: set it toTRUEto mark the estimated change point of the median delay on the fan chart with a vertical line.-
New
plot_delay_drift()andtest_delay_drift()to answer “do reporting delay distributions drift over time?”.-
plot_delay_drift()draws a rolling fan chart of the count-weighted delay distribution indexed by event date: a solid rolling median, a dashed rolling mean, and 25-75% / 10-90% quantile bands. The recent, not-yet-fully reported region (after thelevelincompleteness cutoff) is shaded grey so the truncation-induced dip is not mistaken for drift. Supportsby_strata. -
test_delay_drift()runs an autocorrelation-robust monotonic-trend test (Hamed-Rao modified Mann-Kendall by default, with Yue-Pilon and block-bootstrap options via the newmodifiedmkSuggests) on the per-period delay summaries, testing both a location statistic (median/mean) and a dispersion statistic (IQR / 10-90 spread), on mature data only. Returns a tidy tibble with the Kendall tau, Sen’s slope, p-value and adriftverdict, per stat and stratum.
-
autoplot()gained aby_strataargument (defaultFALSE). WhenTRUE, every panel is split by stratum: the calendar and delay boxplots become dodged boxes (one per stratum, side by side), the epidemic process and both periodograms become one coloured line per stratum (no area fill), and the delay distribution becomes dodged bars. Boxplots are normalized per stratum (1 = that stratum’s own average) so the calendar pattern is comparable across strata, and strata are coloured with aviridisscale. A companionstrataargument chooses which columns to group on (defaults to the object’sstrata; pass a subset such asstrata = "gender"to override).autoplot()now draws reporting-delay diagnostic panels alongside the case-count ones, so you can see delay effects: the mean reporting delay by day of week / week of year / month (delay_weekday,delay_week,delay_month), and a periodogram of the mean-delay series (delay_seasonality) that reveals periodicity in the delay itself. The delay panels are computed on the complete part of the series (before the incompleteness line) so recent truncation does not bias them.autoplot()gained apanelsargument to choose which panels to draw. It accepts the concrete panel keys, or the aliases"all"(default),"calendar"and"delay_calendar". Selecting a single panel returns it as a plainggplot2object instead of apatchwork. Unknown panels error; panels that do not apply to the data’s time unit are skipped with a warning.New pkgdown article “One dataset, many nowcasts” now also demonstrates that temporal (delay) effect columns are carried into
epinowcast(metareference/metareport),baselinenowcast(long) andepidist, with a table clarifying which target formats can hold covariates and how each model can use them.temporal_effects()gained an after-holiday and after-weekend effect via the newholiday_lagsandweekend_lagsarguments. Each takes a non-negative integer depthN; materialising the spec then adds indicator columns..._holiday_lag_1 … ..._holiday_lag_N(and likewise..._weekend_lag_k) that flag dates falling exactlykworking days after a holiday / weekend. Working days skip weekends and holidays, so the effect lands on the first day(s) back at work — designed to capture the rise in cases just after a holiday or weekend.holiday_lagsrequires aholidayscalendar. The columns are picked up automatically by everytbl_now_to_*()converter (as covariate columns) and bydiseasenowcasting::nowcast().Documented and tested attaching temporal effects to the report date (in addition to the default event date) via
add_temporal_effects(x, spec, date_type = "report_date"). Event- and report-date effects can coexist on the sametbl_now; both sets of columns (.event_*and.report_*) are carried through all converters.
tbl.now 0.9.0
- Added
as_tibble()andas.data.frame()methods fortbl_nowwith an opt-incompute_temporal_effectsargument (defaultFALSE). Passingcompute_temporal_effects = TRUEmaterialises the lazytemporal_effects()spec (holidays, Fourier terms, calendar effects) into columns before returning a plaintibble/data.frame; the inputtbl_nowis left unchanged. The default stays lazy on purpose, becausedplyrrelies on these coercions being cheap, non-materialising declassers internally (e.g.group_by()). - The
tbl_now_to_*()converters now carry the (lazy) temporal-effect columns (holidays, Fourier seasonal terms, day-of-week / calendar effects) into the target format as covariate columns. The spec is materialised on demand viacompute_temporal_effects()at conversion time (the inputtbl_nowis left unchanged), and the columns are passed todata.table,tsibble,baselinenowcastlong format,epidist, andepinowcast(where they appear in the observations andmetareferencetables for use in the reference module). Thebaselinenowcastreporting-triangle matrix still cannot hold them. - Removed the
%>%export and changed all the pipes to|> - Refactored
converters.Rfor readability (dplyr column operations instead of base indexing, full variable names, lintr-clean). - The
tbl_now_to_*()converters now keep thecovariatesandis_censoredcolumns wherever the target format can hold them (data.table,tsibble,baselinenowcastlong format,epidistlinelist); the fixed modelling objects (enw_preprocess_data, the reporting-triangle matrix, the EpiNow2 series) still cannot carry them. - Added S3 methods on the other packages’ coercion generics so they accept a
tbl_nowdirectly:as_epidist_linelist_data(),as_reporting_triangle(),as_tsibble()andas.data.table(), each wrapping the matchingtbl_now_to_*(). - Fixed
tbl_now_to_data_table()checking forbaselinenowcastinstead ofdata.table, andtbl_now_to_baselinenowcast(format = "long")no longer requiringbaselinenowcastto be installed.
tbl.now 0.8.0
- Modified the
updateas thet_effectargument was not doing anything. - Fixed bug that errored
complete_zeroeswhenis_censoredwas given. - Removed explicit zeroes from the converters (
tbl_now_from_*) as they are not necessary intbl_now. - Added
censor_delays_above()to flag reports with an implausibly long delay as censored (their delay becomes an upper bound). - Improved documentation and README
- Documented all internal functions with roxygen (
@keywords internal+@noRd) and ensured every exported function has a@return. - Homogenized
lifecyclebadges. - Brought the
censor_delays_abovefunction fromdiseasenowcastingtotbl_now. -
tbl_now_from_epinowcast()now accepts not only the raw long input but also a preprocessedenw_preprocess_dataobject or a fittedepinowcastobject (grouping auto-detected), matching the formatepinowcastuses for summaries and plots. -
tbl_now_to_EpiNow2()gained amodelargument:"estimate_infections"(default, the singledate/confirmseries) and"estimate_truncation"(a list of report-date snapshots, the one EpiNow2 model that uses the report dimension). Documentation clarified accordingly. - Fixed two converter
requireNamespace()guards:tbl_now_to_data_table()checked forbaselinenowcastinstead ofdata.table, andtbl_now_to_baselinenowcast(format = "long")no longer requiresbaselinenowcastto be installed.
tbl.now 0.7.5
- Bumped roxygen to version 8.0.0. This also resulted in updated documentation.
- Changed
autoplot()’s default level to 0.95 - Added tests for converters and pillars.
- Throws warning when converting to
baselinenowcastif data is"count-cumulative".
tbl.now 0.7.3
- Added the
update_now()function to make it more intuitive to update the now.
tbl.now 0.7.0
- Added an
autoplot()method fortbl_nowobjects that produces a multi-panel diagnostic overview: the empirical delay distribution, the observed epidemic process with an incompleteness line (controlled bylevel), normalized calendar-effect boxplots (cases relative to the overall mean), and a periodogram to help choose Fourierseasons. Daily data shows both a day-of-week and a week-of-year boxplot panel; weekly data shows week-of-year. Built onggplot2andpatchwork. The x-axis limits of each panel can be set individually (delay_distribution_xlim,event_date_xlim,calendar_effect_xlim,seasonality_xlim), and holidays from the temporal-effects spec are marked with red dots on the epidemic process. - Added converters to and from other packages, all of the form
tbl_now_from_*()/tbl_now_to_*():epinowcast,baselinenowcast,EpiNow2(to only),epidist,data.tableandtsibble. Thetbl_now_from_*()functions wrapas_tbl_now()and forward...totbl_now(); thetbl_now_to_*()functions call into the target package. All accept averboseargument that reports the choices made (the inferrednow, data type, units, and column mapping). -
as_tbl_now()gained methods for the classes produced bytbl_now_to_*()(enw_preprocess_data,reporting_triangle,epidist_linelist_data,tbl_tsanddata.table), so a converted object can be turned straight back into atbl_now. - Documented
autoplot()and the converters in the introduction vignette.
tbl.now 0.6.4
- Fixed dependency on R >= 4.2.0
- Update function now defaults the censoring to FALSE if the update is censored but the original is not.
tbl.now 0.6.2
- Removed warning when using columns for temporal effects that cascaded into
to_count. - Changed DESCRIPTION to fix ortographic error and trigger less messages of unknown words.
tbl.now 0.6.0
- Changed temporal effects to be lazy (as required by #17) so that now its easier to use
dplyrfunctions without compromising them. - Bumped the deprecated dplyr’s
*_atfunctions to useall_of() - Fixed to no warnings during test.
- Users can now pass the
.delaycolumn directly (#6) and it will recalculate the missing column (i.e. event or report) - Added
complete_zeroesto vignette (#13).