Skip to content

Commit ca305e3

Browse files
authored
Merge pull request #93 from pythonhealthdatascience/dev
Dev
2 parents 251e212 + 90cf365 commit ca305e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2433
-694
lines changed

_quarto.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ website:
7575
contents:
7676
- pages/sharing/peer_review.qmd
7777
- pages/sharing/licence.qmd
78-
- pages/sharing/archive.qmd
7978
- pages/sharing/citation.qmd
8079
- pages/sharing/changelog.qmd
80+
- pages/sharing/archive.qmd
8181
- section: "Further information"
8282
contents:
8383
- pages/further_info/acknowledgements.qmd
@@ -102,7 +102,9 @@ website:
102102
Part of the STARS research project.<br>
103103
Code licence: <a href="https://opensource.org/license/mit" target="_blank" rel="noopener">MIT</a>.
104104
Text licence: <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="noopener">CC-BY-SA 4.0</a>.
105-
105+
right:
106+
- text: |
107+
Heather, A., Monks, T., Mustafee, N., & Harper, A. (2025). DES RAP Book: Reproducible Discrete-Event Simulation in Python and R. https://github.com/pythonhealthdatascience/des_rap_book. https://doi.org/10.5281/zenodo.17094155.
106108
comments:
107109
giscus:
108110
repo: "pythonhealthdatascience/des_rap_book"

pages/output_analysis/n_reps.qmd

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,147 @@
22
title: ❌ Number of replications
33
---
44

5-
<!--separate seeds for each replication-->
5+
{{< include ../../scripts/_reticulate-setup.md >}}
6+
7+
:::: {.pale-blue}
8+
9+
**Learning objectives:**
10+
11+
* TODO
12+
13+
**Pre-reading:**
14+
15+
This page continues on from: [Replications](outputs.qmd).
16+
17+
> *Entity generation → Entity processing → Initialisation bias → Performance measures → Replications → Number of replications*
18+
19+
**Required packages:**
20+
21+
These should be available from environment setup in the "🧪 Test yourself" section of [Environments](../setup/environment.qmd).
22+
23+
::: {.python-content}
24+
25+
```{python}
26+
from IPython.display import HTML
27+
from itables import to_html_datatable
28+
import numpy as np
29+
import pandas as pd
30+
import scipy.stats as st
31+
import simpy
32+
from sim_tools.distributions import Exponential
33+
```
34+
35+
:::
36+
37+
::: {.r-content}
38+
39+
```{r}
40+
#| output: false
41+
library(dplyr)
42+
library(kableExtra)
43+
library(knitr)
44+
library(simmer)
45+
library(tidyr)
46+
```
47+
48+
:::
49+
50+
::::
51+
52+
## Confidence interval method
53+
54+
The **confidence interval method** can be used to select the number of replications to run. The more replications you run, the narrower your confidence interval becomes, leading to a more precise estimate of the model's mean performance.
55+
56+
First, you select a **desired confidence interval** - for example, 95%. Then, run the model with an **increasing number of replications**, and identify the number required to achieve that precision in the estimate of a given metric - and also, to maintain that precision (as the intervals may converge or expand again later on).
57+
58+
When selecting the number of replications you should **repeat the analysis for all performance measures** and select the highest value as your number of replications.
59+
60+
We'll show two ways of implementing this: **manually** and **automated**.
61+
62+
The model being used is that from the [Replications](replications.qmd) page.
63+
64+
```{python}
65+
#| echo: false
66+
{{< include replications_resources/parameters.py >}}
67+
{{< include replications_resources/patient.py >}}
68+
{{< include replications_resources/model.py >}}
69+
{{< include replications_resources/summary_stats.py >}}
70+
{{< include replications_resources/runner.py >}}
71+
```
72+
73+
```{r}
74+
#| echo: false
75+
{{< include replications_resources/create_params.R >}}
76+
{{< include replications_resources/filter_warmup.R >}}
77+
{{< include replications_resources/calc_arrivals.R >}}
78+
{{< include replications_resources/calc_mean_wait.R >}}
79+
{{< include replications_resources/get_run_results.R >}}
80+
{{< include replications_resources/model.R >}}
81+
{{< include replications_resources/runner.R >}}
82+
```
83+
84+
## Manual inspection
85+
86+
<!--TODO: Import from sim-tools...waiting for Tom's update...-->
87+
88+
## Algorithm
89+
90+
## 🔍 Explore the example models
91+
92+
<div class="h3-tight"></div>
93+
94+
### 🩺 Nurse visit simulation
95+
96+
<!--TODO: Mention sensitivity analysis-->
97+
98+
:::: {.python-content}
99+
100+
{{< include ../../html/pydesrapmms.html >}}
101+
102+
::: {.blue-table}
103+
| | |
104+
| - | - |
105+
| **Key files** | |
106+
| **What to look for?** | |
107+
: {tbl-colwidths="[20,80]"}
108+
:::
109+
110+
::::
111+
112+
:::: {.r-content}
113+
114+
{{< include ../../html/rdesrapmms.html >}}
115+
116+
::: {.blue-table}
117+
| | |
118+
| - | - |
119+
| **Key files** | |
120+
| **What to look for?** | |
121+
: {tbl-colwidths="[20,80]"}
122+
:::
123+
124+
::::
125+
126+
### 🧠 Stroke pathway simulation
127+
128+
:::: {.python-content}
129+
130+
{{< include ../../html/pydesrapstroke.html >}}
131+
132+
Not relevant - replicating an existing model described in a paper, so just used the number of replications stated by the authors.
133+
134+
::::
135+
136+
:::: {.r-content}
137+
138+
{{< include ../../html/rdesrapstroke.html >}}
139+
140+
Not relevant - replicating an existing model described in a paper, so just used the number of replications stated by the authors.
141+
142+
::::
143+
144+
## 🧪 Test yourself
145+
146+
TODO
6147

7148
<br><br>

0 commit comments

Comments
 (0)