estimate_stability: Estimate edge stability by block resampling (experimental)

View source: R/stability.R

estimate_stabilityR Documentation

Estimate edge stability by block resampling (experimental)

Description

Experimental. The resampling design is methodologically grounded (block bootstrap for dependent data; edge-stability summaries in the spirit of bootnet), but unlike the estimators in this package it has no external reference implementation to validate against, and its interface, defaults, and reported statistics may change in a future release.

Refit an idiographic estimator across deterministic block resamples and summarize edge-level stability. Blocks preserve within-block time order: subject-day blocks when id and day are supplied, subjects when only id is supplied, days when only day is supplied, or consecutive row blocks for a single series. Duplicate blocks receive temporary ids/day labels before fitting so lag construction never connects two sampled copies.

Usage

estimate_stability(
  data,
  vars,
  estimator = c("var", "graphical_var", "mlvar", "usem", "gimme"),
  id = NULL,
  day = NULL,
  beep = NULL,
  n_resamples = 100L,
  resample = c("block", "split_half"),
  block_size = NULL,
  threshold = 1e-08,
  seed = NULL,
  keep_fits = FALSE,
  ...
)

Arguments

data

A data.frame or matrix with columns for variables and optional id/day/beep columns.

vars

Character vector of variable names.

estimator

"var" (default) for fit_var(), "graphical_var" for fit_graphical_var(), "mlvar" for fit_mlvar(), "usem" for fit_usem(), or "gimme" for fit_gimme().

id

Character. Name of the person-ID column, or NULL.

day

Character. Name of the day/session column, or NULL.

beep

Character. Name of the measurement-occasion column, or NULL.

n_resamples

Integer number of bootstrap/split resamples.

resample

"block" samples blocks with replacement; "split_half" samples half the blocks without replacement on each replicate.

block_size

Integer or NULL. Consecutive block length used only when neither id nor day is supplied. Defaults to floor(sqrt(nrow(data))).

threshold

Numeric. Absolute weight above which an edge is counted as selected. Default 1e-8.

seed

Optional integer seed for deterministic resampling.

keep_fits

Logical. Store successful resampled fits in the returned object? Default FALSE.

...

Further arguments passed to the estimator.

Value

A stability_result with ⁠$stability⁠ edge statistics, ⁠$original⁠ fit, ⁠$resample_edges⁠, ⁠$failures⁠, and ⁠$config⁠.

Examples

set.seed(1)
d <- data.frame(id = 1, day = rep(1:4, each = 12),
                beep = rep(1:12, 4),
                A = rnorm(48), B = rnorm(48), C = rnorm(48))
st <- estimate_stability(d, vars = c("A", "B", "C"), id = "id",
                         day = "day", beep = "beep",
                         n_resamples = 5, seed = 1)
head(st$stability)

idiographic documentation built on Aug. 4, 2026, 1:07 a.m.