Statistics API Reference

This page documents all statistics available in REM.jl.

Base Types and Interface

Abstract Types

REM.AbstractStatisticType
AbstractStatistic

Abstract base type for all REM statistics.

All statistics must implement:

  • compute(stat::AbstractStatistic, state::NetworkState, sender::Int, receiver::Int) -> Float64
  • name(stat::AbstractStatistic) -> String
source
REM.DyadStatisticType
DyadStatistic <: AbstractStatistic

Statistics that depend on the history of events between the focal dyad (sender, receiver). Examples: repetition, reciprocity, inertia.

source
REM.DegreeStatisticType
DegreeStatistic <: AbstractStatistic

Statistics that depend on the degree (activity/popularity) of actors. Examples: sender activity, receiver popularity.

source
REM.TriangleStatisticType
TriangleStatistic <: AbstractStatistic

Statistics that measure triadic closure effects. Examples: transitive closure, cyclic closure, shared partners.

source
REM.NodeStatisticType
NodeStatistic <: AbstractStatistic

Statistics based on node-level attributes. Examples: homophily, attribute matching.

source

Interface Functions

REM.computeFunction
compute(stat::AbstractStatistic, state::NetworkState, sender::Int, receiver::Int) -> Float64

Compute the statistic value for a potential event from sender to receiver. This is the main interface that all statistics must implement.

source
REM.nameFunction
name(stat::AbstractStatistic) -> String

Return a descriptive name for the statistic.

source

StatisticSet

REM.compute_allFunction
compute_all(ss::StatisticSet, state::NetworkState, sender::Int, receiver::Int) -> Vector{Float64}

Compute all statistics in the set for a potential event.

source
compute_all(stats::Vector{<:AbstractStatistic}, state::NetworkState, sender::Int, receiver::Int) -> Vector{Float64}

Compute all statistics for a potential event.

source

Dyad Statistics

Statistics based on the history of events between the focal sender-receiver pair.

REM.RepetitionType
Repetition <: DyadStatistic

Measures 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.
source
REM.ReciprocityType
Reciprocity <: DyadStatistic

Measures the tendency for reciprocal events. Returns the (weighted) count of past events from receiver to sender.

Fields

  • stat_name::String: Name for this statistic.
source
REM.InertiaStatisticType
InertiaStatistic <: DyadStatistic

Measures 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.
source
REM.RecencyStatisticType
RecencyStatistic <: DyadStatistic

Measures 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.
source
REM.DyadCovariateType
DyadCovariate <: DyadStatistic

A 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.
source

Degree Statistics

Statistics based on actor activity (out-degree) and popularity (in-degree).

REM.SenderActivityType
SenderActivity <: DegreeStatistic

Measures 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.
source
REM.ReceiverActivityType
ReceiverActivity <: DegreeStatistic

Measures 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.
source
REM.SenderPopularityType
SenderPopularity <: DegreeStatistic

Measures 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.
source
REM.ReceiverPopularityType
ReceiverPopularity <: DegreeStatistic

Measures 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.
source
REM.TotalDegreeType
TotalDegree <: DegreeStatistic

Measures 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.
source
REM.DegreeDifferenceType
DegreeDifference <: DegreeStatistic

Measures 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.
source
REM.LogDegreeType
LogDegree <: DegreeStatistic

Measures 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.
source

Triangle Statistics

Statistics capturing triadic closure effects in directed networks.

REM.TransitiveClosureType
TransitiveClosure <: TriangleStatistic

Measures 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.
source
REM.CyclicClosureType
CyclicClosure <: TriangleStatistic

Measures 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.
source
REM.SharedSenderType
SharedSender <: TriangleStatistic

Measures 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.
source
REM.SharedReceiverType
SharedReceiver <: TriangleStatistic

Measures 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.
source
REM.CommonNeighborsType
CommonNeighbors <: TriangleStatistic

Measures the number of common neighbors (undirected) between sender and receiver.

Fields

  • stat_name::String: Name for this statistic.
source
REM.GeometricWeightedTriadsType
GeometricWeightedTriads <: TriangleStatistic

Geometrically 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.
source

Four-Cycle Statistics

Statistics capturing higher-order clustering through four-node structures.

REM.FourCycleType
FourCycle <: FourCycleStatistic

Measures 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.
source
REM.GeometricWeightedFourCyclesType
GeometricWeightedFourCycles <: FourCycleStatistic

Geometrically 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.
source

Node Attribute Statistics

Statistics incorporating actor-level attributes for homophily and covariate effects.

REM.NodeMatchType
NodeMatch <: NodeStatistic

Measures 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.
source
REM.NodeMixType
NodeMix <: NodeStatistic

Measures 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.
source
REM.NodeDifferenceType
NodeDifference <: NodeStatistic

Measures 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.
source
REM.NodeSumType
NodeSum <: NodeStatistic

Measures the sum of a numeric attribute for sender and receiver.

Fields

  • attribute::NodeAttribute{<:Number}: The numeric attribute.
  • stat_name::String: Name for this statistic.
source
REM.NodeProductType
NodeProduct <: NodeStatistic

Measures the product of a numeric attribute for sender and receiver.

Fields

  • attribute::NodeAttribute{<:Number}: The numeric attribute.
  • stat_name::String: Name for this statistic.
source
REM.SenderAttributeType
SenderAttribute <: NodeStatistic

Returns the sender's attribute value (as a main effect).

Fields

  • attribute::NodeAttribute{<:Number}: The numeric attribute.
  • stat_name::String: Name for this statistic.
source
REM.ReceiverAttributeType
ReceiverAttribute <: NodeStatistic

Returns the receiver's attribute value (as a main effect).

Fields

  • attribute::NodeAttribute{<:Number}: The numeric attribute.
  • stat_name::String: Name for this statistic.
source
REM.SenderCategoricalType
SenderCategorical <: NodeStatistic

Returns 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.
source
REM.ReceiverCategoricalType
ReceiverCategorical <: NodeStatistic

Returns 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.
source