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

Open Beginner friendly
#26 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
r
Domain
documentation

Research direction

Start with the aggregate.dur entry in tSnaStats.Rd and run the reproducible networkDynamic example from the issue to confirm the documented behavior. Update the manual entry and corresponding online documentation to define the window, endpoint semantics, and aggregate.dur = 0 behavior; done means both documentation locations agree with the example.

Written by the indexing model from the issue text.

Description

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)


Dominant language
R
Stars
12
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statnet/networkDynamic

All issues in statnet/networkDynamic

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.