glucopy.metrics.modd#
- glucopy.metrics.modd(df: DataFrame, target_time: str | time | None = None, slack: int = 0, ignore_na: bool = True)[source]#
Calculates the Mean of Daily Differences (MODD).
\[MODD = \frac{1}{T} \sum_{t=1}^{T-1} | X_{t+1} - X_t |\]\(X_t\) is the glucose value at time t.
\(X_{t+1}\) is the glucose value 24 hours after time t.
\(T\) is the number of observations with a previous 24-hour observation.
- Parameters:
df (pandas.DataFrame) – DataFrame containing the CGM values. The dataframe must contain all columns present in
glucopy.Gframe.data
.target_time (str | datetime.time | None, default None) – Time of day to calculate the MODD for. If None, calculates the MODD for all available times.
slack (int, default 0) – Maximum number of minutes that the given time can differ from the actual time in the data.
ignore_na (bool, default True) – If True, ignores missing values (not found within slack). If False, raises an error if there are missing values.
- Returns:
modd – Mean of Daily Differences (MODD).
- Return type:
float
Notes
This function is meant to be used by
glucopy.Gframe.modd()