Skip to content
/ WSS Public

Weight scale and shift code for covid epidemic modelling

License

Notifications You must be signed in to change notification settings

gjackland/WSS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

aeaa7fa · Mar 28, 2023
Nov 26, 2021
Feb 22, 2022
Jan 31, 2022
Jul 26, 2021
Dec 6, 2021
Oct 19, 2021
Mar 27, 2023
Jan 22, 2023
Jun 2, 2021
Nov 22, 2021
Aug 25, 2021
Nov 3, 2022
Sep 26, 2022
Nov 22, 2022
Sep 29, 2022
Mar 28, 2023
Jan 22, 2023
Mar 23, 2022
Feb 8, 2022
Sep 29, 2022
Jan 22, 2023
Jan 22, 2023
Oct 12, 2021
Feb 22, 2022
Feb 12, 2022
Nov 22, 2021
Apr 13, 2022
Sep 29, 2022
Mar 28, 2023
Mar 28, 2023
Nov 2, 2021
Sep 6, 2021
Aug 12, 2021
Aug 30, 2021
Oct 5, 2021
Jun 21, 2022
Jun 1, 2022
Oct 13, 2022

Repository files navigation

WSS

Weight scale and shift code for covid epidemic modelling. This code has been part of the SPI_M and JBC suite of nowcasts, medium term predictions and scenarios since autumn 2021.

The model takes CASES from https://coronavirus.data.gov.uk/ . All predictions are based on a compartment model moving people from CASE through hospitalization, ICU, to recovery or death. Compartments are broken down by age region.

R-numbers are calculated by differentiating the case data, after a little data processing to make this legit.
They reliably agree with "official" estimates published from SPI-M, but are available 16 days earlier.

Medium term projections are made by extending the CASE data with R-based prediction.

Parameterization is taken by fits to death/ICU/hospital data over the entire pandemic. Parameters are (slowly) varying with variant and vaccination. Lockdowns etc are not included directly, because their effect is mainly in CASES.

Model description and application is here (preprint and paper)

Previous preprints using the model

Ongoing version for BMJ

Analysis article

Execution

The code is in pure R and developed in and best run through Rstudio. Data is read at runtime from internet. If online data is unavailable, code will fail with error messages.
Since summer 2022, the testing regime has become quite sketchy and ONS estimates of prevalence (more accurate but delayed) are used to normalise the published case numbers. Similarly, Scotland stopped reporting death data to the UK site, so these are inferred from NRS. Wales and Northern Ireland data are unusable since summer 2022.

There are many in-code adjustable parameters, mainly gathered together in getParams.R. For ordinary running startdate and enddate can be set to cover the pandemics period where data are available. "reporting_delay" menas the last few days are excluded from nowcasting because dtat is incomplete.

Workflow:

  1. Run Workflow.R This sets up the global parameters for the UK, calculates all R. parameters, generates plots for interactive monitoring, and does the compartment simulation for England, including medium term predictions.

  2. Covid_trimmed.R. Reads the current data from , calculates R numbers and pandemic hindcasts and medium term predictions

  3. ScottishData.R. This reads data from the Scottish government, reformats it because it uses different age banding, and runs the compartment model. The code ends with some monitoring plots

  4. Regional.R. to read data and obtain compartment model data for 7 NHS England Regions, and write outputs in CrystalCast format for uploading to weekly JBC ensemble estimates. Writing is done in CC_write.R

  5. Sanity check. R-numbers can be sensitive to late posting on recent cases, and wrong R-numbers tip over into the medium term predictions. Medium term predictions are very sensitive to the calculated parameters R_BestGuess$. Before believing anything, always check these and if not sensible investigate the last few days of input case data for anomalies. The parameter "enddate" can be increased to eliminate incomplete data. If R is sensitive to enddate, there is a data problem.

  6. Legacy code from the WSS paper calculating CFR variation with time may be called from medrxiv.R and age_pdfplot.R, but these must be called by editing the calls in the code to:

    medout <- MedrxivPaper()

    and setting:

    pdfpo <- TRUE

scenarios - where a range of initial values for R_BestGuess$ are set rather than calculated - can be run using the Scenarios.R code.

Workflow of restructured version:

  1. Run Workflow.R This calls all other necessary code. Gets parameters,data, calculates R, MTPs and prints out CrystalCast format

Predictions for SPI-MO and JBC

WSS is part of the suite of codes contributing to UK and Scottish government real-time modelling.

Licensing

The code is licensed under GPL-3.0. The data used for making the calculations is made available under an Open Government Licence.