{"id":22151671,"url":"https://github.com/epiverse-trace/finalsize","last_synced_at":"2025-09-03T14:36:22.570Z","repository":{"id":60910909,"uuid":"488612686","full_name":"epiverse-trace/finalsize","owner":"epiverse-trace","description":"R package to calculate the final size of an SIR epidemic in populations with heterogeneity in social contacts and disease susceptibility","archived":false,"fork":false,"pushed_at":"2025-05-26T08:12:11.000Z","size":11785,"stargazers_count":13,"open_issues_count":18,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-08-25T23:36:07.247Z","etag":null,"topics":["epidemic-modelling","epidemiology","epiverse","outbreak-analysis","r","r-package","rcpp","sdg-3"],"latest_commit_sha":null,"homepage":"https://epiverse-trace.github.io/finalsize/","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/epiverse-trace.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-04T14:03:55.000Z","updated_at":"2025-07-01T13:30:08.000Z","dependencies_parsed_at":"2024-04-08T15:53:41.907Z","dependency_job_id":"060e0d42-3b4b-479c-825a-27f6b27144d0","html_url":"https://github.com/epiverse-trace/finalsize","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/epiverse-trace/finalsize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiverse-trace%2Ffinalsize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiverse-trace%2Ffinalsize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiverse-trace%2Ffinalsize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiverse-trace%2Ffinalsize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epiverse-trace","download_url":"https://codeload.github.com/epiverse-trace/finalsize/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiverse-trace%2Ffinalsize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273457175,"owners_count":25109188,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["epidemic-modelling","epidemiology","epiverse","outbreak-analysis","r","r-package","rcpp","sdg-3"],"created_at":"2024-12-02T00:35:07.663Z","updated_at":"2025-09-03T14:36:22.522Z","avatar_url":"https://github.com/epiverse-trace.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\nbibliography: vignettes/references.json\nlink-citations: true\n---\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# {{ packagename }}: Calculate the final size of an epidemic \u003cimg src=\"man/figures/logo.svg\" align=\"right\" width=\"130\"/\u003e\n\n\u003c!-- badges: start --\u003e\n\u003ca href=\"https://app.digitalpublicgoods.net/a/10557\"\u003e\u003cimg src=\"https://digitalpublicgoods.net/registry/dpgicon.svg\" alt=\"Digital Public Good\" height=\"25\"\u003e\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![R-CMD-check](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/{{ gh_repo }}/branch/main/graph/badge.svg)](https://app.codecov.io/gh/{{ gh_repo }}?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/finalsize)](https://CRAN.R-project.org/package=finalsize)\n\u003c!-- badges: end --\u003e\n\n_{{ packagename }}_ is an R package to calculate the final size of a SIR epidemic in populations with heterogeneity in social contacts and infection susceptibility.\n\n_{{ packagename }}_ provides estimates for the total proportion of a population infected over the course of an epidemic, and can account for a demographic distribution (such as age groups) and demography-specific contact patterns, as well as for heterogeneous susceptibility to infection between groups (such as due to age-group specific immune responses) and within groups (such as due to immunisation programs). An advantage of this approach is that it requires fewer parameters to be defined compared to a model that simulates the full transmission dynamics over time, such as models in the [_epidemics_ package](https://epiverse-trace.github.io/epidemics/articles/epidemics.html).\n\n_{{ packagename }}_ implements methods outlined in @andreasen2011, @miller2012, @kucharski2014, and @bidari2016.\n\n_{{ packagename }}_ can help provide rough estimates of the effectiveness of pharmaceutical interventions in the form of immunisation programmes, or the effect of naturally acquired immunity through previous infection (see the vignette).\n\n_{{ packagename }}_ relies on [Eigen](https://gitlab.com/libeigen/eigen) via [RcppEigen](https://github.com/RcppCore/RcppEigen) for fast matrix algebra, and is developed at the [Centre for the Mathematical Modelling of Infectious Diseases](https://www.lshtm.ac.uk/research/centres/centre-mathematical-modelling-infectious-diseases) at the London School of Hygiene and Tropical Medicine as part of the [Epiverse-TRACE](https://data.org/initiatives/epiverse/).\n\n## Installation\n\nThe package can be installed from CRAN using\n\n```r\ninstall.packages(\"finalsize\")\n```\n\n### Development version\n\nThe current development version of _{{ packagename }}_ can be installed from [Github](https://github.com/{{ gh_repo }}) using the `remotes` package.\nThe development version documentation can be found [here](https://epiverse-trace.github.io/finalsize/dev/).\n\n```r\nif(!require(\"pak\")) install.packages(\"pak\")\npak::pak(\"{{ gh_repo }}\")\n```\n\n## Quick start\n\nThe main function in _{{ packagename }}_ is `final_size()`, which calculates the final size of an epidemic given the $R_0$.\n\n```{r}\n# load finalsize\nlibrary(finalsize)\n\nfinal_size(1.5)\n```\n\nOptionally, `final_size()` can estimate the epidemic size for populations with differences among demographic groups in their social contact patterns, in their susceptibility to infection.\n\nWe can use social contact data (here, from the _socialmixr_ package) to estimate the final size of an epidemic when the disease has an R\u003csub\u003e0\u003c/sub\u003e of 1.5, and given three age groups of interest --- 0-19, 20-39 and 40+.\nThe under-20 age group is assumed to be fully susceptible to the disease, whereas individuals aged over 20 are only half as susceptible as those under 20.\n\n```{r}\n# Load example POLYMOD social contacts data included with the package\ndata(polymod_uk)\n\n# Define contact matrix (entry {ij} is contacts in group i reported by group j)\ncontact_matrix \u003c- polymod_uk$contact_matrix\n\n# Define population in each age group\ndemography_vector \u003c- polymod_uk$demography_vector\n\n# Define susceptibility of each group\nsusceptibility \u003c- matrix(\n  data = c(1.0, 0.5, 0.5),\n  nrow = length(demography_vector),\n  ncol = 1\n)\n\n# Assume uniform susceptibility within age groups\np_susceptibility \u003c- matrix(\n  data = 1.0,\n  nrow = length(demography_vector),\n  ncol = 1\n)\n\n# R0 of the disease\nr0 \u003c- 1.5 # assumed for pandemic influenza\n\n# Calculate the proportion of individuals infected in each age group\nfinal_size(\n  r0 = r0,\n  contact_matrix = contact_matrix,\n  demography_vector = demography_vector,\n  susceptibility = susceptibility,\n  p_susceptibility = p_susceptibility\n)\n```\n\nHelper functions included in _{{ packagename }}_ are provided to calculate the effective $R_0$, called $R_{eff}$, from demographic and susceptibility distribution data, while other helpers can convert between $R_0$ and the transmission rate $\\lambda$.\n\n```{r}\n# calculate the effective R0 using `r_eff()`\nr_eff(\n  r0 = r0,\n  contact_matrix = contact_matrix,\n  demography_vector = demography_vector,\n  susceptibility = susceptibility,\n  p_susceptibility = p_susceptibility\n)\n```\n\n## Package vignettes\n\nMore details on how to use _{{ packagename }}_ can be found in the [online documentation as package vignettes](https://epiverse-trace.github.io/finalsize/), under \"Articles\".\n\n## Help\n\nTo report a bug please open an [issue](https://github.com/{{ gh_repo }}/issues/new/choose).\n\n## Contribute\n\nContributions to _{{ packagename }}_ are welcomed. Please follow the [package contributing guide](https://github.com/{{ gh_repo }}/blob/main/.github/CONTRIBUTING.md).\n\n## Code of conduct\n\nPlease note that the _{{ packagename }}_ project is released with a [Contributor Code of Conduct](https://github.com/epiverse-trace/.github/blob/main/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.\n\n\n## Citing this package\n\n```{r message=FALSE, warning=FALSE}\ncitation(\"finalsize\")\n```\n\n## References\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiverse-trace%2Ffinalsize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepiverse-trace%2Ffinalsize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiverse-trace%2Ffinalsize/lists"}