% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequence-inference.R
\name{test_sequence_group_difference}
\alias{test_sequence_group_difference}
\title{Test a sequence group difference}
\usage{
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
)
}
\arguments{
\item{data}{Long-format sequence data.}

\item{design}{A comparison design.}

\item{metric}{\code{"sequence_length"}, \code{"transition_count"},
\code{"state_prevalence"}, or \code{"subsequence_presence"}.}

\item{target_state}{Required for state prevalence.}

\item{target_subsequence}{Required for subsequence presence, expressed using
\code{separator}.}

\item{sequence_id_col, order_col, state_col}{Core sequence columns.}

\item{separator}{Subsequence label separator.}

\item{n_permutations}{Number of permutations.}

\item{alternative}{Alternative hypothesis.}

\item{seed}{Reproducibility seed.}
}
\value{
An object of class \code{gp3_sequence_group_inference}.
}
\description{
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.
}
\examples{
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)
}
