Abstract

Keywords
Glucose variability is increasingly regarded as a risk factor for diabetes-related complications. The mean amplitude of glycemic excursions (MAGE) is a common measure of glucose variability, and is defined by Service et al 1 as the arithmetic mean of the heights of glucose excursions that are greater than the standard deviation of the glucose values. MAGE is calculated manually by visually inspecting the glucose profiles. While there are several software programs for automated calculations, these programs have shown varying degrees of agreement.
The objective of this study was to develop an automated algorithm for MAGE that would achieve high accuracy against the reference standard of manual calculations as described in Service et al. 1 Manual calculations were performed on 45 publicly available CGM traces from a diverse set of patients (e.g., type 1 diabetes, type 2 diabetes, and those without diabetes). Each CGM trace corresponds to 1 day of measurements from midnight to midnight. An automated algorithm for MAGE calculation was developed to identify peaks and nadirs of glycemic excursions based on the crosses of a short and long moving average of the glucose profile. The shorter moving average is more affected by the local variation in the glucose values than the longer moving average, thus a peak or nadir must exist on the intervals that are bounded by the crosses of the two. A distinct advantage of using moving averages is that they smooth out local fluctuations and noise within larger trends in a glucose profile. The amount of smoothing can be tuned by varying window size parameters α and β. By default, the algorithm uses α = 5 and β = 32 as these values lead to high accuracy. The implementation of this algorithm is free and open-source, it is available in the R package iglu version 32,3 as well as in the accompanying GUI via Shiny App at https://irinagain.shinyapps.io/shiny_iglu/; no registration is required to access the app.
The accuracy of the algorithm was evaluated relative to manual calculations using a training and test splits via 5-fold cross-validation and compared to 4 other publicly available MAGE calculators: EasyGV, 4 cgmanalysis, 5 cgmquantify, 6 and the MAGE algorithm in the earlier version of iglu. 2 The newly developed algorithm had the median error of 1% relative to manual calculations. The median errors of cgmanalysis, cgmquantify, EasyGV, and algorithm in the earlier version of iglu were 20%, 78%, 11%, and 42%, respectively. Figure 1 shows boxplots of relative errors of all algorithms on 45 CGM traces. For proposed algorithm, both in-sample errors with the best choice of window sizes (α, β) and out-of-sample cross-validated errors are displayed.

Comparison of relative errors of different automatic algorithms for MAGE calculation relative to manual MAGE values on 45 continuous glucose monitor traces. The proposed method is implemented as ma (moving average) algorithm in R package iglu 3 ; best corresponds to the errors with α = 5, β = 32; cv corresponds to the out-of-sample errors based on 5- fold-cross-validation for α, β. Abbreviation: MAGE, mean amplitude of glycemic excursions.
The newly developed algorithm eliminates the need for tedious manual MAGE calculations and approximates the manual derivation better than existing approaches. The visual displays of the CGM traces, exact values for manual MAGE and the code to reproduce all analyses are publicly available at https://github.com/Nathaniel-Fernandes/mage_algorithm_data, allowing additional validation of presented results by a community at large.
Footnotes
Acknowledgements
The source of subset of the data is the T1D Exchange, but the analyses, content and conclusions presented herein are solely the responsibility of the authors and have not been reviewed or approved by the T1D Exchange.
Abbreviations
CGM, continuous glucose monitor; MAGE, mean amplitude of glycemic excursions.
Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: NSF CAREER Award DMS-2044823 to IG.
