glucopy.Gframe.mard#
- Gframe.mard(smbg_df: DataFrame, slack: int = 0, interpolate: bool = False)[source]#
Calculates the Mean Absolute Relative Difference (MARD).
\[MARD = \frac{1}{N} \sum_{i=1}^N \frac{|CGM_i - SMBG_i|}{SMBG_i} * 100\]\(N\) is the number of SMBG readings.
\(CGM_i\) is the Continuous Glucose Monitoring (CGM) value at time i.
\(SMBG_i\) is the Self-Monitoring of Blood Glucose (SMBG) value at time i.
- Parameters:
smbg_df (pandas.DataFrame) – DataFrame containing the SMBG values. The dataframe must contain ‘SMBG’ and ‘Timestamp’ columns present in
glucopy.Gframe.data
.slack (int, default 0) – Maximum number of minutes that a given CGM value can be from an SMBG value and still be considered a match.
interpolate (bool, default True) – If True, the SMBG values will be interpolated to the CGM timestamps. If False, Only CGM values that have corresponding SMBG values will be used.
- Returns:
mard – Mean Absolute Relative Difference (MARD).
- Return type:
float
Examples
Calculating the MARD with a 5 minutes slack and without interpolation:
In [1]: import glucopy as gp In [2]: import pandas as pd In [3]: gf = gp.data('prueba_1') In [4]: smbg_timestamps = pd.to_datetime(['2020-11-27 22:00:00', ...: '2020-11-28 01:00:00', ...: '2020-11-28 04:00:00']) ...: In [5]: smbg_df = pd.DataFrame({'Timestamp': smbg_timestamps, ...: 'SMBG': [260, 239, 135]}) ...: In [6]: gf.mard(smbg_df=smbg_df, slack=5, interpolate=False) Out[6]: 1.7350157728706623
Calculating the MARD with a 5 minutes slack and with interpolation:
In [7]: gf.mard(smbg_df=smbg_df, slack=5, interpolate=True) Out[7]: 10.817772054088861