method_switching#

class method_switching(year=None, from_methods=None, to_method=None, switch_prob=None, age_groups=None, postpartum=None, annual=False, verbose=False, **kwargs)[source]#

Bases: Intervention

Intervention that causes women to switch from specific contraceptive methods to a target method.

This intervention modifies the switching probabilities in the contraception module’s switching matrix to induce transitions from one or more source methods to a destination method.

Parameters:
  • year (float) – Year when switching intervention begins

  • from_methods (str/list) – Method name(s) or index(es) to switch from

  • to_method (str/int) – Method name or index to switch to

  • switch_prob (float/dict) – Probability of switching. Can be: - float: Same probability for all source methods - dict: {method_name: probability} for different rates per source

  • age_groups (list) – Age group names to apply switching. If None, applies to all age groups. Use None for all, or list like [‘<18’, ‘18-20’, ‘20-25’, ‘25-35’, ‘>35’]

  • postpartum (int/list) – Postpartum states to modify (0, 1, 6). If None, modifies all states.

  • annual (bool) – If True, switch_prob is annual and converted to per-timestep

  • verbose (bool) – Print detailed information

Example:

# 10% of injectable users switch to DMPA-SC starting in 2025
intv1 = fp.method_switching(
    year=2025,
    from_methods='inj',
    to_method='dmpasc',
    switch_prob=0.10,
    annual=False
)

# Different rates for different methods
intv2 = fp.method_switching(
    year=2030,
    from_methods=['dmpasc3', 'withdrawal', 'other_trad'],
    to_method='dmpasc6',
    switch_prob={'dmpasc3': 0.26, 'withdrawal': 0.20, 'other_trad': 0.20},
    annual=False
)

Attributes

auto_state_list

List of "automatic" states with boolean type (ss.BoolState) that were added via define_states()

dt

Get the current module timestep

has_product

Check if the intervention has a product

now

Shortcut to self.t.now()

state_dict

Return a flat dictionary (objdict) of all states

state_list

Return a flat list of all states (ss.Arr objects)

ti

Get the current module timestep

timevec

Shortcut to self.t.timevec

Methods