Skip to content

Commit

Permalink
partnerships model
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencarlislewalker committed Sep 26, 2024
1 parent 0dfaf70 commit 130f5b1
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 3 deletions.
10 changes: 7 additions & 3 deletions inst/starter_models/si_partnerships_sti/README.Rmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
---
title: "STI Partnership Model"
output:
html_document:
df_print: paged
index_entry: "A modified SEIR model with Hospitalization and Vaccination"
author: ChatGPT and Steve Walker
output:
github_document:
toc: true
editor_options:
chunk_output_type: console
---

```{r setup}
Expand Down
89 changes: 89 additions & 0 deletions inst/starter_models/si_partnerships_sti/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
STI Partnership Model
================
ChatGPT and Steve Walker

- [Introduction](#introduction)
- [Model Description](#model-description)
- [Dynamics:](#dynamics)
- [Model Simulation](#model-simulation)
- [Running the Simulation](#running-the-simulation)
- [Results](#results)
- [Conclusion](#conclusion)

``` r
library(macpan2)
library(ggplot2)
```

## Introduction

This document describes a **Sexually Transmitted Infection (STI)
Partnership Model** implemented in `macpan2`. The model simulates how
STIs spread within a population where individuals form and dissolve
partnerships, incorporating both **within-partner transmission** and
**external transmission**.

## Model Description

The compartments in the model are:

- **S**: Susceptible individuals
- **I**: Infected individuals
- **SS**: Susceptible-Susceptible partnerships
- **SI**: Susceptible-Infected partnerships
- **II**: Infected-Infected partnerships

### Dynamics:

1. **Partnership Formation**: Susceptible individuals form
partnerships, transitioning into the **SS** or **SI** compartments.
2. **Partnership Dissolution**: Partnerships dissolve, moving
individuals back to the **S** or **I** compartments.
3. **Within-Partner Transmission**: Infected partners in **SI**
compartments transmit infection to their susceptible partners,
transitioning them to **II**.
4. **External Transmission**: Susceptible individuals can be infected
through external sources, moving from **S** to **I**.

## Model Simulation

We use the pre-defined model from the library.

``` r
# Load the pre-specified STI model
model <- mp_tmb_library("starter_models", "si_partnerships_sti", package = "macpan2")
```

## Running the Simulation

The simulation is run for 100 time steps, and results are captured for
analysis.

``` r
simulated_results <- model |>
mp_simulator(time_steps = 100, outputs = c("S", "I", "SS", "SI", "II")) |>
mp_trajectory()
```

## Results

The plot below shows the changes in population across the compartments
over time.

``` r
ggplot(simulated_results, aes(x = time, y = value, color = matrix)) +
geom_line() +
facet_wrap(~ matrix, scales = "free_y") +
theme_bw() +
labs(title = "STI Partnership Model Dynamics", x = "Time", y = "Population")
```

![](README_files/figure-gfm/plot_results-1.png)<!-- -->

## Conclusion

This model simulates STI spread through partnerships and external
sources, offering insights into the role of relationship dynamics in
disease transmission. The model can be expanded to explore additional
features such as heterogeneity in the population or multiple infection
strains.

0 comments on commit 130f5b1

Please sign in to comment.