% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stack_stats.R
\name{stack_stats}
\alias{stack_stats}
\title{Stack remstats for model fitting}
\usage{
stack_stats(stats, reh)
}
\arguments{
\item{stats}{A \code{tomstats} object (output of \code{remstats()} or
\code{tomstats()}).}

\item{reh}{A \code{remify} object (output of \code{remify::remify2()}).}
}
\value{
A list with elements:
\describe{
  \item{remstats_stack}{Data frame in long format with columns: \code{event}
    (event index), \code{dyad} (dyad index 1..D), all statistic columns,
    \code{obs} (1 = observed event, 0 = non-event), and
    \code{log_interevent} (log inter-event time; only for interval timing).}
  \item{subset}{Integer vector of length 2: first and last event index.}
  \item{D}{Number of dyads in the risk set.}
  \item{E}{Number of events (time points).}
  \item{ordinal}{Logical: whether the ordinal likelihood applies.}
}
}
\description{
Stack a \code{tomstats} object into long format suitable for fitting with
standard R model functions. Each row corresponds to one dyad in the risk
set at one event time point.
}
\details{
For interval timing (\code{ordinal = FALSE}), the stacked data can be
fitted with a Poisson GLM using \code{log_interevent} as an offset:
\code{glm(obs ~ -1 + . - event - dyad - log_interevent,
          offset = log_interevent, family = poisson, data = stacked$remstats_stack)}

For ordinal timing (\code{ordinal = TRUE}), use conditional logistic
regression stratified by event:
\code{survival::clogit(obs ~ -1 + . - event - dyad +
                       strata(event), data = stacked$remstats_stack)}
}
