Skip to content

Clarify aggregate.dur behavior in tSnaStats: inconsistent documentation vs. implementation #26

@Chimay-0426

Description

@Chimay-0426

The aggregate.dur argument in networkDynamic::tSnaStats() is described in the CRAN manual as

“optional numeric value giving the duration of time bin to aggregate over for each evaluation (default 0). See network.collapse”
but this brief description is ambiguous about interval endpoints, window placement, and whether the window is half-open or closed. It does not match the actual implementation, which aggregates edges over the half-open interval [t, t + aggregate.dur).

Actual behavior:

In practice, tSnaStats(nd, snafun="gden", time.interval=5, aggregate.dur=1) does the following for each sampling time t (0, 5, 10, …):

  1. Defines a half-open window [t, t + 1).
  2. Collects all dynamic edges whose start_time (and end_time) fall within that window.
  3. Collapses multiple spikes of the same dyad into a single static edge.
  4. Computes global density as (number of unique dyads) / (N*(N-1)).

By contrast, the documentation leaves users wondering:

  • Is the window [t, t + aggregate.dur) or (t − aggregate.dur/2, t + aggregate.dur/2]?

  • Are both endpoints included?

  • What happens when aggregate.dur = 0?

Suggested documentation update

Please revise the manual entry for aggregate.dur in both tSnaStats.Rd and online documentation to read something like:
- aggregate.dur: optional numeric value giving the duration of time bin to aggregate over for each evaluation (default 0).
+ aggregate.dur: numeric; for each evaluation at time t, collapse all dynamic edges whose activity intervals overlap
+                the half-open window [t, t + aggregate.dur).  
+                - Default = 0: instantaneous snapshot at t (no time window).  
+                - aggregate.dur > 0: window width = aggregate.dur (e.g., 1 gives [t, t+1)).  

Reproducible example

library(network)
library(networkDynamic)

# Create a small example of instantaneous edge spells
edge_spells <- data.frame(
  start_time = c(0.2, 0.7, 5.1, 5.6),
  end_time   = c(0.2, 0.7, 5.1, 5.6),
  tail       = c(1, 2, 3, 4),
  head       = c(2, 3, 4, 1)
)

nd <- networkDynamic(
  base.net    = network.initialize(4, directed = TRUE),
  edge.spells = edge_spells
)

# Default aggregate.dur = 0: snapshots at t = 0, 5, ...
tSnaStats(nd, snafun="gden", time.interval=5, aggregate.dur=0)

# aggregate.dur = 1: windows [0,1), [5,6), …
tSnaStats(nd, snafun="gden", time.interval=5, aggregate.dur=1)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions