Endogenous Effects API Reference

The statistic protocol

Revel's statistics are methods of the ecosystem's shared compute and name generics (NetworkCore.jl), in both signatures its relational event packages use.

Revel.AbstractRevelStatistic — Type
AbstractRevelStatistic <: REM.AbstractStatistic

Supertype of every statistic defined in Revel.jl. A subtype implements the internal _value(stat, events, sender, receiver, time) and inherits both compute signatures of the ecosystem — the history interface compute(stat, history, sender, receiver, time) and REM's compute(stat, state, sender, receiver) — together with name(stat).

Example

using Revel, REM
Inertia() isa AbstractRevelStatistic          # true
SendEffect([1.0, 2.0]) isa AbstractStatistic  # true — usable in REM.fit_rem too
source
NetworkCore.compute — Method
compute(stat::AbstractRevelStatistic, history::InteractionHistory, sender, receiver, time)
compute(stat::AbstractRevelStatistic, state::REM.EventNetworkState, sender, receiver)

The value of a Revel statistic for the candidate event sender → receiver, read off the events of the history that happened at or before time — later events in the history are ignored, so a whole sequence can be passed and evaluated at any point of it. The history must be in time order (an ArgumentError says so otherwise) and event times must be finite. These are methods of the ecosystem's shared compute generic (NetworkCore.jl), in the two signatures its relational event packages use: the history interface, on an InteractionHistory at an explicit time, and REM.jl's, on an EventNetworkState at its current_time. The two agree exactly.

The REM interface reads the state's event log, which carries no event types, so a statistic restricted to types= works with the history interface only.

Example

using Revel, REM
events = [Event(1, 2, 1.0), Event(1, 2, 2.0), Event(2, 1, 3.0)]
history = build_history(events)
compute(Inertia(), history, 1, 2, 4.0)          # 2.0
state = EventNetworkState{Float64}()
foreach(e -> update!(state, e), events)
state.current_time = 4.0
compute(Inertia(), state, 1, 2)                 # 2.0 — the same computation
source
NetworkCore.name — Method
name(stat::AbstractRevelStatistic) -> String

The statistic's name: the label of its coefficient and of its column in an event_design. The automatic name spells out what distinguishes the statistic from the default one — its scaling, transform, memory, event types — and the name= keyword of every constructor overrides it. Two statistics in one model must have different names.

Example

using Revel
name(Inertia())                                       # "inertia"
name(Inertia(scaling=:prop, memory=HalfLife(30.0)))   # "inertia.prop[halflife=30.0]"
name(OTP(transform=:log1p, types=:email))             # "log1p(otp[types=email])"
name(Inertia(keep=(s, r, t, w, ty) -> w > 1, name="heavy_inertia"))   # "heavy_inertia"
source
Revel.InteractionHistory — Type
InteractionHistory{T}()
InteractionHistory()

The time-ordered events absorbed so far (history.events::Vector{Event{T}}), against which compute(stat, history, sender, receiver, time) evaluates a statistic. T is the type of the event times (Float64 by default). update_history! appends an event and build_history builds a history from a vector of events.

The fitters replay one history in place (they empty history.events and absorb the events again), and a statistic's layer notices the rewrite and rebuilds its index; a history must otherwise only grow.

Example

using Revel
h = InteractionHistory()
update_history!(h, Event(1, 2, 1.0))
update_history!(h, Event(2, 1, 2.0))
length(h.events)                         # 2
compute(Reciprocation(), h, 1, 2, 3.0)   # 1.0 — one past 2 → 1 event
source
Revel.update_history! — Function
update_history!(history::InteractionHistory, event::Event) -> history

Append event to the history. Events must be absorbed in time order.

Example

using Revel
h = InteractionHistory()
update_history!(h, Event(1, 2, 1.0))
compute(Inertia(), h, 1, 2, 2.0)         # 1.0
source
Revel.build_history — Function
build_history(events) -> InteractionHistory

An InteractionHistory holding events (absorbed in the order given): the history against which compute(stat, history, sender, receiver, time) evaluates a statistic by hand.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(2, 1, 2.0), Event(1, 2, 3.0)])
compute(Inertia(), h, 1, 2, 4.0)         # 2.0 — two past 1 → 2 events
compute(Reciprocation(), h, 1, 2, 4.0)   # 1.0 — one past 2 → 1 event
source

The parametric statistics

