This release is a pre-release and may not be stable for production use.
relationalstats
A practical Python toolkit for applied and statistical social network analysis, with research-grade documentation and transparent methodological boundaries.
relationalstats provides Python APIs for statistical network analysis workflows
inspired by R sna, ergm, tergm / stergm, and linkprediction, while
remaining explicit about what is equivalent, approximate, experimental, or
planned.
What is included
| Area | Status |
|---|---|
| Link prediction | Initial core implemented |
| QAPLogit | Initial core implemented |
| ERGM | Initial dyadic-logistic approximation |
| STERGM | Initial separable dyadic-logistic approximation |
| R validation | Placeholders and roadmap; fixtures pending |
Installation for local development
python3.10 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev,test]"
Optional extras:
python -m pip install -e ".[docs]"
python -m pip install -e ".[notebooks,plot]"
python -m pip install -e ".[ml]"
python -m pip install -e ".[r]"
Quick usage
Link prediction
import networkx as nx
from relationalstats.linkprediction import ProxFun, proxfun_full
G = nx.path_graph(3)
scores = proxfun_full(
G,
pairs=[(0, 2)],
metrics=["common_neighbors", "jaccard", "adamic_adar"],
)
result = ProxFun(metrics=["jaccard", "adamic_adar"]).fit(G)
result.to_dataframe()
QAPLogit
from relationalstats.datasets import make_qap_toy_data
from relationalstats.qap import QAPLogit
y, x_matrices = make_qap_toy_data()
result = QAPLogit(
n_permutations=99,
random_state=42,
backend="statsmodels",
).fit(y, x_matrices)
result.to_dataframe()
ERGM approximation
from relationalstats.datasets import make_florentine_like_graph
from relationalstats.ergm import ERGM
G = make_florentine_like_graph()
result = ERGM(
terms=["edges", "common_neighbors", "degree1", "gwesp", "nodematch:faction"],
backend="sklearn",
random_state=42,
).fit(G)
result.to_dataframe()
result.gof(n_sim=100, seed=123)
STERGM approximation
from relationalstats.datasets import make_stergm_temporal_toy
from relationalstats.stergm import STERGM
G1, G2 = make_stergm_temporal_toy()
result = STERGM(
formation_terms=["edges", "common_neighbors", "degree1", "gwesp"],
dissolution_terms=["edges", "common_neighbors", "degree1", "gwesp"],
backend="sklearn",
random_state=42,
).fit(G1, G2)
result.to_dataframe()
result.simulate(seed=123)
Documentation map
- Documentation index
- Link prediction
- QAP
- ERGM approximation
- STERGM approximation
- Equivalence vs approximation
- Reproducibility
- Roadmap
Examples
Run examples:
python examples/linkprediction/proxfun_feature_pipeline.py
python examples/qap/qap_logit_toy.py
python examples/qap/qap_logit_backend_comparison.py
python examples/ergm/ergm_florentine_like.py
python examples/stergm/stergm_temporal_toy.py
Repository structure
relationalstats/
├── docs/
│ ├── README.md
│ ├── ergm/
│ ├── linkprediction/
│ ├── methodology/
│ ├── qap/
│ └── stergm/
├── examples/
│ ├── README.md
│ ├── ergm/
│ ├── linkprediction/
│ ├── qap/
│ └── stergm/
├── notebooks/
│ └── README.md
├── scripts/
├── src/
│ └── relationalstats/
│ ├── datasets/
│ ├── ergm/
│ ├── linkprediction/
│ ├── modules/
│ ├── qap/
│ └── stergm/
├── tests/
│ ├── unit/
│ └── validation_against_r/
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── pyproject.toml
└── README.md
Running tests
source .venv/bin/activate
pytest -q
Focused test groups:
pytest tests/unit/test_linkprediction.py tests/unit/test_linkprediction_manual_graphs.py -q
pytest tests/unit/test_qap.py tests/unit/test_qap_permutation.py -q
pytest tests/unit/test_ergm_statistics.py tests/unit/test_ergm_gof.py -q
pytest tests/unit/test_stergm.py -q
Build and distribution validation
source .venv/bin/activate
rm -rf dist build *.egg-info
python -m pip install build twine
python -m build
python -m twine check "dist/*"
ls -lh dist/
Release flow
feature/* -> develop -> release/vX.Y.Z -> main -> tag vX.Y.Z -> PyPI
Pre-release versions should follow PEP 440:
0.1.0a1
0.1.0b1
0.1.0rc1
0.1.0
Methodological transparency
Current ERGM and STERGM implementations are dyadic-logistic approximations, not
full MCMC-MLE implementations equivalent to R ergm, tergm, or stergm.
Validation against R
Planned validation fixtures include:
sna::netlogitfor QAP-style logistic models;linkprediction::proxfunfor link prediction metrics;ergmandnetworkfor selected network statistics;tergm/stergmfor temporal dyad construction where feasible.
Academic and private material policy
Solved academic notebooks, private experiments, raw course material, and non-public validation files should not be committed to the public repository.
Author
- Hubert Ronald - Initial Work - HubertRonald
License
The source code in this repository is distributed under the MIT License. See LICENSE for more details.
Metadata
Release files for relationalstats 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| relationalstats-0.1.0a1.tar.gz | 53.5 kB | With provenance | Details for relationalstats-0.1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| relationalstats-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details for relationalstats-0.1.0a1-py3-none-any.whl |
Total release size: 89.9 kB
Release files / relationalstats-0.1.0a1.tar.gz
| Download URL | relationalstats-0.1.0a1.tar.gz |
|---|---|
| Size | 53.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efb6ec1b69aa9a09d08235a07abc3dd05ca7d9a09aec609ea9c0c49e57c779a5
|
|
BLAKE2b-256 checksum How to use checksums |
0f6cecbc59187c565c9923c50a0a1070fdc3e1fbc28e9c71c99d21c1f51e1fc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 20, 2026.
Transparency logRelease files / relationalstats-0.1.0a1-py3-none-any.whl
| Download URL | relationalstats-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2edaeb8d2409b36c0e81bc0abc554f9743854e29ccb772ebdaeaa4a85f350473
|
|
BLAKE2b-256 checksum How to use checksums |
ad2fc7a5406d8692936b92b0ddc0f9f1d477f79ffc24cebea88fab3c5336a4a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 20, 2026.
Transparency logSecurity for relationalstats 0.1.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for relationalstats-0.1.0a1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.