Intervention strategies

Usually you would like to add and compare interventions in your population. In this section, we will add one or multiple screening strategies to the simulation created in Run a model and elaborate on some technical details.

One screening scenario

The next example shows how to adapt the code from the previous section with a screening Process. We add a second Universe in which we apply screening. Note that we initialize the EC_screening Process with the built-in example screening data using the from_data() method. Also, note that we add the new Universe to our Model. Finally, note that for both Universes we use the same Birth, OC and EC processes because they don’t change between the Universes.

 1from miscore import Model, processes, Universe
 2
 3
 4# Birth process
 5birth = processes.Birth(
 6    year=1995
 7)
 8
 9# OC process
10oc = processes.OC(
11    life_table=processes.oc.data.us_2017.life_table_female
12)
13
14# EC process
15ec = processes.EC.from_data(
16    processes.ec.data.us
17)
18
19# EC screening process
20ec_screening = processes.EC_screening.from_data(
21    processes.ec_screening.data.example
22)
23
24# Universes
25no_screening = Universe(
26    name="no_screening",
27    processes=[
28        birth,
29        oc,
30        ec
31    ]
32)
33
34screening = Universe(
35    name="screening",
36    processes=[
37        birth,
38        oc,
39        ec,
40        ec_screening
41    ]
42)
43
44# Model
45model = Model(
46    universes=[
47        no_screening,
48        screening
49    ]
50)
51
52# Run
53result = model.run(
54    n=1000,
55    seed=123,
56    event_ages=range(0, 101),
57    event_years=range(1995, 2096),
58    duration_ages=range(0, 101),
59    duration_years=range(1995, 2096),
60    verbose=True
61)
62
63# Exports
64result.events.to_csv("events.csv")
65result.durations.to_csv("durations.csv")

The events.csv file now shows the events from both Universes. Note how in the screening Universe, events related to screening appear while these are absent in the no_screening Universe. Moreover, take a look at the lifeyears in the durations.csv file. Here you can see that more people get older due to screening.

Multiple screening scenarios

You could also be interested in evaluating multiple screening scenarios. In that case take the following steps:

  1. Generate multiple EC_screening Processes and initialize each of them with a different strategy.

  2. Generate multiple Universes that include the generic Birth, OC and EC process, and one of the EC_screening processes. Each Universe should have a different name.

  3. Add all Universes to your model.

Now all Universes represent a different screening strategy that is simulated with the same population.

The following example shows a simulation in which we compare no screening for EC, screening from age 30 to 35 and from age 30 to 40. The EC_screening Process also requires you to specify the maximum number of screening rounds over all strategies to compute the right amount of round-specific random numbers.

  1from miscore import Model, processes, Universe
  2
  3
  4# Birth process
  5birth = processes.Birth(
  6    year=1995
  7)
  8
  9# OC process
 10oc = processes.OC(
 11    life_table=processes.oc.data.us_2017.life_table_female
 12)
 13
 14# EC process
 15ec = processes.EC.from_data(
 16    processes.ec.data.us
 17)
 18
 19# EC screening process
 20strategy_35 = [
 21    {
 22        "age": age,
 23        "participation_first": 1.0,
 24        "participation_participator": 1.0,
 25        "participation_non_participator": 1.0,
 26    }
 27    for age in range(30, 36, 1)
 28]
 29
 30strategy_40 = [
 31    {
 32        "age": age,
 33        "participation_first": 1.0,
 34        "participation_participator": 1.0,
 35        "participation_non_participator": 1.0,
 36    }
 37    for age in range(30, 41, 1)
 38]
 39
 40max_rounds = max(len(strategy_35), len(strategy_40))
 41
 42ec_screening_35 = processes.EC_screening.from_data(
 43    processes.ec_screening.data.example,
 44    strategy=strategy_35,
 45    max_rounds=max_rounds,
 46)
 47
 48ec_screening_40 = processes.EC_screening.from_data(
 49    processes.ec_screening.data.example,
 50    strategy=strategy_40,
 51    max_rounds=max_rounds,
 52)
 53
 54# Universes
 55no_screening = Universe(
 56    name="no_screening",
 57    processes=[
 58        birth,
 59        oc,
 60        ec
 61    ]
 62)
 63
 64screening_35 = Universe(
 65    name="screening_35",
 66    processes=[
 67        birth,
 68        oc,
 69        ec,
 70        ec_screening_35
 71    ]
 72)
 73
 74screening_40 = Universe(
 75    name="screening_40",
 76    processes=[
 77        birth,
 78        oc,
 79        ec,
 80        ec_screening_40
 81    ]
 82)
 83
 84# Model
 85model = Model(
 86    universes=[
 87        no_screening,
 88        screening_35,
 89        screening_40
 90    ]
 91)
 92
 93# Run
 94result = model.run(
 95    n=1000,
 96    seed=123,
 97    event_ages=range(0, 101),
 98    event_years=range(1995, 2096),
 99    duration_ages=range(0, 101),
100    duration_years=range(1995, 2096),
101    verbose=True
102)
103
104# Exports
105result.events.to_csv("events.csv")
106result.durations.to_csv("durations.csv")

A few remarks:

  • For each disease, the inputs of the disease and screening process follow a strict patterns. For example, for the strategy in EC_screening, we need to supply the age and participation rates. This might be different for other diseases or custom-built processes. You can find more details at the disease-specific page at the Example MISCAN processes.

  • Here we used the built-in data for parameters on test sensitivity and probability of hysterectomy. You can find these parameters in the built-in data file, and you can modify these like you did for the disease processes, as explained in the previous tutorial.

  • The for age in range(30, 36, 1) means that the test is copied at each age between 30 up to but not including 36, every year. This is called Python list comprehension. You can use this instead of copying the test manually for each age to shorten your code significantly.

Warning

With this approach you add multiple Universes to one Model. Universes in the same Model will always simulate the exact same population. You can therefore only vary variables that are not related to a person’s characteristics. For example, you can vary the screening strategy or probability of hysterectomy because they are not related to a person. You cannot vary the EC hazard or EC dwell times between Universes because they are related to a person. For more information, see Limits of Universes.