bootstrap: Bootstrap Transition Networks from Sequence Data

View source: R/bootstrap.R

bootstrapR Documentation

Bootstrap Transition Networks from Sequence Data

Description

Perform bootstrapping on transition networks created from sequence data stored in a tna object. Bootstrapped estimates of edge weights are returned with confidence intervals and significance testing.

Usage

bootstrap(
  x,
  iter,
  level,
  method,
  threshold,
  consistency_range,
  seed = NULL,
  actor = NULL
)

## S3 method for class 'tna'
bootstrap(
  x,
  iter = 1000,
  level = 0.05,
  method = "stability",
  threshold,
  consistency_range = c(0.75, 1.25),
  seed = NULL,
  actor = NULL
)

## S3 method for class 'group_tna'
bootstrap(
  x,
  iter = 1000,
  level = 0.05,
  method = "stability",
  threshold,
  consistency_range = c(0.75, 1.25),
  seed = NULL,
  actor = NULL
)

Arguments

x

A tna or a group_tna object created from sequence data. Grouped models with scaled edge weights, and their networks, are not resampled (an error of class tna_error_scaling).

iter

An integer specifying the number of bootstrap samples to draw. Defaults to 1000.

level

A numeric value representing the significance level for hypothesis testing and confidence intervals. Defaults to 0.05.

method

A character string. This argument defines the bootstrap test statistic. The "stability" option (the default) compares edge weights against a range of "consistent" values defined by consistency_range. Weights that fall outside this range are considered insignificant. In other words, an edge is considered significant if its value is within the range in (1 - level) * 100% of the bootstrap samples. The "threshold" option instead compares the edge weights against a user-specified threshold value.

threshold

A numeric value to compare edge weights against. The default is the 10th percentile of the edge weights. Used only when method = "threshold".

consistency_range

A numeric vector of length 2. Determines how much the edge weights may deviate (multiplicatively) from their observed values (below and above) before they are considered insignificant. The default is c(0.75, 1.25) which corresponds to a symmetric 25% deviation range. Used only when method = "stability".

seed

A single numeric random seed for reproducible resampling, or NULL (the default) to use the current RNG state.

actor

An optional actor identifier for sequences nested in actors (for example, several sessions per student). Either a character string naming a non-sequence column of the data the model was built from (such as a column of meta_data from prepare_data()), or a vector with one identifier per sequence (per sequence of the data the grouped model was built from, for a group_tna object). When given, whole actors are resampled with replacement instead of single sequences (a cluster bootstrap; Davison & Hinkley, 1997, Section 3.8), so that sequences nested in actors are not treated as independent. The default NULL resamples sequences.

Details

The function first computes the original edge weights for the specified cluster from the tna object. It then performs bootstrapping by resampling the sequence data and recalculating the edge weights for each bootstrap sample. The mean and standard deviation of the transitions are computed, and confidence intervals are derived. The function also estimates p-values for each edge and identifies significant edges based on the specified significance level. A matrix of significant edges (those with estimated p-values below the significance level) is generated. Additional statistics on removed edges (those not considered significant) are provided.

All results, including the original transition matrix, bootstrapped estimates, and summary statistics for removed edges, are returned in a structured list.

Value

A tna_bootstrap object which is a list containing the following elements:

  • weights_orig: The original edge weight matrix.

  • weights_sig: The matrix of significant transitions (those with estimated p-values below the significance level).

  • weights_mean: The mean weight matrix from the bootstrap samples.

  • weights_sd: The standard deviation matrix from the bootstrap samples.

  • cr_lower: The lower bound matrix of the consistency range for the edge weights.

  • cr_upper: The upper bound matrix of the consistency range for the edge weights.

  • ci_lower: The lower bound matrix of the bootstrap confidence intervals for the edge weights.

  • ci_upper: The upper bound matrix of the bootstrap confidence intervals for the edge weights.

  • p_values: The matrix of estimated p-values for the edge weights.

  • summary: A data.frame with one row per edge with a positive weight and the columns from, to, weight, p_value, sig, cr_lower, cr_upper, ci_lower, and ci_upper. The same table is returned by summary.tna_bootstrap().

  • model: The tna model pruned to the significant edges (see prune() with method = "bootstrap").

If x is a group_tna object, the output is a group_tna_bootstrap object, which is a list of tna_bootstrap objects.

References

Davison, A. C., & Hinkley, D. V. (1997). Bootstrap Methods and their Application. Cambridge University Press.

See Also

Validation functions deprune(), estimate_cs(), markov_order(), permutation_test(), permutation_test.group_tna(), plot.group_tna_bootstrap(), plot.group_tna_permutation(), plot.group_tna_stability(), plot.tna_bootstrap(), plot.tna_markov_order(), plot.tna_permutation(), plot.tna_reliability(), plot.tna_stability(), print.group_tna_bootstrap(), print.group_tna_permutation(), print.group_tna_stability(), print.summary.group_tna_bootstrap(), print.summary.tna_bootstrap(), print.summary.tna_markov_order(), print.tna_bootstrap(), print.tna_markov_order(), print.tna_permutation(), print.tna_reliability(), print.tna_stability(), prune(), pruning_details(), reliability(), reprune(), summary.group_tna_bootstrap(), summary.tna_bootstrap(), summary.tna_markov_order(), summary.tna_permutation(), summary.tna_reliability(), summary.tna_stability()

Examples

model <- tna(group_regulation)
# Small number of iterations for CRAN
bootstrap(model, iter = 10)


tna documentation built on Nov. 17, 2026, 1:06 a.m.