Skip to content

Time Series Methods Based on Growth Curves

0packages depend
2.8Kdownloads / year
90.5%test coverage
13/13flavors OK

Overview

About
Maintained by Michael AshbyCRAN page ↗GitHub ↗Issues ↗Declared funders: Caldecott Bursary Fund, Magdalene College, University of Cambridge, Cambridge Centre for Health Leadership & Enterprise, Cambridge Judge Business School, University of Cambridge and 6 more

Provides tools for modelling and forecasting epidemic trajectories using a dynamic Gompertz model within a state space framework, with the Kalman filter for robust estimation of non-linear growth. Includes a reinitialization feature to adapt to new waves, and a leading-indicator extension that uses a related series moving ahead of the variable of interest (e.g. cases ahead of hospitalisations) to improve short-horizon forecasts, with model and lag selection via rolling-origin cross-validation. Applicable to data at daily, monthly, quarterly, or annual frequency, and to non-epidemic trajectories with similar dynamics, such as innovation diffusion and product adoption. Includes functions for data preprocessing, model fitting, forecast visualization, and accuracy evaluation using standard error measures. Methods are described in Harvey and Kattuman (2020) doi:10.1162/99608f92.828f40de, Harvey and Kattuman (2021) doi:10.1098/rsif.2021.0179, and Ashby, Harvey, Kattuman, Tang, and Thamotheram (2024) https://www.jbs.cam.ac.uk/wp-content/uploads/2024/03/cchle-tsgc-paper-2024.pdf.

Changes in 2.0.0

Breaking changes

  • Internal computation no longer relies on xts/zoo. Series used during estimation and filtering are now represented with a new, dependency-free idx_series class, with calendar handling provided by a companion idx_calendar class. Bundled datasets are unaffected and remain xts objects; xts_to_idx() is provided to convert user-supplied xts/zoo data to idx_series where needed. Code that relied on the internal (non-exported) representation of series may need to be updated.
  • SSModelDynGompertzReinit has been deprecated. Its functionality is now provided directly by SSModelDynamicGompertz via the reinit.idx, original.results, and use.presample.info fields, so a single class now covers both the standard and reinitialised model. SSModelBase has also been deprecated, with its logic folded into SSModelDynamicGompertz.
Show all changes in 2.0.0Hide the rest of the changes in 2.0.0
  • In FilterResults, the confidence_level argument to predict_all() and get_gy_ci() has been renamed to confidence.level, for consistency with naming elsewhere in the package. Calls that pass this argument by name will need to be updated. The default value of sea.on in predict_all() has also changed, from FALSE to TRUE.
  • forecast_peak(), forecast.peak(), and plot_new_cases() have been deprecated. plot_new_cases() has been renamed to plot_forecast() as the growth curve theory extends beyond epidemiological settings.

New features

  • Added a leading indicator model, via the new SSModelLeadingIndicator and FilterResultsLI reference classes, for modelling a target series using a leading series (see Harvey, A. (2021). "Time Series Modelling of Epidemics: Leading Indicators, Control Groups and Policy Assessment." *National Institute Economic Review*, 257, 83-100). FilterResultsLI provides predict_level(), predict_all(), get_growth_y(), get_gy_ci(), print(), summary(), and mapes() methods, paralleling FilterResults for the standard model.
  • Added five new example datasets: ukitaly, gauteng_weather_2021, england_weather_2021, nintendo_sales, and etrading_apps, including weather data to support leading indicator examples.
  • Added idx_series() and supporting methods (idx_cbind(), idx_rbind(), idx_diff(), idx_lag(), idx_range(), idx_values(), idx_positions(), and standard methods including length(), head(), tail(), as.matrix(), as.numeric(), as.double(), and print()) as a dependency-free representation of time series for internal computation.
  • Added idx_calendar() and supporting helpers (idx_step(), idx_to_date(), idx_calendar_offset(), idx_calendar_step(), idx_calendar_multi_step(), and related utilities) providing a consistent translation layer between integer positions and calendar dates for daily, weekly, monthly, quarterly, and annual data.
  • Added get_timeframe(), idx_to_pos(), idx_offset_to_pos(), and idx_detect_calendar_pattern() to support the new indexing system.
  • Added print_model_diagnostics() to surface model diagnostics more clearly.
  • Added xts_to_idx() to convert xts/zoo objects to the internal idx_series representation, for users supplying their own xts data.
  • Added cross_val() for cross-validating one or more models over a series of rolling estimation windows, and mapes() for computing mean absolute percentage errors from forecast results.
  • Added df2ldl_lead() for handling two-column data for leading indicator models.
  • Added print() and summary() S3 methods for SSModelDynamicGompertz, SSModelLeadingIndicator, FilterResults, and FilterResultsLI.
  • Added new plotting functions plot_compare_forecast() (compare forecasts across models), plot_log_forecast() (forecasts on the log scale), and plot_r0() (plot estimated reproduction numbers from estimate_r0()). Also added plotting functionality for models (plot() takes in a model object)
  • Added a new set of accessor functions (accessorFns.R) for extracting components from fitted model and KFS objects, including output(), modelKFS(), seasonalComp(), att(), Ptt(), get_V(), gety(), alphahat(), and a standalone estimate() wrapper around a model's estimate() method.

