Statistics API Reference
This page documents all statistics available in REM.jl.
Base Types and Interface
Abstract Types
REM.AbstractStatistic — Type
AbstractStatisticAbstract base type for all REM statistics.
All statistics must implement:
compute(stat::AbstractStatistic, state::NetworkState, sender::Int, receiver::Int) -> Float64name(stat::AbstractStatistic) -> String
REM.DyadStatistic — Type
DyadStatistic <: AbstractStatisticStatistics that depend on the history of events between the focal dyad (sender, receiver). Examples: repetition, reciprocity, inertia.
REM.DegreeStatistic — Type
DegreeStatistic <: AbstractStatisticStatistics that depend on the degree (activity/popularity) of actors. Examples: sender activity, receiver popularity.
REM.TriangleStatistic — Type
TriangleStatistic <: AbstractStatisticStatistics that measure triadic closure effects. Examples: transitive closure, cyclic closure, shared partners.
REM.FourCycleStatistic — Type
FourCycleStatistic <: AbstractStatisticStatistics that measure four-cycle (local clustering) effects.
REM.NodeStatistic — Type
NodeStatistic <: AbstractStatisticStatistics based on node-level attributes. Examples: homophily, attribute matching.
REM.InteractionStatistic — Type
InteractionStatistic <: AbstractStatisticStatistics that capture interaction effects between attributes.
Interface Functions
REM.compute — Function
compute(stat::AbstractStatistic, state::NetworkState, sender::Int, receiver::Int) -> Float64Compute the statistic value for a potential event from sender to receiver. This is the main interface that all statistics must implement.
StatisticSet
REM.StatisticSet — Type
StatisticSetA collection of statistics to compute together.
REM.compute_all — Function
compute_all(ss::StatisticSet, state::NetworkState, sender::Int, receiver::Int) -> Vector{Float64}Compute all statistics in the set for a potential event.
compute_all(stats::Vector{<:AbstractStatistic}, state::NetworkState, sender::Int, receiver::Int) -> Vector{Float64}Compute all statistics for a potential event.
Dyad Statistics
Statistics based on the history of events between the focal sender-receiver pair.
REM.Repetition — Type
Repetition <: DyadStatisticMeasures the tendency for repeated events from sender to receiver. Returns the (weighted) count of past events from sender to receiver.
Fields
directed::Bool: If true, count only events from s→r. If false, count events in both directions.stat_name::String: Name for this statistic.
REM.Reciprocity — Type
Reciprocity <: DyadStatisticMeasures the tendency for reciprocal events. Returns the (weighted) count of past events from receiver to sender.
Fields
stat_name::String: Name for this statistic.
REM.InertiaStatistic — Type
InertiaStatistic <: DyadStatisticMeasures inertia - the tendency for events to persist in a direction. Combines repetition and reciprocity effects.
Returns: repetitionweight * repetition + reciprocityweight * reciprocity
Fields
repetition_weight::Float64: Weight for repetition component.reciprocity_weight::Float64: Weight for reciprocity component.stat_name::String: Name for this statistic.
REM.RecencyStatistic — Type
RecencyStatistic <: DyadStatisticMeasures recency - how recently the last event occurred on this dyad. Returns the inverse of elapsed time since last event (or 0 if no prior events).
Fields
directed::Bool: If true, only consider events from s→r.transform::Symbol: Transform to apply (:inverse, :log, :exp_decay).decay::Float64: Decay parameter for :exp_decay transform.stat_name::String: Name for this statistic.
REM.DyadCovariate — Type
DyadCovariate <: DyadStatisticA statistic based on a pre-specified dyad-level covariate matrix.
Fields
values::Dict{Tuple{Int,Int}, Float64}: Mapping from dyad to covariate value.default::Float64: Default value for dyads not in the dict.stat_name::String: Name for this statistic.
Degree Statistics
Statistics based on actor activity (out-degree) and popularity (in-degree).
REM.SenderActivity — Type
SenderActivity <: DegreeStatisticMeasures the sender's past activity (out-degree). Returns the (weighted) number of past events sent by the sender.
Fields
stat_name::String: Name for this statistic.
REM.ReceiverActivity — Type
ReceiverActivity <: DegreeStatisticMeasures the receiver's past activity (out-degree). Returns the (weighted) number of past events sent by the receiver.
Fields
stat_name::String: Name for this statistic.
REM.SenderPopularity — Type
SenderPopularity <: DegreeStatisticMeasures the sender's past popularity (in-degree). Returns the (weighted) number of past events received by the sender.
Fields
stat_name::String: Name for this statistic.
REM.ReceiverPopularity — Type
ReceiverPopularity <: DegreeStatisticMeasures the receiver's past popularity (in-degree). Returns the (weighted) number of past events received by the receiver.
Fields
stat_name::String: Name for this statistic.
REM.TotalDegree — Type
TotalDegree <: DegreeStatisticMeasures the total degree (in + out) of an actor.
Fields
role::Symbol: Which actor's degree to compute (:sender or :receiver).stat_name::String: Name for this statistic.
REM.DegreeDifference — Type
DegreeDifference <: DegreeStatisticMeasures the difference in degree between sender and receiver.
Fields
degree_type::Symbol: Type of degree to compare (:out, :in, or :total).absolute::Bool: If true, return absolute difference.stat_name::String: Name for this statistic.
REM.LogDegree — Type
LogDegree <: DegreeStatisticMeasures the log-transformed degree of an actor. Uses log(1 + degree) to handle zero degrees.
Fields
role::Symbol: Which actor's degree to compute (:sender or :receiver).degree_type::Symbol: Type of degree (:out, :in, or :total).stat_name::String: Name for this statistic.
Triangle Statistics
Statistics capturing triadic closure effects in directed networks.
REM.TransitiveClosure — Type
TransitiveClosure <: TriangleStatisticMeasures transitive closure: tendency for s→r when there exists k such that s→k→r. Returns the count of actors k who have received from s and sent to r.
Fields
weighted::Bool: If true, weight by edge weights.stat_name::String: Name for this statistic.
REM.CyclicClosure — Type
CyclicClosure <: TriangleStatisticMeasures cyclic closure: tendency for s→r when there exists k such that r→k→s. Returns the count of actors k who have received from r and sent to s.
Fields
weighted::Bool: If true, weight by edge weights.stat_name::String: Name for this statistic.
REM.SharedSender — Type
SharedSender <: TriangleStatisticMeasures shared sender effect: tendency for s→r when there exists k such that k→s and k→r. Returns the count of actors k who have sent to both s and r.
Fields
weighted::Bool: If true, weight by edge weights.stat_name::String: Name for this statistic.
REM.SharedReceiver — Type
SharedReceiver <: TriangleStatisticMeasures shared receiver effect: tendency for s→r when there exists k such that s→k and r→k. Returns the count of actors k who have received from both s and r.
Fields
weighted::Bool: If true, weight by edge weights.stat_name::String: Name for this statistic.
REM.CommonNeighbors — Type
CommonNeighbors <: TriangleStatisticMeasures the number of common neighbors (undirected) between sender and receiver.
Fields
stat_name::String: Name for this statistic.
REM.GeometricWeightedTriads — Type
GeometricWeightedTriads <: TriangleStatisticGeometrically weighted shared partner statistic. Down-weights the contribution of additional shared partners.
Fields
closure_type::Symbol: Type of closure (:transitive, :cyclic, :sharedsender, :sharedreceiver).alpha::Float64: Decay parameter (higher = less down-weighting).stat_name::String: Name for this statistic.
Four-Cycle Statistics
Statistics capturing higher-order clustering through four-node structures.
REM.FourCycle — Type
FourCycle <: FourCycleStatisticMeasures four-cycle closure: tendency for s→r when there exist j, k such that s→j, k→j, and k→r (or variants).
This captures local clustering where sender and receiver share connections to a common pair of intermediaries.
Fields
cycle_type::Symbol: Type of four-cycle configuration.- :out_out: s→j←k→r (shared out-neighbor pattern)
- :in_in: s←j→k←r (shared in-neighbor pattern)
- :out_in: s→j→k→r (two-path through intermediaries)
- :mixed: any configuration
weighted::Bool: If true, weight by edge weights.stat_name::String: Name for this statistic.
REM.GeometricWeightedFourCycles — Type
GeometricWeightedFourCycles <: FourCycleStatisticGeometrically weighted four-cycle statistic. Down-weights the contribution of additional four-cycles.
Fields
cycle_type::Symbol: Type of four-cycle configuration.alpha::Float64: Decay parameter (higher = less down-weighting).stat_name::String: Name for this statistic.
Node Attribute Statistics
Statistics incorporating actor-level attributes for homophily and covariate effects.
REM.NodeMatch — Type
NodeMatch <: NodeStatisticMeasures homophily: tendency for events between actors with matching attributes. Returns 1.0 if sender and receiver have the same attribute value, 0.0 otherwise.
Fields
attribute::NodeAttribute: The attribute to match on.stat_name::String: Name for this statistic.
REM.NodeMix — Type
NodeMix <: NodeStatisticMeasures mixing patterns: indicator for specific sender-receiver attribute combinations. Returns 1.0 if sender has value sender_value and receiver has receiver_value.
Fields
attribute::NodeAttribute: The attribute to check.sender_value: Required sender attribute value.receiver_value: Required receiver attribute value.stat_name::String: Name for this statistic.
REM.NodeDifference — Type
NodeDifference <: NodeStatisticMeasures the difference in a numeric attribute between sender and receiver.
Fields
attribute::NodeAttribute{<:Number}: The numeric attribute.absolute::Bool: If true, return absolute difference.stat_name::String: Name for this statistic.
REM.NodeSum — Type
NodeSum <: NodeStatisticMeasures the sum of a numeric attribute for sender and receiver.
Fields
attribute::NodeAttribute{<:Number}: The numeric attribute.stat_name::String: Name for this statistic.
REM.NodeProduct — Type
NodeProduct <: NodeStatisticMeasures the product of a numeric attribute for sender and receiver.
Fields
attribute::NodeAttribute{<:Number}: The numeric attribute.stat_name::String: Name for this statistic.
REM.SenderAttribute — Type
SenderAttribute <: NodeStatisticReturns the sender's attribute value (as a main effect).
Fields
attribute::NodeAttribute{<:Number}: The numeric attribute.stat_name::String: Name for this statistic.
REM.ReceiverAttribute — Type
ReceiverAttribute <: NodeStatisticReturns the receiver's attribute value (as a main effect).
Fields
attribute::NodeAttribute{<:Number}: The numeric attribute.stat_name::String: Name for this statistic.
REM.SenderCategorical — Type
SenderCategorical <: NodeStatisticReturns 1.0 if sender has a specific categorical attribute value.
Fields
attribute::NodeAttribute: The categorical attribute.value: The value to match.stat_name::String: Name for this statistic.
REM.ReceiverCategorical — Type
ReceiverCategorical <: NodeStatisticReturns 1.0 if receiver has a specific categorical attribute value.
Fields
attribute::NodeAttribute: The categorical attribute.value: The value to match.stat_name::String: Name for this statistic.