glucopy.Gframe.mage#

Gframe.mage(per_day: bool = False)[source]#

Calculates the Mean Amplitude of Glycaemic Excursions (MAGE).

\[MAGE = \frac{1}{K} \sum \lambda_i * I(\lambda_i > s)\]
  • \(\lambda_i\) is the difference between a pair of consecutive peak and nadir of glycaemia (or nadir-peak).

  • \(s\) is the standar deviation of the glucose values.

  • \(I(\lambda_i > s)\) is the indicator function that returns 1 if \(\lambda_i > s\) and 0 otherwise.

  • \(K\) is the number of events such that \(\lambda_i > s\)

Parameters:

per_day (bool, default False) – If True, returns a pandas.Series with the MAGE for each day. If False, returns the MAGE for the entire dataset.

Returns:

mage – Mean Amplitude of Glycaemic Excursions.

Return type:

float | pandas.Series

Examples

Calculating the MAGE for the entire dataset:

In [1]: import glucopy as gp

In [2]: gf = gp.data('prueba_1')

In [3]: gf.mage()
Out[3]: 121.6843853820598

Calculating the MAGE for each day:

In [4]: gf.mage(per_day=True)
Out[4]: 
Day
2020-11-27     35.000000
2020-11-28    107.000000
2020-11-29    104.666667
2020-11-30     52.285714
2020-12-01     84.800000
                 ...    
2021-03-14     95.333333
2021-03-15    170.666667
2021-03-16    113.333333
2021-03-17     75.750000
2021-03-18    141.000000
Name: MAGE, Length: 112, dtype: float64