Skip to content

Commit

Permalink
Fix example dataset polymod_uk (#112)
Browse files Browse the repository at this point in the history
* Transpose contact data before demography scaling

* Use pre-transposed contact matrix

* Fix polymod_uk use in examples

* Correct R0 in text

* Automatic readme update

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
pratikunterwegs and actions-user authored Dec 2, 2022
1 parent ed14e79 commit 1d4b6b1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R/final_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#' # load example POLYMOD data included in the package
#' data(polymod_uk)
#' r0 <- 2.0
#' contact_matrix <- t(polymod_uk$contact_matrix)
#' contact_matrix <- polymod_uk$contact_matrix
#' demography_vector <- polymod_uk$demography_vector
#'
#' # define the number of age and susceptibility groups
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ devtools::install_github("epiverse-trace/finalsize")

_finalsize_ provides the single function `final_size()`, to calculate the final size of an epidemic.

Here, an example using social contact data from the _socialmixr_ package investigates the final size of an epidemic when the disease has an R<sub>0</sub> of 2.0, and given three age groups of interest --- 0-19, 20-39 and 40+.
The under-20 age group is assumed to be fully susceptible to the disease, whereas individuals aged over 20 are only half as susceptible.
Here, an example using social contact data from the _socialmixr_ package investigates the final size of an epidemic when the disease has an R<sub>0</sub> of 1.5, and given three age groups of interest --- 0-19, 20-39 and 40+.
The 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.

```{r}
# load finalsize
Expand All @@ -59,7 +59,7 @@ library(finalsize)
data(polymod_uk)
# Define contact matrix (entry {ij} is contacts in group i reported by group j)
contact_matrix <- t(polymod_uk$contact_matrix)
contact_matrix <- polymod_uk$contact_matrix
# Define population in each age group
demography_vector <- polymod_uk$demography_vector
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ the final size of an epidemic.

Here, an example using social contact data from the *socialmixr* package
investigates the final size of an epidemic when the disease has an
R<sub>0</sub> of 2.0, and given three age groups of interest — 0-19,
R<sub>0</sub> of 1.5, and given three age groups of interest — 0-19,
20-39 and 40+. The under-20 age group is assumed to be fully susceptible
to the disease, whereas individuals aged over 20 are only half as
susceptible.
susceptible as those under 20.

``` r
# load finalsize
Expand All @@ -69,7 +69,7 @@ library(finalsize)
data(polymod_uk)

# Define contact matrix (entry {ij} is contacts in group i reported by group j)
contact_matrix <- t(polymod_uk$contact_matrix)
contact_matrix <- polymod_uk$contact_matrix

# Define population in each age group
demography_vector <- polymod_uk$demography_vector
Expand Down Expand Up @@ -100,9 +100,9 @@ final_size(
susceptibility
)
#> demo_grp susc_grp susceptibility p_infected
#> 1 [0,20) susc_grp_1 1.0 0.3207405
#> 2 [20,40) susc_grp_1 0.5 0.1127051
#> 3 40+ susc_grp_1 0.5 0.1270013
#> 1 [0,20) susc_grp_1 1.0 0.32849966
#> 2 [20,40) susc_grp_1 0.5 0.10532481
#> 3 40+ susc_grp_1 0.5 0.06995193
```

## Package vignettes
Expand Down
2 changes: 1 addition & 1 deletion data-raw/polymod_uk.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ polymod_uk <- socialmixr::contact_matrix(
)

# get contact matrix and demography vector
contact_matrix <- polymod_uk$matrix
contact_matrix <- t(polymod_uk$matrix)
demography_vector <- polymod_uk$demography$population

# scale contacts by maximum real eigenvalue and divide by demography
Expand Down
Binary file modified data/polymod_uk.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/final_size.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d4b6b1

Please sign in to comment.