From 0c80db34da6742cbbe2e400586f007f2d607a0ce Mon Sep 17 00:00:00 2001 From: Andree Valle Campos Date: Sat, 22 Nov 2025 22:58:01 +0000 Subject: [PATCH 1/6] add style edits --- episodes/modelling-interventions.Rmd | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/episodes/modelling-interventions.Rmd b/episodes/modelling-interventions.Rmd index fb1e9007..d06a5628 100644 --- a/episodes/modelling-interventions.Rmd +++ b/episodes/modelling-interventions.Rmd @@ -52,7 +52,7 @@ In this tutorial different types of intervention and how they can be modelled ar :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -## A baseline model +## Baseline model We will investigate the effect of interventions on a COVID-19 outbreak using an SEIR model (`model_default()` in the R package `{epidemics}`). To be able to see the effect of our intervention, we will run a baseline variant of the model, i.e, without intervention. @@ -141,7 +141,7 @@ To include an intervention in our model we must create an `intervention` object. rownames(cm_matrix) ``` -Therefore, we specify ` reduction = matrix(c(0.5, 0.01, 0.01))`. We assume that the school closures start on day 50 and continue to be in place for a further 100 days. Therefore our intervention object is: +Therefore, we specify `reduction = matrix(c(0.5, 0.01, 0.01))`. We assume that the school closures start on day 50 and continue to be in place for a further 100 days. Therefore our intervention object is: ```{r intervention} close_schools <- epidemics::intervention( @@ -160,18 +160,18 @@ In `{epidemics}`, the contact matrix is scaled down by proportions for the perio ```{r echo = FALSE} reduction <- matrix(c(0.5, 0.1)) -cm_matrix_example <- matrix(c(1, 1, 1, 1), nrow = 2) -cm_matrix_example +contact_matrix_example <- matrix(c(1, 1, 1, 1), nrow = 2) +contact_matrix_example ``` If the reduction is 50% in group 1 and 10% in group 2, the contact matrix during the intervention will be: ```{r echo = FALSE} -cm_matrix_example[1, ] <- cm_matrix_example[1, ] * (1 - reduction[1]) -cm_matrix_example[, 1] <- cm_matrix_example[, 1] * (1 - reduction[1]) -cm_matrix_example[2, ] <- cm_matrix_example[2, ] * (1 - reduction[2]) -cm_matrix_example[, 2] <- cm_matrix_example[, 2] * (1 - reduction[2]) -cm_matrix_example +contact_matrix_example[1, ] <- contact_matrix_example[1, ] * (1 - reduction[1]) +contact_matrix_example[, 1] <- contact_matrix_example[, 1] * (1 - reduction[1]) +contact_matrix_example[2, ] <- contact_matrix_example[2, ] * (1 - reduction[2]) +contact_matrix_example[, 2] <- contact_matrix_example[, 2] * (1 - reduction[2]) +contact_matrix_example ``` The contacts within group 1 are reduced by 50% twice to accommodate for a 50% reduction in outgoing and incoming contacts ($1\times 0.5 \times 0.5 = 0.25$). Similarly, the contacts within group 2 are reduced by 10% twice. The contacts between group 1 and group 2 are reduced by 50% and then by 10% ($1 \times 0.5 \times 0.9= 0.45$). @@ -245,7 +245,7 @@ We can also model the effect of other NPIs by reducing the value of the relevant We expect that mask wearing will reduce an individual's infectiousness, based on multiple studies showing the effectiveness of masks in reducing transmission. As we are using a population-based model, we cannot make changes to individual behavior and so assume that the transmission rate $\beta$ is reduced by a proportion due to mask wearing in the population. We specify this proportion, $\theta$ as product of the proportion wearing masks multiplied by the proportion reduction in transmission rate (adapted from [Li et al. 2020](https://doi.org/10.1371/journal.pone.0237691)). -We create an intervention object with `type = rate` and `reduction = 0.161`. Using parameters adapted from [Li et al. 2020](https://doi.org/10.1371/journal.pone.0237691) we have proportion wearing masks = coverage $\times$ availability = $0.54 \times 0.525 = 0.2835$ and proportion reduction in transmission rate = $0.575$. Therefore, $\theta = 0.2835 \times 0.575 = 0.163$. We assume that the mask wearing mandate starts at day 40 and continue to be in place for 200 days. +We create an intervention object with `type = "rate"` and `reduction = 0.161`. Using parameters adapted from [Li et al. 2020](https://doi.org/10.1371/journal.pone.0237691) we have proportion wearing masks = coverage $\times$ availability = $0.54 \times 0.525 = 0.2835$ and proportion reduction in transmission rate = $0.575$. Therefore, $\theta = 0.2835 \times 0.575 = 0.163$. We assume that the mask wearing mandate starts at day 40 and continue to be in place for 200 days. ```{r masks} mask_mandate <- epidemics::intervention( From b7de670671baa18332dbc0eaad19633bc4678b7e Mon Sep 17 00:00:00 2001 From: Andree Valle Campos Date: Sat, 22 Nov 2025 22:59:20 +0000 Subject: [PATCH 2/6] fix equation --- episodes/modelling-interventions.Rmd | 1 + 1 file changed, 1 insertion(+) diff --git a/episodes/modelling-interventions.Rmd b/episodes/modelling-interventions.Rmd index d06a5628..178a7748 100644 --- a/episodes/modelling-interventions.Rmd +++ b/episodes/modelling-interventions.Rmd @@ -373,6 +373,7 @@ $$ \frac{dV_i}{dt} & =\nu_{i,t} S_i\\ \end{aligned} $$ + Individuals in age group ($i$) at specific time dependent ($t$) are vaccinated at rate ($\nu_{i,t}$). The other SEIR components of these equations are described in the tutorial [simulating transmission](../episodes/simulating-transmission.md#simulating-disease-spread). To explore the effect of vaccination we need to create a vaccination object to pass as an input into `model_default()` that includes age groups specific vaccination rate `nu` and age groups specific start and end times of the vaccination program (`time_begin` and `time_end`). From 0f5644e25218322238f9dda6b0dec8909d93c2a6 Mon Sep 17 00:00:00 2001 From: Andree Valle Campos Date: Sat, 22 Nov 2025 23:02:13 +0000 Subject: [PATCH 3/6] fix equations --- episodes/contact-matrices.Rmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/episodes/contact-matrices.Rmd b/episodes/contact-matrices.Rmd index f0e11878..f957078a 100644 --- a/episodes/contact-matrices.Rmd +++ b/episodes/contact-matrices.Rmd @@ -64,6 +64,7 @@ $$ 1 & 3 \end{bmatrix} $$ + In this example, we would use this to represent that children meet, on average, 2 other children and 2 adult per day (first row), and adults meet, on average, 1 child and 3 other adults per day (second row). We can use this kind of information to account for the role heterogeneity in contact plays in infectious disease transmission. ::::::::::::::::::::::::::::::::::::: callout @@ -267,6 +268,7 @@ $$ \frac{dR}{dt} &=\gamma I \\ \end{aligned} $$ + To add age structure to our model, we need to add additional equations for the infection states $S$, $I$ and $R$ for each age group $i$. If we want to assume that there is heterogeneity in contacts between age groups then we must adapt the transmission term $\beta SI$ to include the contact matrix $C$ as follows : $$ \beta S_i \sum_j C_{i,j} I_j/N_j. $$ From 2ad0760f4c0776c87219f7cce9cadffd0eea5a88 Mon Sep 17 00:00:00 2001 From: Andree Valle Campos Date: Sat, 22 Nov 2025 23:16:46 +0000 Subject: [PATCH 4/6] update setup alt installation --- learners/setup.md | 87 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/learners/setup.md b/learners/setup.md index 57389bf6..3af54bfe 100644 --- a/learners/setup.md +++ b/learners/setup.md @@ -96,7 +96,71 @@ While this may sound scary, it is **far more common** to run into issues due to ::::::::::::::::::::::::::::: -### 2. Install the required R packages +### 2. Check and Install Build Tools + +Some packages require a complementary set of tools to build them. +Open RStudio and **copy and paste** the following code chunk into the +[console window](https://docs.posit.co/ide/user/ide/guide/code/console.html), +then press the Enter (Windows and Linux) or Return (MacOS) to execute the command: + +```r +if(!require("pkgbuild")) install.packages("pkgbuild") +pkgbuild::check_build_tools(debug = TRUE) +``` + +We expect a message like the one below: + +```output +Your system is ready to build packages! +``` + +If the build tools are not available, this will trigger an automated install. + +1. Run the command in the console. +2. Don’t interrupt it—wait until R prints the confirmation message. +3. Once that’s done, restart your R session (or just restart RStudio) to ensure the changes take effect. + +If the automatic installation **does not** work, you can manually install them according to your operating system. + +::::::::::::::::::::::::::::: tab + +### Windows + +Windows users will need a working installation of `Rtools` in order to build the package from source. +`Rtools` is not an R package, but a software you need to download and install. +We suggest you to follow: + +- **Install `Rtools`**. Download the `Rtools` installer from . Install with default selections. +- Close and reopen RStudio so it can recognize the new installation. + +### Mac + +Mac users require two additional steps as detailed in this [guide to Configuring C Toolchain for Mac](https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Mac): + +- Install and use [`macrtools`](https://mac.thecoatlessprofessor.com/macrtools/) to setup the C++ toolchain +- Enable some compiler optimizations. + +### Linux + +Linux users require specific details per distribution. Find them in this [guide to Configuring C Toolchain for Linux](https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux). + +::::::::::::::::::::::::::::: + +::::::::::::: callout + +### Environment Check + +This step requires administrator privileges to install software. + +If you do not have admin rights in your current environment: + +- Try running the tutorial on your **personal machine** where you have full access. +- Use a **preconfigured development environment** (e.g. [Posit Cloud](https://posit.cloud/)). +- Ask your **system administrator** to install the required software for you. + +::::::::::::: + +### 3. Install the required R packages