R Observatory
Search
install.packages("tsgc")
CRAN 30-day downloads, method
293−34.7% down on the 30 days before, the worse direction
Test coverage, method
90%of lines run by tests

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.

Full description

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>.

Maintainer
Michael Ashby
Licence
GPL (>= 3)
Latest release
1 Sep 2026
First release
26 Aug 2024

Compare with another package

More details
Releases
2
Needs compilation
No
Needs R
>= 3.5.0
Config/roxygen2/version
8.0.0
Config/testthat/edition
3
LazyData
true
RoxygenNote
7.3.3
Task views (1)
Subjects (1) Method, Subjects
Cite

Package

Run in R for the authors' preferred citation:

citation("tsgc")
APA
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
About

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

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-29. https://doi.org/10.5281/zenodo.21843040
About

From data release v2026-10-29, which the citation names so these numbers can be found later.

All 13 check platforms pass.

  • r-devel-linux-x86_64-debian-clang

    The unreleased R on Linux, x86_64, debian-clang

    OK

    Version checked
    2.0.0
    Time taken
    226 s
  • r-devel-linux-x86_64-debian-gcc

    The unreleased R on Linux, x86_64, debian-gcc

    OK

    Version checked
    2.0.0
    Time taken
    152 s
  • r-devel-linux-x86_64-fedora-clang

    The unreleased R on Linux, x86_64, fedora-clang

    OK

    Version checked
    2.0.0
    Time taken
    146 s
  • r-devel-linux-x86_64-fedora-gcc

    The unreleased R on Linux, x86_64, fedora-gcc

    OK

    Version checked
    2.0.0
    Time taken
    149 s
  • r-devel-windows-x86_64

    The unreleased R on Windows, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    268 s
  • r-oldrel-macos-arm64

    The previous release of R on macOS, arm64

    OK

    Version checked
    2.0.0
    Time taken
    56 s
  • r-oldrel-macos-x86_64

    The previous release of R on macOS, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    235 s
  • r-oldrel-windows-x86_64

    The previous release of R on Windows, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    310 s
  • r-patched-linux-x86_64

    The patched release of R on Linux, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    216 s
  • r-release-linux-x86_64

    The current release of R on Linux, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    213 s
  • r-release-macos-arm64

    The current release of R on macOS, arm64

    OK

    Version checked
    2.0.0
    Time taken
    55 s
  • r-release-macos-x86_64

    The current release of R on macOS, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    257 s
  • r-release-windows-x86_64

    The current release of R on Windows, x86_64

    OK

    Version checked
    2.0.0
    Time taken
    251 s
  • 13 OK

Over time

No change since 4 Aug 2026

As a list (5)
ChangedWorst statusOKNotesWarningsErrors
4 Aug 2026OK13000
1 Aug 2026Note12100
9 Jun 2026OK13000
8 Jun 2026Error12001
10 Mar 2026OK14000

Since March 2026

Check results on CRAN

Total downloads in the last 30 days
310−33.9% down on the 30 days before, the worse directionIt is the sum of 3 channels: CRAN, r2u and autoCRAN.

CRAN rank

14,494 of 26,553

CRAN

293 downloads in the last 30 days

Rank
14,494 of 26,553
Change
−34.7% down on the 30 days before, the worse direction

It is in the total. Take it out

r2u

14 downloads in the last 30 days

Rank
5,640 of 30,526
Change
+100% up on the 30 days before, the better direction

It is in the total. Take it out

autoCRAN

3 downloads in the last 30 days

Rank
18,475 of 29,233
Change
−76.9% down on the 30 days before, the worse direction

It is in the total. Take it out

Over time

Compare downloads

Needs
11
Dependent packages
0
Suggested by
0
Needs (11)
Installing it adds
60 packages, 48.9 MB of source
Of those, need compilation
34
Optional extras (11)
Functions
104
Public exports
51
Lines of R code
6,621
Median complexity
2.5
Functions (104)
Size and composition

Lines by kind (19,393)

KindLinesShare
R code6,62134%
Tests4,58324%
Documentation3,52118%
Guides4,66824%

Lines by language

LanguageLinesShare
R13,73171%
Rd3,52118%
Vignettes2,02210%
Other1190.6%

Languages are counted from file extensions.

Files
127
R functions
104
Object systems
S3: 21 methods, Reference classes: 4 classes
Complexity
Median
2.5
Mean
4.38
Highest
26
Median lines per function
10
About complexity

Cyclomatic complexity counts the independent paths through a function: 1 is a straight line, higher is harder to test. R functions only.

Call graph figures
R functions
104
Calls
240
Unconnected
24
Groups
1
Growth (2 releases)
Total lines by release
4,102 on 26 Aug 202419,393 on 1 Sep 2026
Release changes

The tests ran and coverage was measured.

Lines run by tests
90.5%
Expressions run by tests
90.1%
Test cases
337
Exports named in tests
100%
Coverage by file (9)
Coverage run
Lines counted
3,016
Lines the tests ran
2,729
Tests passed
Yes
Measured with
covr 3.6.5 on R 4.6.1
Test suite
Has tests
Yes
Test frameworks
testthat
Test cases
337
Lines of tests
4,583
Test lines per line of code
0.69
Exports documented
100%
Arguments documented
92.3%
Return value documented
92.2%
Help pages with examples
55.8%
Examples run in checks
100%
Guides (1)
Other documentation
README
Yes, 606 words
Release notes file
Yes
Help pages
86
Lines of documentation
3,521
DatasetSize
englandDaily Covid-19 metrics for England.733 × 4
england_weather_2021Daily Weather data of England in 2021.365 × 5
etrading_appsMonthly downloads of French leading apps from January 2017 to July 202155 × 5
gautengCumulative daily cases of Covid-19 in the South African province of Gauteng.667 × 1
gauteng_weather_2021Daily weather data of the South African province of Gauteng in 2021365 × 5
nintendo_salesQuarterly Sales of Nintendo consoles from 2004 Q4 to 2024 Q178 × 8
ukitalyCumulative daily cases of Covid-19 in Italy and UK, before 14 Dec 2020.294 × 2

Funded by 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

edwintang903 / tsgc on github.com

Stars
1
Forks
1
Open issues
–
Last commit
1 Sep 2026
Activity
Commits
330
Open pull requests
0
Tagged releases
0
Latest tagged release
–
Issues closed in
–
Pull requests closed in
0 days (median)
Pull requests merged
71%
Created
22 Jul 2024
Licence file reads as
–
Development practices (4)
KindFound
Governance and communityContributing guide
CRAN release processcran-comments.md
Research and citationcodemeta.json
Lint, format, editorRStudio project

Method, repository practices

Across edwintang903

Earlier repositories (1)
R releases
  • On CRAN
  • Release
VersionReleasedREvents
2.0.0 current1 Sep 20264.6.1Maintainer: Michael Ashby
0.026 Aug 20244.4.1
Release notes (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.
  • 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.