mag {iglu} | R Documentation |
Calculate the Mean Absolute Glucose (MAG)
Description
The function mag calculates the mean absolute glucose or MAG.
Usage
mag(data, n = 60, dt0 = NULL, inter_gap = 45, tz = "")
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 60 to have hourly (60 minutes) intervals. |
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 |
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 where
is
the sum of the absolute change in glucose calculated for each interval as specified
by n, default n = 60 for hourly change in glucose. The sum is then divided by
which is the total time in hours.
Value
A tibble object with two columns: subject id and MAG value
Author(s)
Elizabeth Chun
References
Hermanides et al. (2010) Glucose Variability is Associated with Intensive Care Unit Mortaility, Critical Care Medicine 38(3) 838-842, doi:10.1097/CCM.0b013e3181cc4be9
Examples
data(example_data_1_subject)
mag(example_data_1_subject)
data(example_data_5_subject)
mag(example_data_5_subject)