% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wtna.R
\name{wtna}
\alias{wtna}
\title{Window-based Transition Network Analysis}
\usage{
wtna(
  data,
  method = c("transition", "cooccurrence", "both"),
  type = c("frequency", "relative"),
  codes = NULL,
  window_size = 1L,
  mode = c("non-overlapping", "overlapping"),
  actor = NULL
)
}
\arguments{
\item{data}{Data frame with one-hot encoded columns (0/1 binary).}

\item{method}{Character. Network type: \code{"transition"} (directed),
\code{"cooccurrence"} (undirected), or \code{"both"} (returns list of
two networks). Default: \code{"transition"}.}

\item{type}{Character. Output type: \code{"frequency"} (raw counts) or
\code{"relative"} (row-normalized probabilities). Default: \code{"frequency"}.}

\item{codes}{Character vector or NULL. Names of the one-hot columns to use.
If NULL, auto-detects binary columns. Default: NULL.}

\item{window_size}{Integer. Number of consecutive rows to aggregate per
window. Default: 1 (no windowing).}

\item{mode}{Character. Window mode: \code{"non-overlapping"} (fixed, separate
windows) or \code{"overlapping"} (rolling, step = 1).
Default: \code{"non-overlapping"}.}

\item{actor}{Character or NULL. Name of the actor/ID column for per-group
computation. If NULL, treats all rows as one group. Default: NULL.}
}
\value{
For \code{method = "transition"} or \code{"cooccurrence"}: a
\code{netobject} (see \code{\link{build_network}}).

For \code{method = "both"}: a \code{wtna_mixed} object with elements
\code{$transition} and \code{$cooccurrence}, each a \code{netobject}.
}
\description{
Computes networks from one-hot (binary indicator) data using temporal
windowing. Supports transition (directed), co-occurrence (undirected),
or both network types.
}
\details{
\strong{Transitions}: Uses \code{crossprod(X[-n,], X[-1,])} to count
how often state i is active at time t AND state j at time t+1.

\strong{Co-occurrence}: Uses \code{crossprod(X)} to count states that are
simultaneously active in the same row.

\strong{Windowing}: For \code{window_size > 1}, rows are aggregated into
windows before computing networks. Non-overlapping windows are fixed,
separate blocks; overlapping windows roll forward one row at a time.
Within each window, any active indicator (1) in any row makes that state
active for the window.

\strong{Per-actor}: When \code{actor} is specified, networks are computed
per group and summed.
}
\examples{
oh <- matrix(c(1,0,0, 0,1,0, 0,0,1, 1,0,0), nrow = 4, byrow = TRUE,
             dimnames = list(NULL, c("A","B","C")))
w <- wtna(oh)

\donttest{
# Simple one-hot data
df <- data.frame(
  A = c(1, 0, 1, 0, 1),
  B = c(0, 1, 0, 1, 0),
  C = c(0, 0, 1, 0, 0)
)

# Transition network
net <- wtna(df)
print(net)

# Both networks
nets <- wtna(df, method = "both")
print(nets$transition)
print(nets$cooccurrence)

# With windowing
net <- wtna(df, window_size = 2, mode = "non-overlapping")
}

}
\seealso{
\code{\link{build_network}}, \code{\link{prepare_onehot}}
}
