ERGMRank.jl
Model complete rankings of other actors, such as each person’s ordering of everyone else in a group. ERGMRank.jl preserves the ranking sample space, evaluates rank statistics, and fits by MCMC maximum likelihood (the default, R ergm.rank’s estimator) or by a fast swap-based pseudo-likelihood.
| First analysis | Learn the model or data | Reference and detail |
|---|---|---|
| Build and fit rankings | Understand complete rankings | Estimate, check and simulate |
Every actor must rank all other actors without ties: each row’s off-diagonal values are a permutation of 1:(n-1), with larger values indicating higher standing. Partial rankings, tied rankings, and missing dyads are refused. The default estimator is the MCMC MLE, as in R ergm.rank; method=:mple selects the swap pseudo-likelihood, a different and faster estimator whose default fit reports no p-values. The README lists what is not implemented.
Installation
Use Julia 1.12 or newer and the shared workspace installation guide. These development packages are not yet registered; the guide prepares the required sibling checkouts and a Julia environment for the examples.
Quick Start
Fit the bundled first week of Newcomb’s sociometric rankings by MCMC maximum likelihood (10–20 s; the bridge estimate of the log-likelihood is skipped here to keep it short):
using ERGMRank, Random
rankings = newcomb_week1()
fit = fit_ergm_rank(rankings, [RankDeference(), RankNonconformity()];
bridge_rungs=0, rng=Xoshiro(1))
display(fit)The two terms describe deference and conformity in rankings; the estimates reproduce R ergm.rank’s (−0.153 and −0.0066) up to Monte-Carlo error. Follow the estimation guide for the MCMC budget and convergence checks, goodness of fit, the fast swap pseudo-likelihood (method=:mple), seeded simulation, and the distinction between Julia’s absolute and R’s null-relative log-likelihood reporting.
The Model
Each ego rank-orders all alters. The observation for ego $i$ is a permutation of the $n-1$ alters, encoded as rank values with greater values indicating higher standing. The model is
\[P(\mathbf{Y} = \mathbf{y}) \propto \exp\left(\theta' g(\mathbf{y})\right)\]
on the space of complete orderings, under the discrete-uniform CompleteOrderReference — every valid rank configuration has equal baseline weight, so the structure comes from the sample-space constraint and the statistics $g$.
Highlights
RankNetworkenforces the complete-ranking invariant (each ego's ranks are a permutation of1:(n-1)), preserved byswap_ranks!(the AlterSwap move);as_rank_networkbuilds one from a rank matrix or — honouring the ecosystem conversion contract (reject a masked or undirected network, report every dropped attribute) — from a directedNetworkCore.Networkwith a rank edge attribute- The implemented terms have deterministic fixtures generated with R
ergm.rank4.1.2:RankDeference,RankNonconformity(:all/:localAND; the otherergm.rankvariants are refused, not silently approximated),RankNodeICov,RankInconsistency(withergm.rank'sweights,wtnameandwtcenter),RankEdgeCov— each with a per-swap change statisticswap_change ergm_rankfits by MCMC maximum likelihood by default (the estimator ofergm.rank, asserted against it on two Newcomb fixtures) or by swap-based maximum pseudo-likelihood (method=:mple: fast, with R'sdropsemantics for boundary statistics, a loud "MPLE does not exist" for separated models, and no p-values unless bootstrapped or opted into), with the full StatsAPI surface and the shared result-metadata protocol on the resultgofcompares the observed ranking with simulated ones on the model statistics and on auxiliary statistics the model does not containsimulate_rank_ergmsamples with AlterSwap Metropolis moves on the ecosystem's oneERGM.mh_toggle!kernel — allocation-free steps, swap-scaled burn-in defaults, every draw reproducible fromrng
Contents
- Getting Started
- Rank Networks
- Rank Terms
- Estimation and Simulation
- MCMC MLE (
method=:mcmle, the default) - Swap-based maximum pseudo-likelihood (
method=:mple) - The StatsAPI surface
- Bootstrap standard errors:
se=:bootstrap - When the swap-MPLE does not exist
- Non-convergence of the swap-MPLE
- Newcomb week 1: the two estimators on the real data
- AlterSwap Metropolis simulation
- Model checking
- MCMC MLE (
- Types
- Terms
- Estimation and Simulation
References
- Krivitsky, P.N. & Butts, C.T. (2017). Exponential-family random graph models for rank-order relational data. Sociological Methodology, 47(1), 68-112.
- Krivitsky, P.N. (2012). Exponential-family random graph models for valued networks. Electronic Journal of Statistics, 6, 1100-1128.
Citation
If you use ERGMRank.jl in your work, please cite it using the entry in CITATION.bib. Please also cite the R package it follows, ergm.rank, and the paper that introduced the models (Krivitsky & Butts 2017, reference 1 above); the ecosystem's How to cite page lists the full references.
@misc{SNWJERGMRankJL,
author = {Santoni, Simone},
title = {ERGMRank.jl: Exponential Random Graph Models for Rank-Order Relational Data in Julia},
year = {2026},
url = {https://github.com/statistical-network-analysis-with-Julia/ERGMRank.jl},
note = {Homepage: https://statistical-network-analysis-with-Julia.github.io/ERGMRank.jl; GitHub: https://github.com/statistical-network-analysis-with-Julia}
}