sid.statistics

Module Contents

Functions

calculate_r_effective(df: pandas.DataFrame, window_length: int = 7) → pandas.Series

Calculate the effective reproduction number, \(R_e\).

calculate_r_zero(df: pandas.DataFrame, window_length: int = 7, threshold: float = 0.75) → pandas.Series

Calculate the basic replication number \(R_0\).

calculate_r_effective(df: pandas.DataFrame, window_length: int = 7) pandas.Series[source]

Calculate the effective reproduction number, \(R_e\).

More explanation can be found in the Wikipedia article.

Note

The infection counter is only reset to zero once a person becomes infected again so abstracting from very fast reinfections its mean among those that ceased to be infectious in the last window_length is \(R_e\).

Parameters
  • df (pandas.DataFrame) – states DataFrame for which to calculate \(R_e\), usually the states of one day.

  • window_length (int) – how many days to use to identify the previously infectious people. The lower, the more changes in behavior can be seen, but the smaller the number of people on which to calculate \(R_e\).

Returns

mean number of people infected by someone whose

infectious spell ended in the last window_length days.

Return type

r_effective (pandas.Series)

calculate_r_zero(df: pandas.DataFrame, window_length: int = 7, threshold: float = 0.75) pandas.Series[source]

Calculate the basic replication number \(R_0\).

This is done by dividing the effective reproduction number by the share of susceptible people in the DataFrame. Using R_e and the share of the susceptible people from the very last period of the time means that heterogeneous matching and changes in the rate of immunity are neglected.

More explanation can be found here: https://bit.ly/2VZOR5a.

Parameters
  • df (pandas.DataFrame) – states DataFrame for which to calculate \(R_0\), usually the states of one period.

  • window_length (int) – how many days to use to identify the previously infectious people. The lower, the more changes in behavior can be seen, but the smaller the number of people on which to calculate \(R_0\).

  • threshold (float) – Parameter determining at which immunity level threshold an individual is considered as “immune” in a binary setting. This is needed for the approximation of the share of susceptible individuals. Must be in [0, 1]; default: 0.75.

Returns

The average number of people that would have been

infected by someone whose infectious spell ended in the last window_length days if everyone had been susceptible, neglecting heterogeneous matching and changes in the rate of immunity.

Return type

r_zero (pandas.Series)