Tidyverse-native toolkit for intensive longitudinal data
(ILD).
Author: Alex Litovchenko.
remotes::install_github("alitovchenko/tidyILD")library(tidyILD)
# Prepare: validate time structure, add .ild_* columns and metadata
d <- data.frame(
id = rep(1:3, each = 5),
time = rep(as.POSIXct(0:4 * 3600, origin = "1970-01-01"), 3),
mood = rnorm(15)
)
x <- ild_prepare(d, id = "id", time = "time", gap_threshold = 7200)
# Inspect (summary tibble + list)
ild_summary(x)
# Within-between decomposition
x <- ild_center(x, mood)
# Spacing-aware lags (max_gap from metadata if omitted)
x <- ild_lag(x, mood, mode = "gap_aware", max_gap = 7200)
# Missingness (summary tibble + plot + by_id)
ild_missing_pattern(x, vars = "mood")
# Fit and report: tidy fixed effects, fitted vs observed, residual ACF + QQ
fit <- ild_lme(mood ~ 1 + (1 | id), data = x, ar1 = FALSE, warn_no_ar1 = FALSE)
tidy_ild_model(fit)
ild_plot(fit, type = "fitted")
diag <- ild_diagnostics(fit); diag; plot_ild_diagnostics(diag)ild_prepare() — encode longitudinal structure, spacing,
gapsild_summary() — one-shot summaryild_center() — person-mean centering (WP/BP)ild_lag() — index, gap-aware, or time-window lags
(supports lubridate::hours(2) etc.)ild_decomposition() — WP/BP variance and ratio;
optional WP vs BP density plotild_check_lags() — lag validity (valid/invalid,
pct_invalid, lag order)ild_crosslag() — one-call cross-lag: lag predictor,
check lags, fit outcome ~ lagild_acf() — ACF on a variable or on residuals
(pre-model check for AR1)ild_spacing_class() — regular-ish vs irregular-ishild_spacing() — spacing diagnostics (median/IQR, large
gaps %, CV) and AR1/CAR1 recommendationild_design_check() — aggregate spacing, WP/BP,
missingness, and recommendationsild_center_plot() — standalone WP vs BP density
plotild_missing_pattern() — missingness by
person/variableild_missing_bias() — test if missingness is associated
with a predictor (informative missingness)ild_align() — align secondary stream (e.g. wearables)
to primary ILD within a time windowild_lme() — mixed-effects model (lmer or nlme with
AR1/CAR1)ild_person_model() — fit model per person (N-of-1);
ild_person_distribution() — plot distribution of
estimatesild_diagnostics() — residual ACF, residuals vs
fitted/time (use print() for summary)plot_ild_diagnostics() — build diagnostic plots from an
ild_diagnostics objectild_plot() — trajectory, heatmap, gaps, fitted vs
observed, residual ACFild_heatmap(), ild_spaghetti() — aliases
for heatmap and trajectory plotsild_circadian() — variable by hour of day (when time is
POSIXct)augment_ild_model() — tibble with .ild_id, .ild_time,
outcome, .fitted, .residtidy_ild_model() — fixed-effect table (estimate, SE,
CI, p) for both enginesild_simulate() — simulated ILD (n_id, n_time/n_obs_per,
ar1, wp_effect, bp_effect, irregular)ild_power() — simulation-based power for a fixed effect
(ild_simulate → ild_lme → effect recovery)ema_example — built-in dataset
(data(ema_example))broom.mixed for
tidy(fit) and augment(fit) on
ild_lme fits.ild_prepare() through ild_lme() and
ild_plot().Documentation and vignettes are built with pkgdown. From the package root:
pkgdown::build_site(). Config:
_pkgdown.yml.
MIT.