Revel.DyadEffect — Type
DyadEffect(layer; direction=:out, scaling=:none, denominator=:sender_out,
           empty=0.0, transform=identity, name=nothing)

The weight a EventLayer puts on the candidate dyad s → r (direction=:out), on the reversed dyad r → s (:in), or on both (:sym). Inertia, Reciprocation and DyadActivity are its named forms.

scaling=:prop divides by an actor's degree — the denominator, one of :sender_out, :sender_in, :receiver_out, :receiver_in — and returns empty when that degree is zero. The zero-history value is a convention that differs by package (relevent and remstats use 1/(n−1)), so it is a keyword here, not a hidden default.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
raw = DyadEffect(EventLayer())
share = DyadEffect(EventLayer(); scaling=:prop, empty=0.5)
compute(raw, h, 1, 2, 4.0)      # 2.0
compute(share, h, 1, 2, 4.0)    # 0.666… — two of actor 1's three sends
compute(share, h, 3, 1, 4.0)    # 0.5 — actor 3 has sent nothing: `empty`
source
Revel.DegreeEffect — Type
DegreeEffect(layer; role=:sender, kind=:out, measure=:events, scaling=:none,
             empty=0.0, transform=identity, name=nothing)

A degree of the candidate's sender (role=:sender) or receiver (:receiver): events sent (kind=:out), received (:in) or both (:total). The six named forms are OutdegreeSender, IndegreeSender, TotaldegreeSender, OutdegreeReceiver, IndegreeReceiver and TotaldegreeReceiver.

On a symmetric=true layer (undirected events) the three kinds coincide: each is the number of events the actor took part in.

measure=:partners counts distinct partners instead of events, and measure=:intensity divides the events by the partners — the "degree" and the "intensity" (events per collaboration tie) of Vu, Lomi, Mascia & Pallotti (2017, appendix eq. 2); measure=:events (default) is plain event volume. scaling=:prop divides event volume by the number of past events (twice that for :total), the normalised degree of relevent's NIDSnd family and remstats' scaling="prop"; empty is returned before any event.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
compute(DegreeEffect(EventLayer()), h, 1, 2, 4.0)                        # 3.0
compute(DegreeEffect(EventLayer(); measure=:partners), h, 1, 2, 4.0)     # 2.0
compute(DegreeEffect(EventLayer(); measure=:intensity), h, 1, 2, 4.0)    # 1.5
compute(DegreeEffect(EventLayer(); scaling=:prop), h, 1, 2, 4.0)         # 1.0
source
Revel.DyadDegreeEffect — Type
DyadDegreeEffect(layer; sender_kind=:total, receiver_kind=:total, combine=:sum,
                 measure=:events, scaling=:none, empty=0.0,
                 transform=identity, name=nothing)

Two actor degrees combined into one dyad statistic: their :sum, :min, :max, absolute difference (:absdiff) or :product. The named forms are TotaldegreeDyad, DegreeMin, DegreeMax, DegreeDiff and DegreeAssortativity. With scaling=:prop each degree is divided by the number of past events (twice that for :total) before combining.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 3, 3.0)])
compute(DyadDegreeEffect(EventLayer(); combine=:absdiff), h, 1, 3, 4.0)   # 0.0
compute(DyadDegreeEffect(EventLayer(); sender_kind=:out, receiver_kind=:in,
                         combine=:product), h, 1, 3, 4.0)                 # 4.0
source
Revel.TwoPathEffect — Type
TwoPathEffect(leg1, leg2=leg1; dir1=:out, dir2=:in, combine=:min, root=false,
              order=:none, third=nothing, transform=identity, name=nothing)

