View source: R/sequence-inference.R
| test_sequence_group_difference | R Documentation |
Aggregates sequence metrics to the declared independent unit and performs a permutation or randomization test. For observational data the p-value tests exchangeability-based association only; it is not a causal estimate.
test_sequence_group_difference(
data,
design,
metric = c("sequence_length", "transition_count", "state_prevalence",
"subsequence_presence"),
target_state = NULL,
target_subsequence = NULL,
sequence_id_col = "sequence_id",
order_col = "sequence_order",
state_col = "state",
separator = " > ",
n_permutations = 999L,
alternative = c("two.sided", "greater", "less"),
seed = 1L
)
data |
Long-format sequence data. |
design |
A comparison design. |
metric |
|
target_state |
Required for state prevalence. |
target_subsequence |
Required for subsequence presence, expressed using
|
sequence_id_col, order_col, state_col |
Core sequence columns. |
separator |
Subsequence label separator. |
n_permutations |
Number of permutations. |
alternative |
Alternative hypothesis. |
seed |
Reproducibility seed. |
An object of class gp3_sequence_group_inference.
data <- data.frame(
participant_id = rep(paste0("p", 1:8), each = 4L),
sequence_id = rep(paste0("s", 1:8), each = 4L),
sequence_order = rep(1:4, times = 8L),
state = c(rep(c("A", "B", "C", "D"), 4L),
rep(c("A", "A", "C", "D"), 4L)),
group = rep(rep(c("control", "treatment"), each = 4L), each = 4L)
)
design <- declare_sequence_comparison_design("group", "participant_id",
design = "randomized")
test_sequence_group_difference(data, design, metric = "state_prevalence",
target_state = "A", n_permutations = 99L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.