stack_stats: Stack remstats for model fitting

View source: R/stack_stats.R

stack_statsR Documentation

Stack remstats for model fitting

Description

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.

Usage

stack_stats(stats, reh, add_actors = TRUE)

Arguments

stats

A tomstats object (output of remstats() or tomstats()).

reh

A remify object (output of remify::remify()).

add_actors

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.

Details

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)

Value

A list with elements:

remstats_stack

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).

subset

Integer vector of length 2: first and last event index.

D

Number of dyads in the risk set.

E

Number of events (time points).

ordinal

Logical: whether the ordinal likelihood applies.


remstats documentation built on July 15, 2026, 5:07 p.m.