The general two-path statistic: a sum over third actors k ∉ {s, r} of the two legs linking the candidate's sender and receiver through k.

  • leg1, dir1 — the sender's leg: :out reads w₁(s, k), :in reads w₁(k, s), :sym their sum.
  • leg2, dir2 — the receiver's leg: :in reads w₂(k, r), :out reads w₂(r, k), :sym their sum. A different layer per leg gives cross-network and signed closure (goldfish mixedTrans; the balance statistics of Brandes, Lerner & Snijders 2009; rem triadStat(eventtypevalues=…)).
  • combine — how the two legs of one path are combined. The packages and papers disagree, which is why "the same" triadic effect differs in value across them: :min (Butts 2008; relevent; remstats; the default of eventnet's dyadic triangle statistics, as its documentation states — not verified by running it), :product (rem; Vu et al. 2011; Perry & Wolfe 2013), :harmonic — 2ab/(a + b), the harmonic mean of Vu, Lomi, Mascia & Pallotti (2017, eq. 12) — :sum, :max, or :count, the number of distinct third actors (goldfish; remstats unique=TRUE).
  • root — take the square root of the total (rem's triadStat; the balance statistics).
  • order — :leg1_first or :leg2_first keep a third actor only if some event on the named leg precedes some event on the other (the dyads' first and last events over the whole history, whatever the memory); :none ignores timing. This is a cheaper device than the time-ordered transitivity of Arena, Mulder & Leenders (2024, eq. 12), which counts the time-ordered pairs of events on the two legs within a lag window, and it agrees with that statistic only when each leg holds a single event.
  • third — a weight (s, k, r) -> Real on the third actor: the hook for closure among actors sharing an attribute (see matching_third) and for eventnet's node-attribute-on-the-broker closure.

OTP, ITP, OSP, ISP, SharedPartners and BalanceEffect are its named forms.

Example

using Revel
h = build_history([Event(1, 3, 1.0), Event(1, 3, 2.0), Event(3, 2, 3.0)])
L = EventLayer()
compute(TwoPathEffect(L), h, 1, 2, 4.0)                       # min(2, 1) = 1.0
compute(TwoPathEffect(L; combine=:product), h, 1, 2, 4.0)     # 2.0
compute(TwoPathEffect(L; combine=:harmonic), h, 1, 2, 4.0)    # 2·2·1/(2 + 1) ≈ 1.33
compute(TwoPathEffect(L; combine=:count), h, 1, 2, 4.0)       # 1.0
source
Revel.FourCycleEffect — Type
FourCycleEffect(layer; combine=:min, root=false, transform=identity, name=nothing)
FourCycleEffect(; combine=:min, root=false, …, layer=nothing, memory=…, …)

Four-cycle closure: for a candidate s → r, the three-paths s → a ← b → r — another sender b shares a target a with s and also targets r. It is the closure statistic of two-mode event networks, where triads do not exist (Lerner & Lomi 2020; goldfish four; rem fourCycleStat; eventnet FOUR_CYCLE_STATISTIC; "shared support" in Haunss & Hollway 2023).

At least three non-equivalent versions are in use, selected by combine and root: :min — the sum of the minima of the three weights (Lerner & Lomi 2020); combine=:product, root=true — the cube root of the summed products (rem); :count — the number of three-paths on the binary network (goldfish).

Example

using Revel
# actors 1–2 are senders, 11–12 targets: 1 and 2 both used 11, and 2 used 12
h = build_history([Event(1, 11, 1.0), Event(2, 11, 2.0), Event(2, 12, 3.0)])
compute(FourCycleEffect(), h, 1, 12, 4.0)    # 1.0 — closing 1 → 11 ← 2 → 12
compute(FourCycleEffect(), h, 1, 11, 4.0)    # 0.0
source

Dyadic effects

Revel.Inertia — Function
Inertia(; scaling=:none, empty=0.0, transform=identity, name=nothing,
        layer=nothing, memory=FullMemory(), types=nothing, weighted=false,
        keep=nothing, clock=:time, symmetric=false)

Repetition: the weight of past s → r events (Brandes, Lerner & Snijders 2009 "inertia"; remstats inertia(); rem inertiaStat; goldfish inertia(weighted=TRUE); eventnet "repetition").

scaling=:prop is Butts's (2008) "persistence" — the share of the sender's past sends that went to this receiver (remstats inertia(scaling="prop"), the "embedding inertia" of Kitts et al. 2017, and relevent's documented FrPSndSnd, whose output in relevent 1.2.1 differs from its documentation); pass empty=1/(n-1) for the value those packages give a sender with no history. transform=:indicator gives goldfish's default 0/1 form.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
compute(Inertia(), h, 1, 2, 4.0)                         # 2.0
compute(Inertia(scaling=:prop), h, 1, 2, 4.0)            # 0.666…
compute(Inertia(memory=HalfLife(1.0)), h, 1, 2, 4.0)     # 0.5 + 0.125 = 0.625
compute(Inertia(transform=:indicator), h, 1, 3, 4.0)     # 1.0
source
Revel.Reciprocation — Function
Reciprocation(; scaling=:none, denominator=:sender_in, empty=0.0,
              transform=identity, name=nothing, layer=nothing, memory=…, …)

Reciprocity: the weight of past r → s events on a candidate s → r (Brandes, Lerner & Snijders 2009; remstats reciprocity(); rem reciprocityStat; goldfish recip). Named Reciprocation because REM.jl exports a Reciprocity statistic with a different (eventnet) parameterisation.

scaling=:prop divides by a degree chosen with denominator: :sender_in (the default) is the share of the sender's past receipts that came from this receiver — relevent FrRecSnd, remstats reciprocity(scaling="prop"), the "dependence reciprocation" of Kitts et al. (2017); :receiver_out is their "embedding reciprocation", the share of the receiver's past sends that went to the sender.

Example

using Revel
h = build_history([Event(2, 1, 1.0), Event(3, 1, 2.0), Event(2, 1, 3.0)])
compute(Reciprocation(), h, 1, 2, 4.0)                    # 2.0
compute(Reciprocation(scaling=:prop), h, 1, 2, 4.0)       # 0.666…
compute(Reciprocation(scaling=:prop, denominator=:receiver_out), h, 1, 2, 4.0)   # 1.0
source
Revel.DyadActivity — Function
DyadActivity(; transform=identity, name=nothing, layer=nothing, memory=…, …)

The weight of past events between the two actors in either direction (eventnet DYAD_STATISTIC with direction SYM). For undirected data build the layer with symmetric=true and use Inertia instead.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(2, 1, 2.0)])
compute(DyadActivity(), h, 1, 2, 3.0)    # 2.0
source

Degree effects

Revel.OutdegreeSender — Function
OutdegreeSender(; measure=:events, scaling=:none, empty=0.0,
                transform=identity, name=nothing, layer=nothing, memory=…, …)

Sender activity: events the candidate's sender has sent (remstats outdegreeSender(); relevent NODSnd with scaling=:prop; rem degreeStat sender-outdegree; goldfish outdeg(type="ego")). See DegreeEffect.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 1, 3.0)])
compute(OutdegreeSender(), h, 1, 2, 4.0)    # 2.0
source
Revel.IndegreeSender — Function
IndegreeSender(; measure=:events, scaling=:none, empty=0.0, …)

Events the candidate's sender has received (remstats indegreeSender(); relevent NIDSnd with scaling=:prop; goldfish indeg(type="ego")). See DegreeEffect.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 1, 3.0)])
compute(IndegreeSender(), h, 1, 2, 4.0)    # 1.0
source
Revel.TotaldegreeSender — Function
TotaldegreeSender(; measure=:events, scaling=:none, empty=0.0, …)

Events the candidate's sender has sent or received (remstats totaldegreeSender(); relevent NTDegSnd with scaling=:prop). See DegreeEffect.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 1, 3.0)])
compute(TotaldegreeSender(), h, 1, 2, 4.0)    # 3.0
source
Revel.OutdegreeReceiver — Function
OutdegreeReceiver(; measure=:events, scaling=:none, empty=0.0, …)

Events the candidate's receiver has sent (remstats outdegreeReceiver(); relevent NODRec with scaling=:prop; goldfish outdeg(type="alter")). See DegreeEffect.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 1, 3.0)])
compute(OutdegreeReceiver(), h, 1, 2, 4.0)    # 1.0
source
Revel.IndegreeReceiver — Function
IndegreeReceiver(; measure=:events, scaling=:none, empty=0.0, …)

Receiver popularity: events the candidate's receiver has received (remstats indegreeReceiver(); relevent NIDRec with scaling=:prop; rem degreeStat target-indegree; goldfish indeg(type="alter")). With scaling=:prop on the :total kind this is Butts's (2008) preferential attachment — see TotaldegreeReceiver.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(3, 2, 2.0), Event(2, 1, 3.0)])
compute(IndegreeReceiver(), h, 1, 2, 4.0)    # 2.0
source
Revel.TotaldegreeReceiver — Function
TotaldegreeReceiver(; measure=:events, scaling=:none, empty=0.0, …)

