{"id":28702878,"url":"https://github.com/epiforecasts/covid19.forecasts.uk","last_synced_at":"2025-06-14T13:05:49.557Z","repository":{"id":49959735,"uuid":"300750132","full_name":"epiforecasts/covid19.forecasts.uk","owner":"epiforecasts","description":"Data and code accompanying the preprint \"Short-term forecasts to inform the response to the Covid-19 epidemic in the UK\"","archived":false,"fork":false,"pushed_at":"2022-07-19T10:27:10.000Z","size":144841,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-08T03:44:03.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epiforecasts.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-02T22:32:40.000Z","updated_at":"2021-10-05T12:18:56.000Z","dependencies_parsed_at":"2022-09-23T19:42:00.990Z","dependency_job_id":null,"html_url":"https://github.com/epiforecasts/covid19.forecasts.uk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/epiforecasts/covid19.forecasts.uk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Fcovid19.forecasts.uk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Fcovid19.forecasts.uk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Fcovid19.forecasts.uk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Fcovid19.forecasts.uk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epiforecasts","download_url":"https://codeload.github.com/epiforecasts/covid19.forecasts.uk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Fcovid19.forecasts.uk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259820812,"owners_count":22916548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-14T13:05:47.751Z","updated_at":"2025-06-14T13:05:49.535Z","avatar_url":"https://github.com/epiforecasts.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\nTitle \u003c- \"Short-term forecasts to inform the response to the Covid-19 epidemic in the UK\"\n```\n\n# Short-term forecasts to inform the response to the Covid-19 epidemic in the UK\n\nThis repository contains the data and code for our manuscript:\n\n\u003e Funk S, Abbott S, Atkins B, Baguelin M, Baillie JK, Birrell P, Blake J, Bosse NI, Burton J, Carruthers J, Davies NG, De Angelis D, Dyson L, Edmunds WJ, Eggo RM, Ferguson NM, Gaythorpe K, Gorsich E, Guyver-Fletcher G, Hellewell J, Hill EM, Holmes A, House TA, Jewell C, Jit M, Jombart T, Joshi I, Keeling MJ, Kendall E, Knock E, Kucharski AJ, Lythgoe KA, Meakin SR, Munday JD, Openshaw PJM, Overton CE, Pagani F, Pearson J, Pellis L, Scarabel F, Semple MG, Sherratt K, Tang M, Tildesley MJ, Van Leeuwen E, Whittles LK, CMMID COVID-19 Working Group, Imperial College COVID-19 Response Team, ISARIC4C Investigators. _`r Title`_. MedRxiv:, online at \u003chttps://www.medrxiv.org/content/10.1101/2020.11.11.20220962v1\u003e\n\n### How to download or install\n\nYou can download the compendium as a zip from from this URL: \u003chttps://github.com/sbfnk/covid19.forecasts.uk/archive/master.zip\u003e\n\nOr you can install this compendium as an R package, `covid19.forecasts.uk`, from GitHub with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"devtools\")\nremotes::install_github(\"sbfnk/covid19.forecasts.uk\")\n```\n\n### Included data sets\n\nThe package includes a publicly available data set of new hospitalisations and hospital bed occupancy with Covid-19 by NHS England region and devolved nation, and deaths by date of death in England.\n\n```{r eval=FALSE}\ndata(covid_uk_data)\n```\n\nData that are excluded from scoring because they were not available at the time the forecasts were made are listed in\n\n```{r eval=FALSE}\ndata(exclude_data)\n```\n\nAll the individual model forecasts are included also included.\n\n```{r eval=FALSE}\ndata(uk_forecasts)\n```\n\nLastly, the forecast ensembles described in the paper, and the weights of the quantile regression average, are included:\n\n```{r eval=FALSE}\ndata(ensembles)\ndata(qra_weights)\n```\n\nThe ensembles that are based on publicly available data can be re-created from the individual model forecasts using\n\n```{r eval=FALSE}\nensembles_and_weights \u003c- generate_ensembles(uk_forecasts, covid_uk_data)\nensembles \u003c- ensembles_and_weights$ensembles\nqra_weights \u003c- ensembles_and_weights$qra_weights\n```\n\nTo extract the best-performing equally-weighted quantiles (between mean and median) and QRA model, run\n\n```{r eval=FALSE}\nscored_ensembles \u003c- ensembles %\u003e%\n  score_forecasts(covid_uk_data, exclude_data) %\u003e%\n  mutate(ensemble_type = substr(model, 1, 3))\nranked_ensembles \u003c- scored_ensembles %\u003e%\n  rank_forecasts()\nbest_ensembles \u003c- ranked_ensembles %\u003e%\n  group_by(ensemble_type) %\u003e%\n  filter(mean == min(mean)) %\u003e%\n  ungroup()\n```\n\nFor later use, the package also includes a vector with the name of the National Health Service (NHS) England regions,\n\n```{r eval = FALSE}\ndata(nhse_regions)\n```\n\n### Table and figures\n\nTo generate the tables and figures from the paper, we will need the `dplyr` and `cowplot` packages:\n\n```{r eval=FALSE}\nlibrary(\"dplyr\")\nlibrary(\"tidyr\")\nlibrary(\"purrr\")\nlibrary(\"cowplot\")\n```\nTo generate Figure 1, run\n\n```{r eval=FALSE}\nplot_data \u003c- covid_uk_data %\u003e%\n  filter(value_type %in% c(\"death_inc_line\", \"hospital_inc\", \"hospital_prev\"),\n         geography %in% c(\"England\", \"Northern Ireland\", \"Scotland\", \"Wales\"))\n\np \u003c- plot_data_forecasts(uk_forecasts, plot_data, uncertainty = TRUE, exclude = exclude_data)\nsave_plot(\"figure1.png\", p, base_height = 9)\n```\n\nTo generate Figure 2 (excluding data that is not publicly available), run\n\n```{r eval=FALSE}\ncomplete_forecasts \u003c- uk_forecasts %\u003e%\n    pivot_wider(names_from = \"quantile\", values_from = \"value\") %\u003e%\n    nest(data = matches(\"^[0-9]\")) %\u003e%\n    mutate(extrapolated = purrr::map(data, estimate_quantiles)) %\u003e%\n    unnest(extrapolated) %\u003e%\n    select(-data) %\u003e%\n    pivot_longer(names_to = \"quantile\", values_to = \"value\", matches(\"^[0-9]\")) %\u003e%\n    mutate(quantile = as.numeric(quantile))\nscored_forecasts \u003c- complete_forecasts %\u003e%\n  score_forecasts(covid_uk_data, exclude_data)\nscored_selected_ensembles \u003c- scored_ensembles %\u003e%\n  filter(model %in% best_ensembles$model) %\u003e%\n  mutate(model = ensemble_type, .keep = \"unused\")\nscored_null \u003c- fit_null_model(uk_forecasts, covid_uk_data) %\u003e%\n  score_forecasts(covid_uk_data, exclude_data)\np \u003c- null_model_plot(list(scored_selected_ensembles, scored_forecasts), scored_null)\nsave_plot(\"figure2.png\", p, base_asp = 1.7, base_height = 7)\n```\n\nBecause data on ICU bed occupancy were not publicly available at the time of writing the manuscript, this data is not included in the package and the corresponding panel in Figure 2 missing if using the command above.\n\nTo generate Table 1, run\n\n```{r eval = FALSE}\nscores_table(scored_selected_ensembles, file = \"table1.pdf\", common_creation_dates = TRUE)\n```\n\nTo generate Figure 3, run\n\n```{r eval = FALSE}\nselected_ensembles \u003c- ensembles %\u003e%\n  filter(model %in% best_ensembles$model, nmodels \u003e 1) %\u003e%\n  mutate(model = substr(model, 1, 3))\np \u003c- plot_data_forecasts(selected_ensembles, plot_data, exclude = exclude_data)\nsave_plot(\"figure3.png\", p, base_height = 9)\n```\n\nTo generate Figure 4, run\n\n```{r eval = FALSE}\ndata(qra_weights) \nplot_weights \u003c- qra_weights %\u003e%\n  filter(qra_model %in% best_ensembles$model,\n         geography == \"England\", quantile == 0.5)\np \u003c- weights_plot(plot_weights)\nsave_plot(\"figure4.png\", p, base_asp = 1.7, base_height = 7)\n```\n\nTo generate Supplementary Table S1, run\n\n```{r eval=FALSE}\nscores_table(scored_forecasts, file = \"si_table1.pdf\")\n```\n\nTo generate Supplementary Table S2, run\n\n```{r eval=FALSE}\nqra_rank_table(ranked_ensembles %\u003e% filter(ensemble_type == \"QRA\"),\n               file = \"si_table2.pdf\")\n```\n\nTo generate Supplementary Table S3, run\n\n```{r eval=FALSE}\newq_rank_table(ranked_ensembles %\u003e% filter(ensemble_type == \"EWQ\"),\n               file = \"si_table3.pdf\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiforecasts%2Fcovid19.forecasts.uk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepiforecasts%2Fcovid19.forecasts.uk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiforecasts%2Fcovid19.forecasts.uk/lists"}