Stack a 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.
stack_stats(stats, reh, add_actors = TRUE)A list with elements:
Data frame in long format with columns: time
(time-point index matching attr(stats, "subset") sequence),
all statistic columns, log_interevent (log
inter-event time; interval timing only), obs (1 = observed event,
0 = non-event), dyad (active dyad index 1..D), and — when
add_actors = TRUE and the riskset is available — actor1
(sender label) and actor2 (receiver label).
Integer vector of length 2: first and last event index.
Number of dyads in the risk set.
Number of events (time points).
Logical: whether the ordinal likelihood applies.
A tomstats object (output of remstats() or
tomstats()).
A remify object (output of remify::remify()).
Logical (default TRUE). When TRUE, two
extra columns actor1 (sender label) and actor2 (receiver
label) are appended by looking up reh$index$dyad_map_active (or
reh$riskset_info$included as a fallback). Set to FALSE to
suppress this lookup, e.g. when the riskset has not yet been resolved or
for performance reasons.
For interval timing (ordinal = FALSE), the stacked data can be
fitted with a Poisson GLM using log_interevent as an offset:
glm(obs ~ -1 + . - time - dyad - log_interevent,
offset = log_interevent, family = poisson, data = stacked$remstats_stack)
For ordinal timing (ordinal = TRUE), use conditional logistic
regression stratified by time point:
survival::clogit(obs ~ -1 + . - time - dyad +
strata(time), data = stacked$remstats_stack)