Events the candidate's receiver has sent or received (remstats totaldegreeReceiver()). With scaling=:prop it is the preferential-attachment statistic of Butts (2008) — the receiver's share of all past volume, relevent NTDegRec.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(3, 2, 2.0), Event(2, 1, 3.0)])
compute(TotaldegreeReceiver(), h, 1, 2, 4.0)                  # 3.0
compute(TotaldegreeReceiver(scaling=:prop), h, 1, 2, 4.0)     # 0.5
source
Revel.TotaldegreeDyad — Function
TotaldegreeDyad(; scaling=:none, transform=identity, name=nothing, layer=nothing, …)

The sum of the two actors' total degrees (remstats totaldegreeDyad()), the degree effect available for undirected events.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 3, 3.0)])
compute(TotaldegreeDyad(), h, 1, 2, 4.0)    # 4.0
source
Revel.DegreeMin — Function
DegreeMin(; scaling=:none, transform=identity, name=nothing, layer=nothing, …)

The smaller of the two actors' total degrees (remstats degreeMin(), for undirected events — build it with symmetric=true, under which an actor's degree is the number of events it took part in). sender_kind=/receiver_kind= choose other degrees.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
compute(DegreeMin(), h, 1, 3, 4.0)    # 1.0
source
Revel.DegreeMax — Function
DegreeMax(; scaling=:none, transform=identity, name=nothing, layer=nothing, …)

