knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(gp3sequences)
Sequence rows are rarely independent. The comparison API requires the group column and independent unit, and can additionally record pairs or assignment clusters. It aggregates the selected metric before permutation or bootstrap resampling.
paths <- replicate(20, sample(c("A", "B", "C"), 6L, replace = TRUE), simplify = FALSE) data <- do.call(rbind, lapply(seq_along(paths), function(i) { data.frame( participant_id = paste0("p", i), sequence_id = paste0("s", i), sequence_order = seq_along(paths[[i]]), state = paths[[i]], group = if (i <= 10L) "control" else "treatment", stringsAsFactors = FALSE ) }))
design <- declare_sequence_comparison_design( group_col = "group", unit_col = "participant_id", design = "randomized" ) result <- test_sequence_group_difference( data, design, metric = "state_prevalence", target_state = "A", n_permutations = 999L, seed = 10L ) result$estimate
Supported metrics are deliberately limited to transparent quantities: sequence length, transition count, state prevalence, and declared subsequence presence.
result <- bootstrap_sequence_group_difference( result, n_boot = 999L, level = 0.95, seed = 11L ) summarise_sequence_group_inference(result)
plot_sequence_group_inference(result, type = "permutation") plot_sequence_group_inference(result, type = "group_means")
For design = "randomized", causal interpretation still depends on valid
assignment, implementation, attrition handling, and an estimand consistent with
the design. For design = "observational", the output explicitly describes an
associational exchangeability-based contrast and does not license causal claims.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.