The function mag calculates the mean absolute glucose or MAG.
Arguments
- data
DataFrame object with column names "id", "time", and "gl".
- n
Integer giving the desired interval in minutes over which to calculate the change in glucose. Default is the CGM meter's frequency (dt0) to measure change in every reading.
- dt0
The time frequency for interpolation in minutes, the default will match the CGM meter's frequency (e.g. 5 min for Dexcom).
- inter_gap
The maximum allowable gap (in minutes) for interpolation. The values will not be interpolated between the glucose measurements that are more than inter_gap minutes apart. The default value is 45 min.
- tz
A character string specifying the time zone to be used. System-specific (see
as.POSIXct
), but " " is the current time zone, and "GMT" is UTC (Universal Time, Coordinated). Invalid values are most commonly treated as UTC, on some platforms with a warning.
Details
A tibble object with a column for subject id and a column for MAG values is returned.
The glucose values are linearly interpolated over a time grid starting at the beginning of the first day of data and ending on the last day of data. Then, MAG is calculated as \(\frac{|\Delta G|}{\Delta t}\) where \(|\Delta G|\) is the sum of the absolute change in glucose per n-minute interval (default n = dt0). The sum is then divided by \(\Delta t\), the total elapsed time (in hours), yieldng the Mean Absolute change in Glucose (mg/dL per hour).
References
Hermanides et al. (2010) Glucose Variability is Associated with Intensive Care Unit Mortality, Critical Care Medicine 38(3) 838-842, doi:10.1097/CCM.0b013e3181cc4be9
Kohnert et al. (2013) Evaluation of the Mean Absolute Glucose Change as a Measure of Glycemic Variability Using Continuous Glucose Monitoring Data, Diabetes Technol Ther. 15(6) 448-454, doi:10.1089/dia.2012.0303
Examples
data(example_data_1_subject)
mag(example_data_1_subject)
#> # A tibble: 1 × 2
#> id MAG
#> <fct> <dbl>
#> 1 Subject 1 27.1
data(example_data_5_subject)
mag(example_data_5_subject)
#> # A tibble: 5 × 2
#> id MAG
#> <fct> <dbl>
#> 1 Subject 1 27.1
#> 2 Subject 2 32.2
#> 3 Subject 3 36.2
#> 4 Subject 4 27.6
#> 5 Subject 5 47.3