Skip to contents

This function compares two networks built from sequence data using permutation tests. The function builds Markov models for two sequence objects, computes the transition probabilities, and compares them by performing permutation tests. It returns the differences in transition probabilities, effect sizes, p-values, and confidence intervals.

Usage

permutation_test(
  x,
  y,
  iter = 1000,
  paired = FALSE,
  level = 0.05,
  measures = character(0),
  ...
)

Arguments

x

A tna object containing sequence data for the first tna model.

y

A tna object containing sequence data for the second tna model.

iter

An integer giving the number of permutations to perform. The default is 1000.

paired

A logical value. If TRUE, perform paired permutation tests; if FALSE, perform unpaired tests. The default is FALSE.

level

A numeric value giving the significance level for the permutation tests. The default is 0.05.

measures

A character vector of centrality measures to test. See centralities() for a list of available centrality measures.

...

Additional arguments passed to centralities().

Value

A tna_permutation object which is a list with two elements: edges and centralities, both containing the following elements

  • stats: A data.frame of original differences, effect sizes, and p-values for each edge or centrality measure. The effect size is computed as the observed difference divided by the standard deviation of the differences of the permuted samples.

  • diffs_true: A matrix of differences in the data.

  • diffs_sig: A matrix showing the significant differences.

Examples

model_x <- tna(group_regulation[1:200, ])
model_y <- tna(group_regulation[1001:1200, ])
# Small number of iterations for CRAN
permutation_test(model_x, model_y, iter = 20)
#> Edges
#> 
#> # A tibble: 81 × 4
#>    edge_name           diff_true effect_size p_value
#>    <chr>                   <dbl>       <dbl>   <dbl>
#>  1 adapt -> adapt       0            NaN        1   
#>  2 cohesion -> adapt    0.00541        0.923    0.95
#>  3 consensus -> adapt  -0.000679      -0.155    0.7 
#>  4 coregulate -> adapt  0.00769        0.464    0.75
#>  5 discuss -> adapt    -0.130         -9.35     0   
#>  6 emotion -> adapt     0.0101         1.65     0.3 
#>  7 monitor -> adapt    -0.00480       -0.346    1   
#>  8 plan -> adapt        0.00339        1.50     0.05
#>  9 synthesis -> adapt  -0.159         -2.38     0   
#> 10 adapt -> cohesion   -0.0907        -1.17     0.25
#> # ℹ 71 more rows