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.

  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
 40ec_screening_35 = processes.EC_screening.from_data(
 41    processes.ec_screening.data.example,
 42    strategy=strategy_35
 43)
 44
 45ec_screening_40 = processes.EC_screening.from_data(
 46    processes.ec_screening.data.example,
 47    strategy=strategy_40
 48)
 49
 50# Universes
 51no_screening = Universe(
 52    name="no_screening",
 53    processes=[
 54        birth,
 55        oc,
 56        ec
 57    ]
 58)
 59
 60screening_35 = Universe(
 61    name="screening_35",
 62    processes=[
 63        birth,
 64        oc,
 65        ec,
 66        ec_screening_35
 67    ]
 68)
 69
 70screening_40 = Universe(
 71    name="screening_40",
 72    processes=[
 73        birth,
 74        oc,
 75        ec,
 76        ec_screening_40
 77    ]
 78)
 79
 80# Model
 81model = Model(
 82    universes=[
 83        no_screening,
 84        screening_35,
 85        screening_40
 86    ]
 87)
 88
 89# Run
 90result = model.run(
 91    n=1000,
 92    seed=123,
 93    event_ages=range(0, 101),
 94    event_years=range(1995, 2096),
 95    duration_ages=range(0, 101),
 96    duration_years=range(1995, 2096),
 97    verbose=True
 98)
 99
100# Exports
101result.events.to_csv("events.csv")
102result.durations.to_csv("durations.csv")

A few remarks:

  • For each disease, the structure of a strategy follows strict patterns. For example, for EC, we need to supply the age and participation rates. This might be different for other diseases. 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.