The larger of the two actors' total degrees (remstats degreeMax(), for undirected events).

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
compute(DegreeMax(), h, 1, 3, 4.0)    # 3.0
source
Revel.DegreeDiff — Function
DegreeDiff(; transform=identity, name=nothing, layer=nothing, …)

The absolute difference of the two actors' total degrees (remstats degreeDiff(); with a negative sign, the degree assortativity of Lerner, Hâncean & Perc 2025).

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(1, 2, 3.0)])
compute(DegreeDiff(), h, 1, 3, 4.0)    # 2.0
source
Revel.DegreeAssortativity — Function
DegreeAssortativity(; sender_kind=:out, receiver_kind=:in, transform=identity,
                    name=nothing, layer=nothing, …)

The product of the sender's and the receiver's degrees — by default sender out-degree × receiver in-degree in events, the activity × popularity term of Lerner & Lomi (2020) (who take log1p of each degree first: build it from DyadDegreeEffect on transformed parts, or use an Interaction of two transformed degrees). measure=:partners gives the "assortativity by degree" of Vu, Lomi, Mascia & Pallotti (2017, eq. 9), the product of the distinct partners. A negative coefficient is read as disassortative (core–periphery) mixing. It is an endogenous × endogenous interaction, and the literature's hierarchy principle asks for both main effects alongside it.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 3, 3.0)])
compute(DegreeAssortativity(), h, 1, 3, 4.0)    # 2 × 2 = 4.0
h2 = build_history([Event(1, 2, 1.0), Event(1, 2, 2.0), Event(2, 3, 3.0)])
compute(DegreeAssortativity(measure=:partners), h2, 1, 3, 4.0)   # 1 × 1 = 1.0
source

Triadic effects

Revel.OTP — Function
OTP(; combine=:min, root=false, ordered=false, third=nothing,
    transform=identity, name=nothing, layer=nothing, memory=…, …)

