Parameterisation

Parameterisation#

Until now, we have only dealt with parameters when it was necessary to inform PyGOM which of our symbols refer to states and which to parameters. However, before PyGOM can find numerical solutions to the equations, it must be supplied with numerical parameter values. PyGOM’s solvers accept parameters in two forms: fixed, where they remain constant, or random, where they are drawn from a given distribution.

We demonstrate these features on our model system, the SIR compartmental model. We start, as always, by encapsulating our system in a PyGOM object, in this case loading from a module of commonly used models.

from pygom import common_models
model = common_models.SIR()

Fixed parameters#

Defining fixed parameters for \(\beta\), \(\gamma\) and \(N\) is simply done via a list of tuples (or a dictionary):

fixed_param_set = [
    ('beta', 0.3),
    ('gamma', 0.25),
    ('N', 1e4)
]

model.parameters = fixed_param_set

Random parameters#

Instead, suppose that we have some prior uncertainty on the values of our model parameters. We may wish to reflect this by running multiple model simulations with a variety of parameter values drawn randomly from a probability distribution.

In this example, a suitable choice of distribution for \(\gamma\) and \(\beta\) might be a Gamma distribution. The total population, \(N\), can remain fixed.

To define our random distributions, we make use of the familiar syntax from R. Slightly cumbersomely, we have to define it via a tuple, where the first item is the function handle (name) and the second the parameters.

from pygom.utilR import rgamma

random_param_set = {
    'gamma': (rgamma, {'shape': 100, 'rate': 400}),
    'beta': (rgamma, {'shape': 100, 'rate': 333.33}),
    'N': 1e4
}

model.parameters = random_param_set