glucopy.Gframe.modd#
- Gframe.modd(target_time: str | time | None = None, slack: int = 0, ignore_na: bool = True) float [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:
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
- Return type:
float
Examples
Calculating the MODD for a target time with a slack of 5 minutes:
In [1]: import glucopy as gp In [2]: gf = gp.data('prueba_1') In [3]: gf.modd(target_time='08:00', slack=5) Out[3]: 54.824561403508774
Calculating the MODD for all times with a slack of 10 minutes:
In [4]: gf.modd(slack=10) Out[4]: 65.37220573689416