Memory and Layers API Reference
Memory kernels
Revel.AbstractMemory — Type
AbstractMemorySupertype of the memory kernels: a rule giving the weight kernel_weight(m, age) a past event of age age ≥ 0 carries in an endogenous statistic. The concrete kernels are FullMemory, HalfLife, Window, IntervalMemory, PowerLaw, LinearDecay and KernelMemory.
Example
using Revel
kernel_weight(FullMemory(), 10.0) # 1.0
kernel_weight(HalfLife(5.0), 5.0) # 0.5
kernel_weight(Window(3.0), 4.0) # 0.0Revel.FullMemory — Type
FullMemory() <: AbstractMemoryEvery past event counts with weight 1, however old (Butts 2008; remstats memory = "full"). Its statistics are constant between events, which is what the interval-timing likelihood requires; the only other kernel with that property is HalfLife(Inf), which is the same thing.
Example
using Revel
kernel_weight(FullMemory(), 1e6) # 1.0Revel.HalfLife — Type
HalfLife(halflife; normalized=false) <: AbstractMemoryExponential decay: an event of age a weighs exp(-a·ln2/halflife), so its weight halves every halflife time units (Brandes, Lerner & Snijders 2009; eventnet; remstats memory = "decay").
Two normalisations coexist in the literature and they are not interchangeable in a fixture: normalized=false (Lerner & Lomi 2020; Arena et al. 2023) is the plain weight above; normalized=true multiplies it by ln2/halflife (Brandes et al. 2009; the rem package), which rescales the coefficient by a constant. halflife=Inf is no decay.
Example
using Revel
kernel_weight(HalfLife(10.0), 10.0) # 0.5
kernel_weight(HalfLife(10.0; normalized=true), 0.0) # log(2)/10Revel.Window — Type
Window(width) <: AbstractMemorySliding window: an event counts with weight 1 while its age is at most width and not at all afterwards (de Nooy 2011; Quintane et al. 2013; goldfish window; remstats memory = "window"). An event exactly width old still counts, as in REM.jl.
Example
using Revel
kernel_weight(Window(24.0), 24.0) # 1.0
kernel_weight(Window(24.0), 24.5) # 0.0Revel.IntervalMemory — Type
IntervalMemory(lo, hi) <: AbstractMemoryEvents whose age lies in (lo, hi] count with weight 1 (Perry & Wolfe 2013; remstats memory = "interval"). A set of adjacent intervals partitions the past, and giving each its own coefficient estimates the decay shape rather than assuming it — see interval_partition. (It is not called Interval so that it does not clash with IntervalSets.Interval.)
Example
using Revel
kernel_weight(IntervalMemory(1.0, 7.0), 1.0) # 0.0 — the lower bound is open
kernel_weight(IntervalMemory(1.0, 7.0), 7.0) # 1.0Revel.PowerLaw — Type
PowerLaw(exponent; offset=0.0, support=Inf) <: AbstractMemoryPower-law decay: an event of age a weighs (a + offset)^(-exponent) (the Lomi/Vu line: Vu, Lomi, Mascia & Pallotti 2017; Bianchi & Lomi 2023, with the exponent chosen by grid search — see profile_memory). With offset = 0 the weight is undefined at age zero, which only arises for events tied with the one being explained under ties=:ordered; pass a positive offset for such data.
A power law never reaches zero, so every new clock re-reads the whole history: a sequence of E events costs O(E²). support truncates the kernel — an event older than support weighs 0 — which bounds that cost by the events inside it; choose it where the weights have become negligible.
Example
using Revel
kernel_weight(PowerLaw(1.0), 4.0) # 0.25
kernel_weight(PowerLaw(0.5; offset=1.0), 0.0) # 1.0
kernel_weight(PowerLaw(1.0; support=100.0), 200.0) # 0.0Revel.LinearDecay — Type
LinearDecay(span) <: AbstractMemoryLinear decay: an event of age a weighs max(0, 1 - a/span) — the linear decay of Arena, Mulder & Leenders (2023, eq. 8), whose parameter is the half-life, the age at which the weight is 1/2: span is twice their θ. A profile over span and one over their half-life are the same profile on different scales.
Example
using Revel
kernel_weight(LinearDecay(10.0), 2.5) # 0.75
kernel_weight(LinearDecay(10.0), 12.0) # 0.0Revel.KernelMemory — Type
KernelMemory(f; support=Inf) <: AbstractMemoryA user-supplied kernel: f(age) is the weight of an event of age age. support is the age beyond which f is zero (it lets the history scan stop early); leave it at Inf when the kernel never vanishes.
Example
using Revel
m = KernelMemory(a -> a <= 2 ? 1.0 : 0.5^(a - 2)) # a plateau, then decay
kernel_weight(m, 1.0), kernel_weight(m, 3.0) # (1.0, 0.5)Revel.kernel_weight — Function
kernel_weight(memory::AbstractMemory, age::Real) -> Float64The weight a past event of age age (time units, or events when the layer's clock is :order) carries under memory.
Example
using Revel
kernel_weight(HalfLife(2.0), 4.0) # 0.25
kernel_weight(IntervalMemory(0.0, 1.0), 0.5) # 1.0Revel.interval_partition — Function
interval_partition(breaks) -> Vector{IntervalMemory}The adjacent IntervalMemory kernels (b₁, b₂], (b₂, b₃], … cut by the increasing breaks. Fitting one copy of an effect per interval gives the piecewise-constant decay profile of Perry & Wolfe (2013), who used seven intervals, and the stepwise interval effects of Arena, Mulder & Leenders (2024).
Example
using Revel
parts = interval_partition([0.0, 1.0, 24.0, 168.0])
length(parts) # 3
[Inertia(memory=m) for m in parts] # one inertia effect per intervalEvent layers
Revel.EventLayer — Type
EventLayer(; memory=FullMemory(), types=nothing, weighted=false, keep=nothing,
clock=:time, symmetric=false)The remembered network an endogenous effect reads: a rule turning the event history into dyad weights w_t(i, j).
memory— how a past event's weight depends on its age: anyAbstractMemorykernel.types— which past event types feed the layer (aSymbolor a collection of them);nothingtakes every event. This is the type-split form of an interaction (signed events in Brandes, Lerner & Snijders 2009; remstatsconsider_type = "separate"; one attribute per type in eventnet).weighted—trueadds each event'sweight,falsecounts events.keep— a predicate(sender, receiver, time, weight, eventtype) -> Boolselecting the past events that count: the attribute-filtered form of an interaction (therempackage'seventfiltervar; Malang, Brandenberger & Leifeld 2019).clock—:timemeasures age in clock units;:ordermeasures it in events (the age of the most recent event is 1), for order-only data and for half-lives stated in events.symmetric—truerecords each event in both directions, for undirected interaction (remstats' undirected statistics; goldfish coordination ties).
Every effect constructor takes these keywords directly and builds a private layer; pass one shared layer= instead to let several effects read a single index of the history.
A layer holds a mutable cache of the histories it has read. The package's entry points (fit_revel, each_risk_set, simulate_events, the diagnostics, …) work on private copies of the statistics they are given, so one specification can be fitted from several tasks at once; calling compute by hand on one statistic from several tasks concurrently is not safe. The copies also merge layers with identical keywords, so [Inertia(), Reciprocation(), OTP()] index the history once.
Example
using Revel
recent = EventLayer(memory=HalfLife(30.0))
stats = [Inertia(layer=recent), Reciprocation(layer=recent), OTP(layer=recent)]
h = InteractionHistory()
update_history!(h, Event(1, 2, 0.0))
compute(stats[1], h, 1, 2, 30.0) # 0.5 — one event, one half-life old
compute(stats[2], h, 2, 1, 30.0) # 0.5 — the same event, seen from 2 → 1