Skip to content

Commit

Permalink
switch to wpp2019 for vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
pearsonca committed Oct 23, 2024
1 parent 226ff89 commit 8edf62b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Suggests:
rmarkdown,
ggplot2,
roxygen2,
wpp2022,
wpp2019,
testthat (>= 3.0.0),
patchwork
VignetteBuilder: knitr
Expand Down
7 changes: 7 additions & 0 deletions man/paramix-package.Rd

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

22 changes: 15 additions & 7 deletions vignettes/intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ suppressPackageStartupMessages({
library(data.table)
library(ggplot2)
library(patchwork)
library(wpp2022)
library(wpp2019)
})
```

Expand Down Expand Up @@ -81,12 +81,20 @@ Let's imagine a compartmental model with age groups [0,5), [5,20), [20,65), and
# our model age group cut points
model_agelimits <- c(0, 5, 20, 65, 101)
# get select data from World Population Prospects estimates
data("popAge1dt", package = "wpp2022")
density_dt <- popAge1dt[
name %like% "Afghanistan|United Kingdom" & year == 2021,
.(name, from = age, weight = pop)
data("popF", package = "wpp2019")
data("popM", package = "wpp2019")
density_dt <- as.data.table(popF)[,
.(name, age, tmp = `2020`)
][
as.data.table(popM), on = c("name", "age"),
.(name, age, weight = tmp + `2020`)
][
name %like% "Afghanistan|United Kingdom"
][,
.(name, from = as.integer(gsub("^(\\d+)[-+].*$","\\1",age)), weight)
]
rm(popAge1dt)
rm(popF)
rm(popM)
```

We can calculate the IFR values for each model age group, under different approaches to computing them. We'll use the package function `parameter_summary()`, which provides a convenient comparison of the parameter values for these approaches to summarisation:
Expand Down Expand Up @@ -115,7 +123,7 @@ plot_dt <- plot_dt[
# duplicates
pop_p <- ggplot(density_dt) + aes(from, weight) +
geom_bar(stat = "identity", width = 1) +
geom_col(width = 5, just = 1) +
facet_grid(cols = vars(name)) +
scale_x_continuous("Age", expand = expansion()) +
scale_y_continuous("Population (thousands)") +
Expand Down

0 comments on commit 8edf62b

Please sign in to comment.