modd_rcpp: Rcpp MODD Calculation

View source: R/variability_metrics.R

modd_rcppR Documentation

Rcpp MODD Calculation

Description

Calculates Mean of Daily Differences (MODD) with an Rcpp backend. The preprocessing follows the iglu day-grid approach used by iglu::modd: CGM data are linearly interpolated to a regular midnight-aligned full-day grid, respecting inter_gap, before same-time-of-day differences are calculated.

Usage

modd_rcpp(data, lag = 1, tz = "", inter_gap = 45)

Arguments

data

A dataframe containing CGM data with columns:

  • id: Subject identifier

  • time: POSIXct measurement timestamp

  • gl: Glucose value in mg/dL

lag

Whole number of days separating paired same-time-of-day glucose observations. Defaults to 1.

tz

Time zone used for day-grid alignment when supplied.

inter_gap

Maximum gap, in minutes, over which linear interpolation is allowed. Defaults to 45, matching iglu's internal default.

Value

A tibble with columns id and MODD.

References

Service, F. John, and Roger L. Nelson. "Characteristics of glycemic stability." Diabetes Care 3.1 (1980): 58-62.

See Also

iglu::modd, conga_rcpp, mage_rcpp

Examples

library(iglu)
data(example_data_5_subject)
modd_rcpp(example_data_5_subject)
modd_rcpp(example_data_5_subject, lag = 2)

cgmguru documentation built on July 8, 2026, 9:06 a.m.