Improvements

  • Substantially expanded plotting internals with helper functions (idx_series_df(), idx_resolve_axis(), idx_axis_opts(), idx_x_scale(), idx_x_lab(), idx_add_info_box(), and related helpers) to give more consistent, better-labelled axes across all plot types, including support for non-daily frequencies.
  • Reduced the package's dependency footprint by removing reliance on xts/zoo from internal computation.

Bug fixes

  • Various small fixes to filtering, forecasting, and plotting uncovered during the internal rewrite.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 5.2 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-04
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 2.0.0
READMEYes · 606 wordsVignettesYes · 1 · dynamicNEWSYes · 100% structured · mentions 2.0.0Citation fileNoWebsitenot declared in DESCRIPTION
Help pages
86
Examples that run
100%48 run in a plain check
Exported functions with examples
49%
Documented parameters
92%
Return-value docs
92%
Help pages citing references
10%

Downloads

2.8K
CRAN downloads in the past year
Rank #12,324 · ~8/day · ~237/mo
Daily download trend is not available in this view yet.
29230 days
91390 days
2.8K1 year
Compare downloads with other packages →
Also on108 r2u2 autocran

Repository

1Stars
1Forks
0Open PRs
0Releases
330Commits
7Commit identities
330 commits · Last activity 2026-09-01
Responsiveness
How these are sampled
PRs merged (all time)
71%
Median days to close, 50 most recently updated closed issues
not measured
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2024-07-01 · 12026-09-02 · 1
Earlier repositories
PracticesBeta

4 development-tooling and community-health practices detected across 4 families in the upstream repository

Checks run against github.com/edwintang903/tsgc on 2026-10-25.

Governance and community (1)
Contributing guide
CRAN release process (1)
cran-comments.md
Research and citation (1)
codemeta.json
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v4 (2026-10-20)

Dependencies

Declared dependencies
21 external dependencies (excludes base and recommended)

Installing tsgc adds 60 packages (34 with compiled code, 49 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, bslib 5.6 MB.

Depends (1)
R >= 3.5.0
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

Datasets

People & History

People (14)
Author, Maintainer since 2.0.0 (2026) · added in 2.0.0
Author · added in 2.0.0
Author · added in 2.0.0
Author · added in 2.0.0
Author · added in 2.0.0
Funder · added in 2.0.0
Supported E. Tang
Funder · added in 2.0.0
Supported A. Harvey
Funder · added in 2.0.0
Funder · added in 2.0.0
Supported P. Kattuman

Previously maintained by Craig Thamotheram (0.0).

Releases (2)

Pick two releases to compare their code metrics.

  • 2.0.0Latest
    record
    2026-09-01 · current release · diff ↗ ·
    removed 5 exports
    SSModelBase, SSModelDynGompertzReinit, forecast.peak, forecast_peak, plot_new_cases
    added 42 exports
    NCOL.idx_series, SSModelLeadingIndicator, as_idx_series, cross_val, df2ldl_lead, estimate, estimate_r0, get_V, get_timeframe, idx_axis_opts, idx_calendar, idx_calendar_multi_step, idx_calendar_offset, idx_calendar_step, idx_cbind, idx_diff, idx_lag, idx_ncol, idx_offset_to_pos, idx_positions, idx_range, idx_rbind, idx_series, idx_step, idx_step_add, idx_to_date, idx_to_pos, idx_values, is_idx_calendar, is_idx_series and 12 more
  • R
    R 4.6.0 released · 2026-04-24
  • R
    R 4.5.0 released · 2025-04-11
  • 0.0
    record
    2024-08-26
  • R
    R 4.4.0 released · 2024-04-24

Package metadata

First published
2024-08-26
Total releases
2 / 2 yrs
License
GPL (>= 3) OSI
Minimum R
≥ 3.5.0
Bundled data
32 KB / 7 files
Download size
526 KB
Appears in task views

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("tsgc")
Ashby, M., Caldecott Bursary Fund, Magdalene College, University of Cambridge, Cambridge Centre for Health Leadership & Enterprise, Cambridge Judge Business School, University of Cambridge, Cambridge Mathematics Placements Programme, University of Cambridge, Chancellor's Scholarship Scheme, University of Warwick, Keynes Fund, Faculty of Economics, University of Cambridge, Statistics Centre for Doctoral Training, University of Warwick, UK Health Security Agency, University of Cambridge Social Science Impact Fund, Harvey, A., Kattuman, P., Secchi, G., Tang, E., & Thamotheram, C. (2026). tsgc: Time Series Methods Based on Growth Curves (Version 2.0.0) [Computer software]. https://doi.org/10.32614/CRAN.package.tsgc

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for tsgc version 2.0.0 [Data set]. HJJB, LLC. Data release v2026-10-26. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-26, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy