Hyperevents API Reference
Hyperevents and their history
Revel.HyperEvent — Type
HyperEvent(participants, time; eventtype=:event, weight=1.0)
HyperEvent(senders, receivers, time; eventtype=:event, weight=1.0)A relational hyperevent: an interaction among a set of actors at time.
The two-argument form is undirected — a meeting, a coauthored paper, a co-offence: all participants are stored in senders and receivers is empty. The three-argument form is directed — typically one sender and a set of receivers (an e-mail, the multicast events of Perry & Wolfe 2013 and Lerner & Lomi 2023), though several senders are allowed (Lerner et al. 2019).
Actor sets are stored sorted; an actor listed twice, a non-positive ID, a directed event without senders, or an actor that is both sender and receiver (the models are defined for loopless hypergraphs) is an ArgumentError. weight carries an event weight or an outcome (team performance, citations) that weighted=true statistics read; eventtype is what the types= filter of a statistic matches.
Example
using Revel
meeting = HyperEvent([3, 1, 2], 1.0)
meeting.senders, meeting.receivers # ([1, 2, 3], Int64[])
mail = HyperEvent([1], [4, 2], 2.0; eventtype=:email)
is_directed(mail), participants(mail) # (true, [1, 2, 4])Revel.HyperHistory — Type
HyperHistory{T}()The past of a hyperevent sequence: the absorbed HyperEvents in time order, plus the indices the statistics read. It is what compute(stat, history, senders, receivers, time) evaluates a hyperevent statistic against; build_hyper_history makes one from a vector of events and update_hyper_history! appends to it.
For each sub-hyperedge an index lists the past events that contain it, so a statistic reads Σ kernel_weight(memory, t − tₑ)·wₑ under any memory kernel and any event-type filter. A subset order is indexed the first time a statistic asks for it and kept up to date from then on; indexing order p costs binomial(size, p) entries per event, which is the cost of high-order subset repetition on large hyperedges.
A history holds either undirected or directed hyperevents, not both. It carries scratch buffers: do not evaluate statistics on one history from several tasks.
Example
using Revel
h = HyperHistory{Float64}()
update_hyper_history!(h, HyperEvent([1, 2, 3], 1.0))
length(h) # 1
compute(SubsetRepetition(2), h, [1, 2], Int[], 2.0) # 1.0Revel.update_hyper_history! — Function
update_hyper_history!(history::HyperHistory, event::HyperEvent) -> historyAppend event to the history and bring every index already built up to date. Events must arrive in time order (an earlier time than the last absorbed event is an ArgumentError), and a history cannot mix directed and undirected hyperevents.
Example
using Revel
h = HyperHistory{Float64}()
update_hyper_history!(h, HyperEvent([1, 2], 1.0))
update_hyper_history!(h, HyperEvent([1, 2, 3], 2.0))
compute(ExactRepetition(), h, [1, 2], Int[], 3.0) # 1.0
compute(SubsetRepetition(2), h, [1, 2], Int[], 3.0) # 2.0Revel.build_hyper_history — Function
build_hyper_history(events) -> HyperHistoryA HyperHistory holding events, absorbed in time order (the vector is sorted by time first; events at equal times keep their order). It is the history against which compute(stat, history, senders, receivers, time) evaluates a hyperevent statistic by hand.
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2, 3], 1.0), HyperEvent([1, 2], 2.0)])
compute(SubsetRepetition(1), h, [1, 4], Int[], 3.0) # (2 + 0)/2 = 1.0Graphs.is_directed — Method
is_directed(event::HyperEvent) -> BoolWhether a HyperEvent distinguishes senders from receivers. (A method of the generic the ecosystem shares through NetworkCore.jl.)
Example
using Revel
is_directed(HyperEvent([1, 2, 3], 1.0)) # false — a meeting
is_directed(HyperEvent([1], [2, 3], 1.0)) # true — one sender, two receiversRevel.participants — Function
participants(event::HyperEvent) -> Vector{Int}Every actor taking part in a HyperEvent, sorted: the senders and the receivers of a directed hyperevent, the participant set of an undirected one.
Example
using Revel
participants(HyperEvent([4], [2, 1], 1.0)) # [1, 2, 4]
participants(HyperEvent([3, 1], 1.0)) # [1, 3]Statistics
Revel.AbstractHyperStatistic — Type
AbstractHyperStatistic <: REM.AbstractStatisticSupertype of the hyperevent statistics. A subtype adds a method to the shared compute generic with the hyperedge signature
compute(stat, history::HyperHistory, senders, receivers, time)where senders and receivers are the sorted actor sets of the candidate hyperedge (receivers is empty for an undirected candidate) and the statistic is read off the events in history that are not later than time. compute(stat, history, candidate::HyperEvent) is the same call with the candidate's sets and time. name(stat) is the column and coefficient name.
Interaction and Transformed accept hyperevent statistics, so a product term or a rescaling is built exactly as for dyadic statistics.
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0)])
stat = ReceiverSetRepetition(2)
stat isa AbstractHyperStatistic # true
compute(stat, h, [4], [2, 3], 2.0) # 1.0
compute(stat, h, HyperEvent([4], [2, 3], 2.0)) # 1.0 — the same call
name(Interaction(HyperedgeSize(), stat)) # "size:rec.subrep(2)"Revel.HyperedgeSize — Type
HyperedgeSize(; endpoint=:all, transform=identity, name=nothing)The number of actors in the candidate hyperedge (Lerner, Tranmer, Mowbray & Hâncean 2019, who call it "one of the few hyperedge statistics that have no related statistic in dyadic REM"; eventnet UHE_SIZE_STAT/DHE_SIZE_STAT). endpoint=:senders counts the senders, :receivers the receivers, :all both.
It cannot be estimated on its own here. hyper_design and fit_rhem compare each observed hyperevent with alternatives of the same size (the size-stratified risk set of Lerner & Lomi 2023), so a size-only statistic is constant within every stratum and its coefficient is not identified — the fit would report a singular information matrix. Use it as a moderator, in an Interaction with a statistic that does vary within the stratum (does familiarity matter less in large meetings?).
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2, 3], 1.0)])
compute(HyperedgeSize(), h, [1, 2, 3], Int[], 2.0) # 3.0
compute(HyperedgeSize(endpoint=:receivers), h, [1], [2, 3, 4], 2.0) # 3.0
by_size = Interaction(HyperedgeSize(), SubsetRepetition(2))
compute(by_size, h, [1, 2, 3], Int[], 2.0) # 3 × 1 = 3.0Revel.HyperCovariate — Type
HyperCovariate(x; endpoint=:all, aggregate=:mean, transform=identity,
name=nothing)A summary of an actor covariate over the candidate hyperedge (eventnet UHE_NODE_STAT/DHE_NODE_STAT and its aggregation functions). x is a Covariate (static or time-varying) or a vector indexed by actor ID.
endpoint— whose values are summarised::allparticipants, the:sendersor the:receivers(an undirected hyperedge has:allonly).aggregate—:mean,:sum,:min,:max,:sd(population standard deviation; eventnetSDEV),:samplesd(SAMPLESDEV),:absdiff(the mean absolute difference over pairs),:catdiff(the share of pairs with different values, for a categorical covariate — the only aggregate a categorical covariate accepts) or:homogeneity(for a 0/1 covariate: the covariate homogeneity of Lerner et al. 2021 — the larger group minus the smaller, over the size, rescaled for an odd size so that the most even split scores 0 and a single group 1).
Pairs for :absdiff and :catdiff are the unordered pairs within the chosen endpoint — except with endpoint=:all on a directed hyperedge, where, as in eventnet, they are the (sender, receiver) pairs: that is how sender–receiver homophily is tested. A set with fewer than two actors has no pair and scores 0.
The covariate effects of the papers are special cases:
| effect | arguments |
|---|---|
| covariate average (Lerner et al. 2021) | aggregate=:mean |
| covariate homogeneity of a binary covariate (Lerner et al. 2021) | aggregate=:homogeneity |
| covariate dispersion within the hyperedge | aggregate=:absdiff, :sd or :samplesd |
| receiver-set average (Lerner & Lomi 2023) | endpoint=:receivers, aggregate=:mean |
sender–receiver heterophily (2023), mean abs(zᵢ − zⱼ) | endpoint=:all, aggregate=:absdiff on directed hyperedges |
receiver-set heterophily (2023), mean pairwise difference within J | endpoint=:receivers, aggregate=:absdiff |
A summary over the senders alone is constant within a choice set that holds the senders fixed (sampler=:receivers), and any summary that depends only on the size of the hyperedge is never identified.
Example
using Revel
age = [30.0, 40.0, 50.0, 20.0]
h = HyperHistory{Float64}()
compute(HyperCovariate(age), h, [1, 2, 3], Int[], 0.0) # 40.0
compute(HyperCovariate(age; aggregate=:absdiff), h, [1, 2, 3], Int[], 0.0) # (10 + 20 + 10)/3
# directed: sender 1, receivers {2, 4}
compute(HyperCovariate(age; endpoint=:receivers), h, [1], [2, 4], 0.0) # 30.0
compute(HyperCovariate(age; aggregate=:absdiff), h, [1], [2, 4], 0.0) # (10 + 10)/2
dept = Covariate([:a, :a, :b, :b]; name="dept")
compute(HyperCovariate(dept; aggregate=:catdiff), h, [1, 2, 3], Int[], 0.0) # 2/3
female = [1.0, 0.0, 1.0, 1.0]
compute(HyperCovariate(female; aggregate=:homogeneity), h, [1, 2, 3, 4], Int[], 0.0) # (3 − 1)/4 = 0.5
compute(HyperCovariate(female; aggregate=:homogeneity), h, [1, 3, 4], Int[], 0.0) # 1.0 — one groupUndirected hyperevents
Revel.SubsetRepetition — Type
SubsetRepetition(order; aggregate=:mean, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Subset repetition of order p = order for undirected hyperevents: the hyperedge degree
deg(h′; t) = Σ_{e: tₑ ≤ t} w(t − tₑ) · χ(h′ ⊆ hₑ)— the (memory-weighted) number of past events whose participants include all of h′ — aggregated over every p-subset h′ of the candidate's participants. Order 1 is individual activity (preferential attachment), order 2 dyadic familiarity, order 3 triadic familiarity; orders of three and above express dependence no dyadic model can (Lerner et al. 2019).
The papers differ in the aggregation, which changes the number, so it is a keyword:
:mean(default) —(1/C(|h|, p)) Σ deg(h′): "sub-repetition of order p" in Lerner, Tranmer, Mowbray & Hâncean (2019), "subset repetition" in Lerner, Lomi, Mowbray, Rollings & Tranmer (2021) and Lerner & Hâncean (2023); eventnetUHE_SUB_REPETITION_STATwithAVERAGE.:sum— the unnormalisedsubrep⁽ᵏ⁾of Lerner, Hâncean & Perc (2025), preferential attachment of order k.:min,:max,:sd(population standard deviation) — the other aggregators the 2019 paper allows;:samplesd— the sample standard deviation, which withp = 1andweighted=trueis the prior success disparity of Lerner & Hâncean (2023, p. 17);:absdiff— the mean absolute difference over pairs of subsets (eventnetABSDIFF).:assortativity—−Σ |deg(h′) − deg(h″)|over unordered pairs ofp-subsets: the degree assortativity of order k of Lerner, Hâncean & Perc (2025), zero unless the candidate has more thanpparticipants.
A candidate with fewer than p participants has no p-subset and scores 0. memory is any Revel memory kernel (the papers use HalfLife); weighted=true adds each past event's weight instead of counting it; types restricts the past to some event types. On directed hyperevents the statistic reads the participant sets (senders and receivers together) — see DirectedSubsetRepetition for the directed families.
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2, 3], 1.0), HyperEvent([1, 2], 2.0),
HyperEvent([2, 3, 4], 3.0)])
# pairs of {1,2,3}: deg{1,2} = 2, deg{1,3} = 1, deg{2,3} = 2
compute(SubsetRepetition(2), h, [1, 2, 3], Int[], 4.0) # 5/3
compute(SubsetRepetition(2; aggregate=:sum), h, [1, 2, 3], Int[], 4.0) # 5.0
compute(SubsetRepetition(1), h, [1, 2, 3], Int[], 4.0) # (2 + 3 + 2)/3
compute(SubsetRepetition(2; memory=Window(1.5)), h, [1, 2, 3], Int[], 4.0) # 1/3Revel.ExactRepetition — Type
ExactRepetition(; direction=:out, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Exact repetition: the hyperedge activity
activity(h; t) = Σ_{e: tₑ ≤ t} w(t − tₑ) · χ(hₑ = h)— the (memory-weighted) number of past events on exactly the candidate hyperedge, with no one missing and no one added ("repetition" in Lerner, Tranmer, Mowbray & Hâncean 2019; eventnet UHE_REPETITION_STAT and DHE_REPETITION_STAT). For a directed candidate both the sender set and the receiver set must match — the "mailing list" effect of Lerner & Lomi (2023), Σ w·1(iₘ = i ∧ Jₘ = J).
direction matters for directed hyperevents only (eventnet's direction argument):
:out— exact repetition;:in— exact reciprocation, past events on the reversed hyperedge, the former receivers sending to the former senders (the "reciprocation" of Lerner et al. 2019);:sym— past events on the same participant set in any role, which isUnorderedRepetition.
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2, 3], 1.0), HyperEvent([1, 2], 2.0),
HyperEvent([1, 2], 3.0)])
compute(ExactRepetition(), h, [1, 2], Int[], 4.0) # 2.0 — not the {1,2,3} meeting
compute(ExactRepetition(), h, [1, 3], Int[], 4.0) # 0.0
mails = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([2, 3], [1], 2.0)])
compute(ExactRepetition(), mails, [1], [2, 3], 3.0) # 1.0
compute(ExactRepetition(direction=:in), mails, [1], [2, 3], 3.0) # 1.0Revel.SharedPriorEvents — Type
SharedPriorEvents(order; memory=FullMemory(), weighted=false, types=nothing,
transform=identity, name=nothing)Shared prior events of order p (Lerner, Tranmer, Mowbray & Hâncean 2019):
Σ_{e: tₑ ≤ t} w(t − tₑ) · χ(|hₑ ∩ h| ≥ p)— the past events that share at least p participants with the candidate. It is the alternative to SubsetRepetition that counts each past event once, where the sum of degrees over p-subsets counts it C(|hₑ ∩ h|, p) times. Participant sets are read without roles on directed hyperevents.
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2, 3], 1.0), HyperEvent([1, 2], 2.0),
HyperEvent([3, 4], 3.0)])
compute(SharedPriorEvents(2), h, [1, 2, 3], Int[], 4.0) # 2.0 — the first two events
compute(SubsetRepetition(2; aggregate=:sum), h, [1, 2, 3], Int[], 4.0) # 4.0 = 3 + 1Revel.PriorSuccess — Type
PriorSuccess(order; memory=FullMemory(), types=nothing, transform=identity,
name=nothing)Prior success of order p (Lerner & Hâncean 2023): with the event weight holding the outcome yₑ of a past hyperevent (the impact of a paper, the performance of a team),
Σ_{h′} performance(h′) / Σ_{h′} deg(h′), performance(h′) = Σ_e w(t − tₑ)·yₑ·χ(h′ ⊆ hₑ)over the p-subsets h′ of the candidate's participants: the average outcome of the past events its members (p = 1), pairs (p = 2) or triads (p = 3) took part in — "prior shared success" for p ≥ 2. It is 0 when no p-subset has a past event.
This is a ratio of an outcome-weighted to an unweighted subset repetition; the outcome-weighted hyperedge degree alone is SubsetRepetition(p; weighted=true, aggregate=:sum).
The paper's prior success disparity — the sample standard deviation of the members' summed past performance (Lerner & Hâncean 2023, p. 17) — is SubsetRepetition(1; weighted=true, aggregate=:samplesd).
Example
using Revel
h = build_hyper_history([HyperEvent([1, 2], 1.0; weight=10.0),
HyperEvent([2, 3], 2.0; weight=4.0)])
# actors 1, 2, 3: outcomes 10, 10 + 4, 4 over 1, 2, 1 past events
compute(PriorSuccess(1), h, [1, 2, 3], Int[], 3.0) # 28/4 = 7.0
compute(PriorSuccess(2), h, [1, 2, 3], Int[], 3.0) # (10 + 0 + 4)/2 = 7.0
compute(PriorSuccess(2), h, [1, 3], Int[], 3.0) # 0.0 — never togetherDirected hyperevents
Revel.DirectedSubsetRepetition — Type
DirectedSubsetRepetition(p, q; direction=:out, aggregate=:mean,
memory=FullMemory(), weighted=false, types=nothing,
transform=identity, name=nothing)Subset repetition of order (p, q) for directed hyperevents (Lerner, Tranmer, Mowbray & Hâncean 2019; eventnet DHE_SUB_REPETITION_STAT): the directed hyperedge degree
deg(a′, b′; t) = Σ_{e: tₑ ≤ t} w(t − tₑ) · χ(a′ ⊆ Iₑ ∧ b′ ⊆ Jₑ)— the past events that had all of a′ among their senders Iₑ and all of b′ among their receivers Jₑ — aggregated over the sub-hyperedges (a′, b′) of the candidate (a, b) that direction selects:
:out— subset repetition:a′ ⊆ awith|a′| = pandb′ ⊆ bwith|b′| = q.(p, 0): the samepactors co-initiate again, toward anyone;(0, q): the sameqactors co-receive again, from anyone.:in— subset reciprocation: sub-hyperedges of the reversed hyperedge,pof the candidate's receivers as past senders andqof its senders as past receivers.:sym— undirected subset repetition: roles are ignored, and the statistic isSubsetRepetitionof orderp + qon the participant sets. (eventnet documentsSYMas "undirected subset repetition" without saying how a(p, q)order maps onto it; this is the reading implemented.)
aggregate is as in SubsetRepetition: :mean (default, the 2019 and 2023 papers), :sum, :min, :max, :sd, :absdiff, :assortativity. A candidate with fewer than p senders or q receivers (as the direction requires) scores 0.
The named effects of the papers (Lerner, Tranmer, Mowbray & Hâncean 2019; Lerner & Lomi 2023) are thin constructors:
| constructor | order, direction |
|---|---|
HyperSenderActivity | (1, 0), :out |
HyperReceiverPopularity | (0, 1), :out |
ReceiverSetRepetition(p) | (0, p), :out |
SenderReceiverSetRepetition(p) | (1, p), :out |
HyperReciprocation | (1, 1), :in |
OutInPopularity | (1, 0), :in |
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([1], [2, 4], 2.0),
HyperEvent([2], [1], 3.0)])
# (1,1) sub-hyperedges of 1 → {2,3}: deg(1→2) = 2, deg(1→3) = 1
compute(DirectedSubsetRepetition(1, 1), h, [1], [2, 3], 4.0) # 1.5
# reversed: deg(2→1) = 1, deg(3→1) = 0
compute(DirectedSubsetRepetition(1, 1; direction=:in), h, [1], [2, 3], 4.0) # 0.5
compute(DirectedSubsetRepetition(0, 2), h, [5], [2, 3], 4.0) # 1.0Revel.UnorderedRepetition — Function
UnorderedRepetition(; memory=FullMemory(), weighted=false, types=nothing,
transform=identity, name=nothing)Unordered repetition (Lerner & Lomi 2023): Σ w·1({iₘ} ∪ Jₘ = {i} ∪ J), the past events among exactly the candidate's participants whoever sent them — interaction within a stable group with turn-taking among senders, the "reply to all" pattern. It is ExactRepetition(direction=:sym) (eventnet DHE_REPETITION_STAT with direction SYM).
The 2019 preprint operationalises "reply to all" differently, as switch reciprocation of order 1; that statistic is not implemented.
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([2], [1, 3], 2.0)])
compute(UnorderedRepetition(), h, [3], [1, 2], 3.0) # 2.0 — both were among {1,2,3}
compute(ExactRepetition(), h, [3], [1, 2], 3.0) # 0.0 — 3 has not sent beforeRevel.ReceiverSetRepetition — Function
ReceiverSetRepetition(order; aggregate=:mean, memory=FullMemory(),
weighted=false, types=nothing, transform=identity,
name=nothing)Partial receiver-set repetition of order p (Lerner & Lomi 2023, rec_sub_rep⁽ᵖ⁾): the average, over the p-subsets J′ of the candidate's receivers, of the hyperedge in-degree Σ w·1(J′ ⊆ Jₘ) — how often those p actors were addressed together, by anyone. Order 1 is the average in-degree of the receivers (popularity); orders of two and above are not sums of dyadic covariates. It is DirectedSubsetRepetition(0, p).
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([4], [2, 3, 5], 2.0)])
compute(ReceiverSetRepetition(2), h, [6], [2, 3], 3.0) # 2.0 — {2,3} co-received twice
compute(ReceiverSetRepetition(1), h, [6], [2, 5], 3.0) # (2 + 1)/2 = 1.5Revel.SenderReceiverSetRepetition — Function
SenderReceiverSetRepetition(order; aggregate=:mean, memory=FullMemory(),
weighted=false, types=nothing, transform=identity,
name=nothing)Sender-specific partial receiver-set repetition of order p (Lerner & Lomi 2023, send_rec_sub_rep⁽ᵖ⁾): the average, over the p-subsets J′ of the candidate's receivers, of Σ w·1(i = iₘ ∧ J′ ⊆ Jₘ) — how often this sender addressed those p actors together. Order 1 is the hyperevent form of inertia; orders of two and above capture sender-specific clusterings of receivers. It is DirectedSubsetRepetition(1, p), which also averages over the senders when a candidate has several.
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([4], [2, 3], 2.0)])
compute(SenderReceiverSetRepetition(2), h, [1], [2, 3], 3.0) # 1.0 — once by sender 1
compute(ReceiverSetRepetition(2), h, [1], [2, 3], 3.0) # 2.0 — twice by anyoneRevel.HyperSenderActivity — Function
HyperSenderActivity(; aggregate=:mean, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Sender activity: the average over the candidate's senders of the number of past hyperevents each has sent — subset repetition of order (1, 0) (Lerner, Tranmer, Mowbray & Hâncean 2019). It is constant within a choice set that holds the sender fixed (sampler=:receivers in hyper_design), where the sender-stratified baseline of Lerner & Lomi (2023) absorbs it.
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([1], [4], 2.0)])
compute(HyperSenderActivity(), h, [1], [5, 6], 3.0) # 2.0
compute(HyperSenderActivity(), h, [2], [5, 6], 3.0) # 0.0Revel.HyperReceiverPopularity — Function
HyperReceiverPopularity(; aggregate=:mean, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Receiver popularity: the average over the candidate's receivers of the number of past hyperevents each has received — subset repetition of order (0, 1), and partial receiver-set repetition of order 1 in Lerner & Lomi (2023). Identical to ReceiverSetRepetition(1) apart from its name.
Example
using Revel
h = build_hyper_history([HyperEvent([1], [2, 3], 1.0), HyperEvent([4], [2], 2.0)])
compute(HyperReceiverPopularity(), h, [5], [2, 3], 3.0) # (2 + 1)/2 = 1.5Revel.HyperReciprocation — Function
HyperReciprocation(; aggregate=:mean, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Reciprocation for directed hyperevents (Lerner & Lomi 2023): Σ_{j ∈ J} hy_deg(j, {i}) / |J| — the average, over the candidate's receivers j, of the past events j sent that had the candidate's sender among their receivers. It is subset reciprocation of order (1, 1), DirectedSubsetRepetition(1, 1; direction=:in), and a dyadic effect in Lerner & Lomi's classification (a sum of dyadic covariates over the receivers).
The 2019 preprint's "reciprocation" is the stricter exact reciprocation — the whole receiver set replying to the whole sender set — which is ExactRepetition(direction=:in).
Example
using Revel
h = build_hyper_history([HyperEvent([2], [1, 4], 1.0), HyperEvent([3], [5], 2.0)])
compute(HyperReciprocation(), h, [1], [2, 3], 3.0) # (1 + 0)/2 = 0.5Revel.OutInPopularity — Function
OutInPopularity(; aggregate=:mean, memory=FullMemory(), weighted=false,
types=nothing, transform=identity, name=nothing)Out-in popularity (Lerner & Lomi 2023): Σ_{j ∈ J} deg⁽ᵒᵘᵗ⁾(j) / |J|, the average number of past hyperevents the candidate's receivers have sent — do active senders attract messages, from anyone? It is subset reciprocation of order (1, 0), DirectedSubsetRepetition(1, 0; direction=:in).
Example
using Revel
h = build_hyper_history([HyperEvent([2], [1, 4], 1.0), HyperEvent([2], [5], 2.0)])
compute(OutInPopularity(), h, [1], [2, 3], 3.0) # (2 + 0)/2 = 1.0Revel.InteractionAmongReceivers — Type
InteractionAmongReceivers(order=1; aggregate=:mean, memory=FullMemory(),
weighted=false, types=nothing, transform=identity,
name=nothing)Past interaction among the receivers, of order p (Lerner & Lomi 2023, interact_rec⁽ᵖ⁾):
Σ_{j ∈ J} Σ_{J′ ⊆ J∖{j}, |J′| = p} hy_deg(j, J′) / (|J| · C(|J| − 1, p)),
hy_deg(j, J′) = Σ w·1(j = iₘ ∧ J′ ⊆ Jₘ)— the candidate addresses a past sender j together with p of that sender's past receivers (in citation data: cite a paper and some of its references). It is not a sum of dyadic covariates for any p ≥ 1. aggregate=:sum drops the normalisation. A receiver set of fewer than p + 1 actors scores 0.
Example
using Revel
h = build_hyper_history([HyperEvent([2], [3, 4], 1.0)])
# j = 2: deg(2→3) = 1; j = 3: deg(3→2) = 0
compute(InteractionAmongReceivers(1), h, [1], [2, 3], 2.0) # (1 + 0)/2 = 0.5
# order 2 over {2,3,4}: only j = 2 with J′ = {3,4} has a past event
compute(InteractionAmongReceivers(2), h, [1], [2, 3, 4], 2.0) # 1/3Closure
Revel.HyperClosure — Type
HyperClosure(; dir1=:out, dir2=:in, combine=:min, parallel=:sum,
aggregate=:mean, normalize=:none, n_actors=nothing,
memory=FullMemory(), weighted=false, types=nothing,
transform=identity, name=nothing)
HyperClosure(kind::Symbol; kwargs...)Triadic closure for hyperevents (eventnet UHE_CLOSURE_STAT/DHE_CLOSURE_STAT): the value of the two-paths i – k – j through third actors k, aggregated over the pairs of the candidate hyperedge. It is built on the dyadic projection of the past hyperevents,
W(i, j; t) = Σ_{e: tₑ ≤ t} w(t − tₑ) · χ(i ∈ Iₑ ∧ j ∈ Jₑ) (directed)
W(i, j; t) = Σ_{e: tₑ ≤ t} w(t − tₑ) · χ({i, j} ⊆ hₑ) (undirected)— the hyperedge degree of the pair. For each pair of the candidate — a sender i and a receiver j of a directed candidate, an unordered pair of participants of an undirected one — and each third actor k ∉ {i, j} (k may be another member of the candidate), the two legs are combined by combine (:min, the papers' choice and the default here; or :product, eventnet's default), the parallel paths through different k by parallel (:sum or :max), and the pairs by aggregate (:mean, :sum, :min, :max).
With the defaults this is the closure of Lerner, Lomi, Mowbray, Rollings & Tranmer (2021) for undirected meetings — the sum over pairs {u, v} ⊆ h and third actors w of min[deg({u, w}), deg({v, w})], divided by the number of pairs — and, on directed hyperevents, the triadic effects of Lerner & Lomi (2023), Σ_{j ∈ J, a ≠ i, j} min{·, ·} / |J|. aggregate=:sum gives the unnormalised triadic closure of Lerner, Hâncean & Perc (2025).
The legs (directed hyperevents only; the projection of undirected hyperevents is symmetric and the directions are ignored): dir1 reads the sender's leg — :out is W(i, k), :in is W(k, i), :sym their sum; dir2 reads the receiver's leg — :in is W(k, j), :out is W(j, k), :sym their sum. The four variants of Lerner et al. (2019) and Lerner & Lomi (2023) are
kind | dir1, dir2 | legs | also called |
|---|---|---|---|
:transitive | :out, :in | W(i,k), W(k,j) | transitive closure |
:cyclic | :in, :out | W(k,i), W(j,k) | cyclic closure |
:shared_senders | :in, :in | W(k,i), W(k,j) | incoming balance (2023), sender balance, sibling |
:shared_receivers | :out, :out | W(i,k), W(j,k) | outgoing balance (2023), receiver balance, cosibling |
and HyperClosure(kind) sets the two directions.
normalize records a drift between the papers: the 2019 preprint divides closure by the number of possible third actors, the papers from 2021 onward do not. :none (default) follows the later papers; :thirds also divides by n_actors − 2 and needs n_actors=. (The preprint does not say whether its count excludes the other members of the candidate; n_actors − 2, every actor but the pair, is the reading implemented. With a fixed actor set it rescales the coefficient by a constant.)
Only closure of order (1, 1, 1) is implemented — single actors at the three corners — not the general order (p, q, l) of the 2019 preprint. The optional node attribute on the third actor, the four-cycle and the neighbour statistics of eventnet are not implemented either.
Example
using Revel
h = build_hyper_history([HyperEvent([1, 3], 1.0), HyperEvent([1, 3], 2.0),
HyperEvent([2, 3, 4], 3.0)])
# pair {1,2}: through 3, min(W13, W23) = min(2, 1) = 1; through 4, min(0, 1) = 0
compute(HyperClosure(), h, [1, 2], Int[], 4.0) # 1.0
compute(HyperClosure(combine=:product), h, [1, 2], Int[], 4.0) # 2.0
compute(HyperClosure(normalize=:thirds, n_actors=4), h, [1, 2], Int[], 4.0) # 1/2
mails = build_hyper_history([HyperEvent([1], [3], 1.0), HyperEvent([3], [2, 4], 2.0)])
compute(HyperClosure(:transitive), mails, [1], [2, 4], 3.0) # (1 + 1)/2 = 1.0
compute(HyperClosure(:cyclic), mails, [1], [2, 4], 3.0) # 0.0Design, fitting and simulation
Revel.hyper_design — Function
hyper_design(events, statistics, n_actors; n_controls=20,
rng=Random.default_rng(), sampler=:auto, ties=:error,
actors=nothing) -> DataFrameThe case-control design of a relational hyperevent model (Lerner & Lomi 2023; eventnet): for each observed hyperevent, one row for the event and one for each of n_controls alternative hyperedges of the same size — the same number of senders and of receivers, sender and receiver sets disjoint — drawn uniformly without replacement from the hyperedges the actors at risk could have formed, the observed one excluded. The statistics of every row are read off the history strictly before the event.
The number of hyperedges of a given size is astronomically large for all but the smallest networks, so the risk set cannot be enumerated; conditioning on the observed size and sampling non-events is what makes the model estimable. When the alternatives of that size number n_controls or fewer they are all included, and the conditional likelihood is then exact for the size-stratified risk set.
The frame has the bookkeeping columns REM.fit_rem(::DataFrame, names) reads — event_index (position in the time-sorted sequence), is_event, stratum, risk_set_size (the number of possible hyperedges of that size, saturating at typemax(Int)), sampling_prob (the share of the alternatives that was kept), tie_weight — plus time, the list columns senders and receivers describing each row's hyperedge, and one column per statistic, named by name(stat). The tie policy that applied rides along as the "tie_method" metadata.
sampler—:receiverskeeps the observed senders and draws receiver sets only: the design of Lerner & Lomi (2023), whose baseline is stratified by sender and receiver-set size. Under it a statistic of the senders alone (HyperSenderActivity, a sender covariate) is constant within every stratum and not identified.:uniformdraws whole hyperedges (senders and receivers); for directed hyperevents it assumes every sender set is equally likely to act, and is biased when senders differ in how often they act unless the model accounts for it.:auto(the default) is:receiversfor directed hyperevents and:uniformfor undirected ones.ties—:error(default),:ordered(sequence order, no correction) or:breslow(the history is frozen across a block of tied events), with the meaning they have ineach_risk_set.:efronand:batchare refused with the reason.actors— the actor IDs at risk (default1:n_actors), or a function(index, event) -> actor IDswhen the actors at risk change over the sequence (actors joining or leaving). Every observed participant must be among them.
A statistic that depends on the size of the hyperedge alone (HyperedgeSize) is constant within every stratum; include it only inside an Interaction.
Example
using Revel, Random
events = [HyperEvent([1, 2], 1.0), HyperEvent([1, 2, 3], 2.0), HyperEvent([1, 2], 3.0)]
design = hyper_design(events, [SubsetRepetition(2)], 5; n_controls=3, rng=Xoshiro(1))
size(design, 1) # 12 — three events × (1 case + 3 controls)
design.risk_set_size[design.is_event] # [10, 10, 10] — C(5,2), C(5,3), C(5,2)
design[design.is_event, "subrep(2)"] # [0.0, 1/3, 2.0]Revel.HyperFit — Type
HyperFitA fitted relational hyperevent model: the REM.REMResult of the conditional logit on the case-control design (fit.fit) together with the time-sorted hyperevents, the statistics, n_actors, n_controls, the sampler and the tie policy that produced it.
It answers the StatsAPI verbs (coef, stderror, vcov, confint, loglikelihood, nobs, dof, aic, bic, coeftable, coefnames) and the ecosystem's result-metadata protocol (NetworkCore.fit_metadata) by forwarding them to the underlying fit. Goodness of fit is not implemented for hyperevent fits: gof(fit) throws an ArgumentError.
Example
using Revel, Random
stats = [SubsetRepetition(2; transform=:log1p)]
events = simulate_hyperevents(stats, [1.0], 6, 80; sizes=[2, 3], rng=Xoshiro(1))
fit = fit_rhem(events, stats, 6; rng=Xoshiro(2))
fit isa HyperFit # true
coefnames(fit) # ["log1p(subrep(2))"]
nobs(fit), fit.n_controls # (80, 20)Revel.fit_rhem — Function
fit_rhem(events, statistics, n_actors; n_controls=20,
rng=Random.default_rng(), sampler=:auto, ties=:error,
actors=nothing, se=:hessian, maxiter=100, tol=1e-8) -> HyperFitFit a relational hyperevent model (RHEM; Lerner, Tranmer, Mowbray & Hâncean 2019; Lerner & Lomi 2023): the rate of a hyperevent on the hyperedge h is λ(h; t) = λ₀(t, |h|) · exp(θ′x(h; t)), with a baseline stratified by the size of the hyperedge, and θ is estimated from the conditional probability that the observed hyperedge — rather than one of the alternatives of its size — is the one on which the event occurred. rhem is an alias.
The function builds the size-stratified case-control design with hyper_design (n_controls, rng, sampler, ties and actors are its keywords) and fits it with REM.fit_rem(design, names), the ecosystem's conditional logit — se is :hessian or :sandwich, and non-convergence, collinearity and separation are reported as that function reports them.
Sampling non-events leaves the estimator consistent; the estimates vary from one draw of controls to the next, so fix rng for reproducibility and raise n_controls to reduce that variation — the default 20 keeps small examples fast, and the papers use about 100. Statistic names must be unique.
Example
using Revel, Random
truth = [SubsetRepetition(1; transform=:log1p), SubsetRepetition(2; transform=:log1p)]
events = simulate_hyperevents(truth, [0.5, 1.0], 7, 200; sizes=[2, 3], rng=Xoshiro(3))
fit = fit_rhem(events, truth, 7; n_controls=40, rng=Xoshiro(4))
round.(coef(fit); digits=1) # close to [0.5, 1.0]
stderror(fit) # from the conditional-logit informationRevel.rhem — Function
rhem(events, statistics, n_actors; kwargs...) -> HyperFitAlias for fit_rhem (the ecosystem's convention: every model answers to a fit_<model> name and a short one).
Example
using Revel, Random
stats = [SubsetRepetition(2; transform=:log1p)]
events = simulate_hyperevents(stats, [1.0], 6, 80; sizes=[2, 3], rng=Xoshiro(5))
rhem === fit_rhem # true
coef(rhem(events, stats, 6; rng=Xoshiro(6)))[1] > 0 # trueRevel.simulate_hyperevents — Function
simulate_hyperevents(statistics, coefficients, n_actors, n_events; sizes,
rng=Random.default_rng(), directed=nothing,
candidates=1000, actors=nothing)
-> Vector{HyperEvent{Float64}}Simulate a hyperevent sequence from a relational hyperevent model. At each step the size of the next hyperedge is drawn uniformly from sizes, and then the hyperedge itself is chosen among the hyperedges of that size with probability proportional to exp(θ′x), the statistics x being read off the hyperevents simulated so far. Events occur at times 1, 2, …, n_events.
sizes— a vector of sizes (undirected hyperevents), or of(senders, receivers)size pairs (directed). Withdirected=truea plain integerkmeans one sender andkreceivers.candidates— the choice is among all hyperedges of the drawn size when there are at mostcandidatesof them. Otherwise it is amongcandidateshyperedges of that size sampled uniformly without replacement: an approximation, since a hyperedge outside the sampled set cannot be chosen at that step. Keep the network small, or raisecandidates, when the simulation has to be exact (a recovery study).actors— the actor IDs at risk (default1:n_actors).
All randomness comes from rng. Cumulative statistics with positive coefficients feed back on themselves; scale them (transform=:log1p) or use a decaying memory.
Example
using Revel, Random
stats = [SubsetRepetition(2; transform=:log1p)]
meetings = simulate_hyperevents(stats, [1.0], 6, 50; sizes=[2, 3, 3], rng=Xoshiro(1))
length(meetings), meetings[end].time # (50, 50.0)
mails = simulate_hyperevents([ReceiverSetRepetition(1; transform=:log1p)], [0.5], 6, 20;
sizes=[(1, 2), (1, 3)], rng=Xoshiro(1))
all(is_directed, mails) # trueStatsAPI.coefnames — Method
coefnames(fit::HyperFit) -> Vector{String}The coefficient names in coef(fit) order: the names of the statistics.
Example
using Revel, Random
stats = [SubsetRepetition(1; transform=:log1p), ExactRepetition(transform=:log1p)]
events = simulate_hyperevents(stats, [0.5, 0.5], 6, 60; sizes=[2, 3], rng=Xoshiro(7))
coefnames(fit_rhem(events, stats, 6; rng=Xoshiro(8)))
# ["log1p(subrep(1))", "log1p(exact.rep)"]