calc_AUC | R Documentation |
This function calculates the area under the curve for a mixed-meal tolerance test (MMTT), oral glucose tolerance test (OGTT), or similar, using the trapezoidal rule. As input, it takes a data frame of C-peptide or insulin values for each timepoint, with an identifier column. This can be a long data frame with timepoint indicated in a separete column, or a wide data frame with separate columns for each timepoint. Options include 2-hour vs. 4-hour AUC, dropping visits with missing timepoints vs. using the average of the two surrounding timepoints, and whether to use the 0 timepoint or the average of the pre-0 and 0 timepoints as the initial value.
calc_AUC(
input_data, input_format = "wide",
pep_colname = "pep", timepoint_colname = "timepoint",
initial_timepoint = "zero", treat_missing = "drop",
auc_timeframe = "2-hour")
input_data |
data frame containing the C-peptide data from MMTTs or stimulated insulin data from OGTTs. Should contain a unique visit/test identifer and the C-peptide level at each timepoint. If there are issues with values below the detection threshold, those must be resolved before running this function (i.e. values such as "<0.01" are not allowed) |
input_format |
character, the format of the C-peptide data. Defaults to "wide", which has each timepoint in a separate column, with a single row for each visit. Set to "long" if the data frame has a separate row for each timepoint. |
pep_colname |
character or numeric. Usage depends on the value of |
timepoint_colname |
character or numeric, the column containing the timepoint values. Used only if |
initial_timepoint |
character, how to handle the initial timepoint. Defaults to "zero", which uses the 0-minute timepoint. Alternative option is "average", which uses the average of the pre-0 timepoint and the 0 timepoint. |
treat_missing |
character, how to handle visits with missing timepoints. Defaults to "drop", which causes any visits missing a timepoint in the AUC window to be dropped. Alternative option is "weighted_average", which causes the AUC to be calculated as if that timepoint were not taken (i.e. the curve is drawn with a straight line between the preceding and following timepoints); this works only for non-consecutive missing timepoints that are not the first or last in the AUC calculation! |
auc_timeframe |
character, either "2-hour" or "4-hour". Determines whether the AUC is calculated over 2 hours or 4. If "4-hour" is selected, any 2-hour MMTTs will be dropped. Defaults to "2-hour". |
a vector containing the AUC values, with NA where it could not be calculated
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.