Limits of Universes

The Intervention strategies tutorial explained that you can simulate different screening strategies by making a separate Universe for each strategy and adding those to your Model. To make a fair comparison between the strategies, the model ensures that the exact same individuals are simulated in each Universe.

However, this may also be a drawback. For example, when we want to compare the effect of a screening strategy on two different populations, we do not want the populations to be the same. In such cases, it’s not possible to use Universes. This tutorial will explain the problem and propose a solution.

The “Overwriting of a property” warning

Consider the following case. We are interested in two populations. In one of them, everybody is born in 1995 and dies at the age of 80. In the second, everybody is born in 1996 and dies at the age 78. We could try to model this with two Universes. For that, we define two Birth and OC processes, one for each population, and assign each of them to a different Universe:

 1from miscore import Model, processes, Universe
 2
 3# Birth processes
 4birth1995 = processes.Birth(
 5    year=1995
 6)
 7birth1996 = processes.Birth(
 8    year=1996
 9)
10
11# OC processes
12oc1995 = processes.OC(
13    age=80
14)
15oc1996 = processes.OC(
16    age=78
17)
18
19# Universes
20universe1995 = Universe(
21    name="universe1995",
22    processes=[birth1995, oc1995]
23)
24universe1996 = Universe(
25    name="universe1996",
26    processes=[birth1996, oc1996]
27)
28
29# Model
30model = Model(
31    universes=[universe1995, universe1996]
32)
33
34# Run
35result = model.run(
36    n=1000,
37    seed=123,
38    event_ages=range(0, 101),
39    duration_ages=range(0, 101),
40    return_properties=["__birth__", "oc_death"],
41    verbose=True
42)
43
44result.events.to_csv("events.csv")
45
46simulated_birth_year = result.properties["__birth__"].mean()
47simulated_oc_death = result.properties["oc_death"].mean()
48
49print(f"The mean birth year in the simulated population is: {simulated_birth_year}")
50print(f"The mean age of other-cause death in the simulated population is: {simulated_oc_death}")

We will get two warnings:

UserWarning: The Birth process overwrites the previously defined '__birth__' property.
UserWarning: The OC process overwrites the previously defined 'oc_death' property.

Also, after the model run, the following is printed:

The mean birth year in the simulated population is: 1996.0
The mean age of other-cause death in the simulated population is: 78.0

It appears that everybody in the model was born in 1996 and died at age 78, also the people in universe1995. You can also check yourself in the events.csv that this is the case for oc_death.

We can explain this using the concept of Properties. At the beginning of the simulation, all processes generate several characteristics for all individuals. These characteristics are called properties(). For example, the OC process generates a year for oc_death for every person, and the EC determines an ec_onset_age for every person based on the hazard parameter.

In the above example, first the OC process oc1995 generates an oc_death at age 80 for each individual. Then the second OC process oc1996 also generates an oc_death for each individual, now at age 78. However, MISCore is programmed such that all persons in a Model are the same, even for different universes. Therefore, the oc_death drawn by the oc1996 process overwrites the oc_death of the oc1995 process. Consequently, in both Universes, all individuals have an oc_death at 78. A similar thing happens for the birth year (__birth__ property) in the Birth process.

The bottom line is that, even though in this case we do not want it, the two Universes simulate the exact same population. Therefore, Universes cannot use different variables that are programmed as a Property in one of your processes, i.e. variables that are related to a person’s characteristics. For example, you can vary the screening or surveillance strategy because they are not related to a person. You cannot vary the Birth year, OC death age, EC hazard, or EC dwell times, because they are related to a person. The model will always warn you with an “Overwriting of a property” warning.

Conclusion

Universes are meant to compare different interventions, not different populations. Therefore, it is possible to vary the screening or surveillance strategies between universes. Instead, birth year, OC death ages and EC hazards or dwell times cannot be varied because they are related to a person. The model will always warn you with an “Overwriting of a property” warning.

Note

Consult the Run a population model tutorial on how to model different populations.