dynamic_pars#

class dynamic_pars(pars=None, **kwargs)[source]#

Bases: Intervention

A generic intervention that modifies a set of parameters at specified points in time.

The intervention takes a single argument, pars, which is a dictionary of which parameters to change, with following structure: keys are the parameters to change, then subkeys ‘days’ and ‘vals’ are either a scalar or list of when the change(s) should take effect and what the new value should be, respectively.

You can also pass parameters to change directly as keyword arguments.

Parameters:
  • pars (dict) – described above

  • kwargs (dict) – passed to Intervention()

Examples:

interv = hpv.dynamic_pars(condoms=dict(timepoints=10, vals={'c':0.9})) # Increase condom use amount casual partners to 90%
interv = hpv.dynamic_pars({'beta':{'timepoints':[10, 15], 'vals':[0.005, 0.015]}, # At timepoint 10, reduce beta, then increase it again
                          'debut':{'timepoints':10, 'vals':dict(f=dict(dist='normal', par1=20, par2=2.1), m=dict(dist='normal', par1=19.6, par2=1.8))}}) # Increase mean age of sexual debut

Methods

initialize(sim)[source]#

Initialize with a sim

apply(sim)[source]#

Loop over the parameters, and then loop over the timepoints, applying them if any are found