This vignette walks through the full tidyILD pipeline: prepare data, inspect structure, apply within-between decomposition and lags, fit a mixed-effects model, and run diagnostics and plots.
ild_summary(x)
#> $n_units
#> [1] 10
#>
#> $n_obs
#> [1] 120
#>
#> $time_range
#> [1] 0 40136
#>
#> $spacing
#> $spacing$median_dt
#> [1] 3612.244
#>
#> $spacing$iqr_dt
#> [1] 640.2958
#>
#> $spacing$n_intervals
#> [1] 110
#>
#> $spacing$pct_gap
#> [1] 0
#>
#> $spacing$by_id
#> # A tibble: 10 × 5
#> id median_dt iqr_dt n_intervals pct_gap
#> <int> <dbl> <dbl> <int> <dbl>
#> 1 1 3627. 549. 11 0
#> 2 2 3702. 854. 11 0
#> 3 3 3617. 740. 11 0
#> 4 4 3321. 702. 11 0
#> 5 5 3616. 588. 11 0
#> 6 6 3438. 481. 11 0
#> 7 7 3767. 816. 11 0
#> 8 8 3591. 499. 11 0
#> 9 9 3609. 194. 11 0
#> 10 10 3700. 521. 11 0
#>
#>
#> $n_gaps
#> [1] 0
#>
#> $pct_gap
#> [1] 0
ild_spacing_class(x)
#> [1] "regular-ish"Without residual autocorrelation (lmer):
With AR1 residual correlation (nlme):
diag <- ild_diagnostics(fit1, data = x)
names(diag$plot)
#> [1] "residuals_vs_fitted" "residuals_vs_time" "qq"Use a fixed seed when simulating or fitting models so results can be recreated. The pipeline is deterministic for a given seed and data. When saving results (e.g. after [ild_lme()] or [ild_diagnostics()]), you can attach a reproducibility manifest and save a single bundle with [ild_manifest()] and [ild_bundle()]:
# Optional: build a manifest with scenario and seed, then bundle the fit for saving
manifest <- ild_manifest(seed = 42, scenario = ild_summary(x), include_session = FALSE)
bundle <- ild_bundle(fit1, manifest = manifest, label = "model_ar1")
# saveRDS(bundle, "run.rds") # one file with result + manifest + label
names(bundle)
#> [1] "result" "manifest" "label"