Outgoing two-paths s → k → r, the transitive-closure statistic: for each third actor the combined weight of s → k and k → r (Butts 2008; relevent OTPSnd; remstats otp(); goldfish trans; eventnet "transitive_tie"; Perry & Wolfe's "2-send"). combine=:count gives goldfish's count of distinct intermediaries and remstats' unique=TRUE; combine=:product, root=true gives rem's triadStat. ordered=true requires s → k to have happened before k → r. See TwoPathEffect.

Example

using Revel
h = build_history([Event(1, 3, 1.0), Event(3, 2, 2.0), Event(1, 4, 3.0), Event(4, 2, 4.0)])
compute(OTP(), h, 1, 2, 5.0)                  # 2.0 — through 3 and through 4
compute(OTP(), h, 2, 1, 5.0)                  # 0.0
compute(OTP(ordered=true), h, 1, 2, 5.0)      # 2.0 — both first legs came first
source
Revel.ITP — Function
ITP(; combine=:min, root=false, ordered=false, third=nothing,
    transform=identity, name=nothing, layer=nothing, memory=…, …)

Incoming two-paths r → k → s, the cyclic-closure statistic (Butts 2008; relevent ITPSnd; remstats itp(); goldfish cycle; Perry & Wolfe's "2-receive"). ordered=true requires r → k to have happened before k → s. See TwoPathEffect.

Example

using Revel
h = build_history([Event(2, 3, 1.0), Event(3, 1, 2.0)])
compute(ITP(), h, 1, 2, 3.0)    # 1.0 — closing the cycle 2 → 3 → 1 → 2
compute(ITP(), h, 2, 1, 3.0)    # 0.0
source
Revel.OSP — Function
OSP(; combine=:min, root=false, order=:none, third=nothing,
    transform=identity, name=nothing, layer=nothing, memory=…, …)

Outbound shared partners s → k ← r: third actors both have sent to (Butts 2008; relevent OSPSnd, whose output in relevent 1.2.1 differs from this definition — see the concordance; remstats osp(); goldfish commonReceiver; Perry & Wolfe's "cosibling"). amorem's "sending balance" is the same configuration, but whether it combines the legs by the minimum has not been checked. Mind the vocabulary: the partner is shared as a receiver — "common receiver" — while the sender and the receiver of the candidate both send; a package that names the effect after the candidate's side calls it the opposite of one that names it after the partner. See TwoPathEffect.

Example

using Revel
h = build_history([Event(1, 3, 1.0), Event(2, 3, 2.0)])
compute(OSP(), h, 1, 2, 3.0)    # 1.0 — both sent to 3
compute(ISP(), h, 1, 2, 3.0)    # 0.0
source
Revel.ISP — Function
ISP(; combine=:min, root=false, order=:none, third=nothing,
    transform=identity, name=nothing, layer=nothing, memory=…, …)

Inbound shared partners s ← k → r: third actors who have sent to both (Butts 2008; relevent ISPSnd; remstats isp(); goldfish commonSender; amorem "receiving balance"; Perry & Wolfe's "sibling"). See TwoPathEffect.

Example

using Revel
h = build_history([Event(3, 1, 1.0), Event(3, 2, 2.0)])
compute(ISP(), h, 1, 2, 3.0)    # 1.0 — 3 sent to both
compute(OSP(), h, 1, 2, 3.0)    # 0.0
source
Revel.SharedPartners — Function
SharedPartners(; combine=:min, transform=identity, name=nothing,
               layer=nothing, memory=…, symmetric=true, …)

Shared partners for undirected events: third actors that have interacted with both (remstats sp(); goldfish trans in the coordination model; eventnet closure with direction SYM). The layer is symmetric by default, so each event counts for both of its participants.

Example

using Revel
h = build_history([Event(1, 3, 1.0), Event(3, 2, 2.0)])
compute(SharedPartners(), h, 1, 2, 3.0)    # 1.0 — 3 has interacted with both
compute(SharedPartners(), h, 2, 1, 3.0)    # 1.0 — and the statistic is symmetric
source
Revel.BalanceEffect — Function
BalanceEffect(kind; positive=:positive, negative=:negative, root=true,
              transform=identity, name=nothing, memory=…, weighted=false,
              clock=:time)

The structural-balance statistics of Brandes, Lerner & Snijders (2009) for signed events: the two-path through a third actor k whose first leg (s–k) and second leg (k–r) are read off the undirected positive or negative event weights, the legs multiplied, the paths summed and the square root taken.

kind names what the receiver r is to the sender s, through k, with the signs of the (s–k, k–r) legs as in Brandes et al.'s definitions: :friend_of_friend (+,+), :friend_of_enemy (−,+: k is s's enemy and r's friend — friendOfEnemy(a, b) = √Σᵢ ω⁻(a,i)·ω⁺(i,b)), :enemy_of_friend (+,−: k is s's friend and r's enemy) or :enemy_of_enemy (−,−). positive/negative name the event types carrying each sign. Balance theory predicts positive events towards friends of friends and enemies of enemies, and negative events towards the other two. The same construction is rem's triadStat(eventtypevalues=…) and eventnet's "enemy of friend" closure.

Example

using Revel
h = build_history([Event(1, 3, 1.0; eventtype=:positive),
                   Event(3, 2, 2.0; eventtype=:negative)])
# 3 is 1's friend and 2's enemy: 2 is an enemy of 1's friend
compute(BalanceEffect(:enemy_of_friend), h, 1, 2, 3.0)     # 1.0
compute(BalanceEffect(:friend_of_enemy), h, 1, 2, 3.0)     # 0.0
compute(BalanceEffect(:friend_of_enemy), h, 2, 1, 3.0)     # 1.0 — 1 is a friend of 2's enemy
source
Revel.matching_third — Function
matching_third(x) -> Function

A third= weight for TwoPathEffect (and OTP, ITP, OSP, ISP) that keeps only third actors whose covariate value equals the sender's: closure among same-attribute actors. The review found this interaction only as a filtered statistic in the literature, never as a product term, and the two are different models — this is the filter.

x is a vector indexed by actor ID.

Example

using Revel
team = [1, 1, 2, 1]
h = build_history([Event(1, 2, 1.0), Event(2, 4, 2.0), Event(1, 3, 3.0), Event(3, 4, 4.0)])
compute(OTP(), h, 1, 4, 5.0)                               # 2.0 — via 2 and via 3
compute(OTP(third=matching_third(team)), h, 1, 4, 5.0)     # 1.0 — only 2 is on 1's team
source

Order and recency

Revel.RecencyRank — Type
RecencyRank(mode=:receive; name=nothing, layer=nothing, types=…, keep=…)

Butts's (2008) rank-based recency. mode=:receive is the inverse of the rank of the candidate's receiver among the actors who most recently sent to the sender (1 for the latest, 1/2 for the one before, 0 if never) — relevent RRecSnd, remstats rrankReceive(). mode=:send ranks the receiver among the actors the sender most recently sent to — relevent RSndSnd, remstats rrankSend(), first printed by DuBois, Butts, McFarland & Smyth (2013).

Ranks depend on event order only, so the statistic takes no memory kernel (a memory= keyword, or a shared layer= with one, is refused); types/keep select which events are ranked.

Example

using Revel
h = build_history([Event(2, 1, 1.0), Event(3, 1, 2.0), Event(1, 4, 3.0)])
compute(RecencyRank(:receive), h, 1, 3, 4.0)    # 1.0 — 3 wrote to 1 most recently
compute(RecencyRank(:receive), h, 1, 2, 4.0)    # 0.5
compute(RecencyRank(:send), h, 1, 4, 4.0)       # 1.0
source
Revel.TimeSince — Type
TimeSince(target=:dyad; transform=inverse_gap, empty=0.0, name=nothing,
          layer=nothing, types=…, keep=…, clock=:time)

A function of the time elapsed since the most recent event of a given kind:

targetthe clock started atremstats
:dyadthe last s → r eventrecencyContinue()
:reversethe last r → s event—
:pairthe last event between the two, either wayrecencyContinue() (undirected)
:send_senderthe sender last sentrecencySendSender()
:send_receiverthe receiver last sentrecencySendReceiver()
:receive_senderthe sender last receivedrecencyReceiveSender()
:receive_receiverthe receiver last receivedrecencyReceiveReceiver()

"Recency" names at least four different statistics in the literature, and transform selects among them: inverse_gap 1/(Δ+1) (remstats, the default), Δ -> exp(-b*Δ) (an exponentially fading recency), Δ -> 1 - exp(-Δ) (Boschi & Wit 2026, who code "never happened" as 1 — pass empty=1.0 with it, since the default empty=0.0 would equal "just happened") or identity for the raw gap time (Zappa & Vu 2021). empty is returned when no such event has happened. With clock=:order the gap is measured in events. The statistic reads the time of the last event, not a weight, so it takes no memory kernel.

On the time clock the statistic changes continuously between events, so it is not admissible in the exact-time likelihood; with clock=:order it is.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(3, 1, 4.0)])
compute(TimeSince(:dyad), h, 1, 2, 5.0)                       # 1/(4 + 1) = 0.2
compute(TimeSince(:receive_sender), h, 1, 2, 5.0)             # 1/(1 + 1) = 0.5
compute(TimeSince(:dyad; transform=identity, empty=-1.0), h, 2, 3, 5.0)   # -1.0
source
Revel.inverse_gap — Function
inverse_gap(Δ) -> Float64

1 / (Δ + 1): remstats' transform of the time Δ since an event, the default of TimeSince.

Example

using Revel
inverse_gap(0.0), inverse_gap(3.0)    # (1.0, 0.25)
source
Revel.PShift — Type
PShift(shift::Symbol; name="PS…") <: AbstractStatistic
PShift(shift::AbstractString; name="PS…") <: AbstractStatistic

Participation-shift indicator (Gibson 2003), matching R relevent's PSAB-BA-family effects: with previous event A→B, the statistic is 1 for a candidate event that realizes the shift, 0 otherwise (and 0 for the first event, which has no previous event).

shift is one of pshift_types (e.g. :AB_BA) or the R name (e.g. "PSAB-BA"). In shift names, A/B are the previous event's sender/receiver, X/Y are any other actors, and 0 is the null actor: an event "to the group" is encoded with receiver == 0, so shifts involving 0 (e.g. :AB_B0, :A0_X0) can only be nonzero when such group-directed events occur in the data — with strictly dyadic events they are structurally zero, exactly as in relevent::rem.dyad.

A participation shift is constant between events, so it is admissible in the interval-timing model. For the shift in which the same dyad repeats, see PShiftABAB; for undirected events, UndirectedPShift.

Example

using Revel
h = build_history([Event(1, 2, 1.0)])
compute(PShift(:AB_BA), h, 2, 1, 2.0)      # 1.0 — turn receiving: B answers A
compute(PShift("PSAB-XY"), h, 3, 4, 2.0)   # 1.0 — an outsider addresses another
compute(PShift(:AB_BA), h, 3, 1, 2.0)      # 0.0
name(PShift(:AB_BA))                       # "PSAB-BA"
source
Revel.pshift_types — Function
pshift_types() -> NTuple{13, Symbol}

The 13 Gibson (2003) participation-shift types accepted by PShift, in relevent's grouping (turn receiving, claiming, usurping, continuing).

Example

using Revel
length(pshift_types())      # 13
first(pshift_types())       # :AB_BA
source
Revel.PShiftABAB — Type
PShiftABAB(; name="PSAB-AB") <: AbstractRevelStatistic

The participation shift in which the same dyad repeats immediately: previous event A → B, candidate A → B (remstats psABAB()). It has no counterpart among Gibson's thirteen shifts, which PShift implements.

Example

using Revel
h = build_history([Event(1, 2, 1.0)])
compute(PShiftABAB(), h, 1, 2, 2.0)       # 1.0
compute(PShiftABAB(), h, 2, 1, 2.0)       # 0.0 — that is PShift(:AB_BA)
compute(PShift(:AB_BA), h, 2, 1, 2.0)     # 1.0
source
Revel.UndirectedPShift — Type
UndirectedPShift(kind; name=nothing) <: AbstractRevelStatistic

Participation shifts for undirected events, where a pair has no sender and no receiver (remstats' two shifts for undirected data):

  • :AB_AB — the previous event's pair interacts again (psABAB());
  • :AB_AY — exactly one actor of the previous pair takes part, with someone new (psABAY()).

The orientation in which a pair happens to be stored does not matter. For directed events use PShift and PShiftABAB.

Example

using Revel
h = build_history([Event(1, 2, 1.0)])
compute(UndirectedPShift(:AB_AB), h, 2, 1, 2.0)    # 1.0 — the same pair
compute(UndirectedPShift(:AB_AY), h, 2, 3, 2.0)    # 1.0 — 2 carries on with 3
compute(UndirectedPShift(:AB_AY), h, 3, 4, 2.0)    # 0.0 — nobody from the last event
source

Neighbourhood statistics

Revel.NodeTransitivity — Type
NodeTransitivity(; role=:receiver, transform=identity, name=nothing,
                 layer=nothing, memory=…, …)

Node-level embeddedness: the number of transitive structures v → a, v → b, a → b in which actor v — the candidate's receiver (role=:receiver) or sender (:sender) — is the source (goldfish nodeTrans, with type="alter" or "ego"). Computed on the binary network of the layer.

Example

using Revel
h = build_history([Event(1, 2, 1.0), Event(1, 3, 2.0), Event(2, 3, 3.0)])
compute(NodeTransitivity(role=:sender), h, 1, 4, 4.0)    # 1.0 — 1 → 2, 1 → 3, 2 → 3
compute(NodeTransitivity(), h, 1, 4, 4.0)                # 0.0 — about actor 4
source
Revel.StructuralSimilarity — Type
StructuralSimilarity(; measure=:jaccard, direction=:out, transform=identity,
                     name=nothing, layer=nothing, memory=…, …)

How alike the candidate's sender and receiver are in whom they have sent to (direction=:out) or received from (:in): the Jaccard index of their partner sets (measure=:jaccard) or the cosine of their weight profiles (:cosine). These are eventnet's JACCARD_SIM_STATISTIC and COSINE_SIM_STATISTIC, a structural-equivalence effect. The two actors themselves are left out of the profiles.

This is not the similarityStat of the rem package, which compares a sender with the other senders of the current target; for that construction use FourCycleEffect, which counts the same co-usage paths.

Example

using Revel
h = build_history([Event(1, 3, 1.0), Event(1, 4, 2.0), Event(2, 3, 3.0)])
compute(StructuralSimilarity(), h, 1, 2, 4.0)                   # 0.5 — {3,4} vs {3}
compute(StructuralSimilarity(measure=:cosine), h, 1, 2, 4.0)    # 1/√2
source