Terms and Auxiliary Networks
TERGM.EdgeStability — Type
EdgeStability <: TemporalTermThe number of dyads whose state agrees with the previous network: Σ_{ij} 1[y_ij = y^{t-1}_ij]. Its change statistic is +1 for a dyad that had a tie at t−1 and -1 for one that did not, whatever the current state.
A descriptive, not a model term. In a separable STERGM the change statistic is constant on the free dyads of either model — -1 on every prior non-tie (formation: the column is -edges), +1 on every prior tie (persistence: the column is +edges) — so the term carries no information a CMPLE could estimate; STERGMModel refuses it in a formula with an ArgumentError saying so. It is informative only in a non-separable (btergm memory-style) TERGM, which TERGM.jl does not fit. Use compute(EdgeStability(), curr, prev) for reporting.
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
compute(EdgeStability(), t1, t0) # 16.0: 20 ordered dyads, 4 changed
change_stat(EdgeStability(), t1, 2, 1, t0) # 1.0: 2→1 was a tie at t0
change_stat(EdgeStability(), t1, 2, 3, t0) # -1.0: 2→3 was notTERGM.Delrecip — Type
Delrecip <: TemporalTermDelayed reciprocity: Σ_{i≠j} y_ij · y^{t-1}_ji, the number of ordered dyads with i→j in the current network and j→i in the previous one (label delrecip; change statistic 1[y^{t-1}_ji], independent of the current state). Directed networks only: compute and change_stat throw an ArgumentError on an undirected network (a silent 0.0 would be a wrong, all-zero design column), and model construction refuses the term on undirected panels through requires_directed.
Provenance. This is btergm's delrecip (Leifeld, Cranmer & Desmarais; ?btergm::"tergm-terms", lag 1), applied here to the auxiliary networks of a separable model. R tergm (≥ 4, the version the golden fixture is generated with) has no delrecip term — tergm(... Form(~edges + delrecip) ...) fails with InitErgmTerm.delrecip not found — so no R fixture can pin its coefficient; its definition and change statistic are pinned by hand in the test suite instead.
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
compute(Delrecip(), t1, t0) # 1.0: 1→2 at t1 answers 2→1 at t0
change_stat(Delrecip(), t1, 2, 1, t0) # 1.0: t0 has 1→2
change_stat(Delrecip(), t1, 3, 4, t0) # 0.0: t0 has no 4→3
requires_directed(Delrecip()) # true
u0 = network(3; directed=false); u1 = copy(u0)
try; compute(Delrecip(), u1, u0); catch e; e isa ArgumentError; end # trueTERGM.PersistentEdge — Type
PersistentEdge <: TemporalTermThe number of edges present in both the current and the previous network (label persistent.edges). Its change statistic is 1 for a dyad that was a tie at t−1 and 0 otherwise.
A descriptive, not a model term (gof reports it as the persisted count). On the free dyads of a separable STERGM its change statistic is constant — 0 on every prior non-tie (formation: an all-zero column), 1 on every prior tie (persistence: the edges column again) — so STERGMModel refuses it in a formula with an ArgumentError; see EdgeStability.
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
compute(PersistentEdge(), t1, t0) # 2.0: 1→2 and 3→4 persist
change_stat(PersistentEdge(), t1, 1, 2, t0) # 1.0
change_stat(PersistentEdge(), t1, 2, 3, t0) # 0.0TERGM.NewEdge — Type
NewEdge <: TemporalTermThe number of edges present now but absent in the previous network (label new.edges). Its change statistic is 1 for a dyad that was not a tie at t−1 and 0 otherwise — the complement of PersistentEdge.
A descriptive, not a model term (gof reports it as the formed count). On the free dyads of a separable STERGM its change statistic is constant — 1 on every prior non-tie (formation: the edges column again), 0 on every prior tie (persistence: an all-zero column) — so STERGMModel refuses it in a formula with an ArgumentError; see EdgeStability.
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
compute(NewEdge(), t1, t0) # 2.0: 2→3 and 5→1 are new
change_stat(NewEdge(), t1, 2, 3, t0) # 1.0
change_stat(NewEdge(), t1, 1, 2, t0) # 0.0
compute(NewEdge(), t1, t0) + compute(PersistentEdge(), t1, t0) == ne(t1) # trueTERGM.formation_network — Function
formation_network(prev_net, curr_net) -> NetworkThe formation network Y⁺ = Y{t-1} ∪ Yt. Formation statistics are evaluated on Y⁺; its free dyads are the non-edges of Y{t-1}. Vertex, edge and network attributes of `prevnet` are preserved (nodal terms in a formation formula see their covariates).
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
yplus = formation_network(t0, t1)
ne(yplus) # 6: the 4 ties of t0 plus the 2 that formed
has_edge(yplus, 2, 1) && has_edge(yplus, 5, 1) # true: dissolved AND new ties are both inTERGM.dissolution_network — Function
dissolution_network(prev_net, curr_net) -> NetworkThe dissolution network Y⁻ = Y{t-1} ∩ Yt. Dissolution (persistence) statistics are evaluated on Y⁻; its free dyads are the edges of Y{t-1}. Attributes of `prevnetare preserved, as for [formation_network`](@ref).
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
yminus = dissolution_network(t0, t1)
ne(yminus) # 2: only 1→2 and 3→4 persisted
has_edge(yminus, 2, 1) # false: 2→1 dissolved
has_edge(yminus, 2, 3) # false: a new tie is not in Y⁻TERGM.edge_ages — Function
edge_ages(networks::Vector{<:Network}) -> Dict{Tuple{Int,Int}, Int}For the last network of the sequence, the age of each current edge: the number of consecutive panels (ending at the last one) in which it has been present. Keys are (src, dst) pairs; an empty sequence is an ArgumentError.
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
ages = edge_ages([t0, t1])
ages[(1, 2)] # 2: present at t0 and t1
ages[(2, 3)] # 1: formed at t1
length(ages) # 4: one entry per edge of the last panelTERGM.mean_edge_age — Function
mean_edge_age(networks::Vector{<:Network}) -> Float64Mean edge_ages of the final panel's edges (NaN if edgeless).
Example
using TERGM, ERGM
t0 = network(5; directed=true)
for (i, j) in [(1, 2), (2, 1), (3, 4), (4, 5)]; add_edge!(t0, i, j); end
t1 = network(5; directed=true)
for (i, j) in [(1, 2), (3, 4), (2, 3), (5, 1)]; add_edge!(t1, i, j); end
mean_edge_age([t0, t1]) # 1.5: ages 2, 2, 1, 1
mean_edge_age([t0, network(5; directed=true)]) # NaN: the last panel is edgeless