A Python package for the econometric analysis of the dyadic network formation models with degree heterogeneity
Project description
NetworkFm is a Python package for the econometric analysis of the dyadic network formation models with degree heterogeneity. The package accompanies the paper:
Yan, Zizhong; Li, Jingrong; Zhang, Yi (2026). Penalized Likelihood for Dyadic Network Formation Models with Degree Heterogeneity. (arXiv:2605.00771)
Quick links
- Paper: https://arxiv.org/abs/2605.00771
- Project Documentation:
- Documentation homepage: NetworkFm.readthedocs.io
- Tutorials: Getting started
- Examples and API: Examples and API reference
What does NetworkFm do?
NetworkFm provides a single, unified interface for fitting several workhorse dyadic network formation models:
- Directed utility and mutual (reciprocity) utility (the main setting of the paper)
- Directed utility only (no mutual component), and
- Mutual utility only, which corresponds to undirected networks.
A key motivation for NetworkFm is that empirical network data are often sparse. In sparse networks, standard fixed-effects estimation routines can break down. Not only because of the classic incidental parameter problem, but also because estimation may be infeasible due to existence / separation–type issues. In practice, this can turn a seemingly standard application into “the optimizer never converges” or “some fixed effects are not identified,” even when the model is conceptually appropriate.
The package implements the likelihood correction proposed in Yan, Li, and Zhang (2026). This correction is designed to address both challenges at once:
- it delivers bias reduction for common parameters in the presence of high-dimensional degree heterogeneity, and
- it remains operational in sparse-network settings under the paper’s convex-hull feasibility condition, substantially enlarging the set of datasets for which estimation is practically usable.
In addition, once the likelihood correction is applied, NetworkFm provides debiased plug-in estimates of average partial effects (APEs), for continuous and discrete regressors.
Estimators included
-
Likelihood correction (Yan, Li, and Zhang, 2026)
- Implements the paper’s likelihood-based adjustment for all three model classes above.
- Addresses the incidental-parameter bias and the sparse network problem (the convex-hull condition).
- Reports debiased APEs for continuous and discrete/finite-change effects.
-
Estimator-based correction (benchmarks / comparisons)
- For directed + mutual utility: estimator-based correction following Yan, Li, and Zhang (2026).
- For directed utility only: estimator-based correction following Yan et al. (2019).
- For mutual utility only / undirected networks: estimator-based correction following Graham (2017).
-
Conditional likelihood method (benchmarks / comparisons)
- Tetrad logit for undirected networks (Graham, 2017), via a vendored copy of
netrics(Graham, 2016). - Quadruple logit for directed networks without mutual utility (Jochmans, 2018), via the bundled
quadlogitpackage by Hu et al. (2026). NetworkFmexposes these methods through the samenetworkfm.fit()interface and data conventions, so users can compare likelihood correction, estimator correction, and conditional likelihood without rewriting data pipelines.
- Tetrad logit for undirected networks (Graham, 2017), via a vendored copy of
Installation
- Installation via
pip install(easiest and recommended)
pip install networkfm
- Install the development version via GitHub
git clone https://github.com/zizhongyan/networkfm.git
cd networkfm
pip install -e .
- Manual installation
Downloaded this Github source code as a ZIP file and unzipped it locally, run the following from the repository root:
cd /path/to/networkfm
pip install -e .
Quick start
import networkfm
res = networkfm.fit(
G, # the network adjacency matrix
X, Z, # covariates in directed and mutual utilities respectively
directed=True, mutual=True, # directed + mutual utility
bc_method="likelihood", # likelihood correction
algorithm="JML"
)
print(res.paras) # parameter estimates
print(res.se) # standard errors
print(res.ape) # average partial effects
Visit the project's documentation for tutorials, examples gallery, and API reference.
Dependencies
- Python ≥ 3.8
- PyTorch is required (CPU-only is fine). It is used for autograd.
- The repository bundles (vendors) several research codes used as benchmarks:
ipt(Graham, 2016) for common logit routines,netrics(Graham, 2016) for tetrad logit,quadlogitthe package Hu et al. (2025) based on the paper Jochmans (2018).
Citing NetworkFm
Please cite the paper and the software when using this package.
-
Paper: Yan, Zizhong; Li, Jingrong; Zhang, Yi (2026). “Penalized Likelihood for Dyadic Network Formation Models with Degree Heterogeneity”. arXiv e-prints, arXiv:2605.00771.
-
Software: Yan, Zizhong (2026). “NetworkFm: A Python Package for Dyadic network formation models with degree heterogeneity” (Version 0.8.1) [Computer software]. Available at
https://github.com/zizhongyan/networkfm(Accessed 14 February 2026) .
References
- Graham, Bryan S. (2016). “netrics: a Python 3.7 package for econometric analysis of networks,” (Version 0.0.1) [Computer program]. Available at https://github.com/bryangraham/netrics (Accessed 04 October 2018)
- Graham, Bryan S. (2017). “An econometric model of link formation with degree heterogeneity,” Econometrica 85 (4): 1033 - 1063
- Helpman, Elhanan, Marc Melitz, and Yona Rubinstein (2008). “Estimating Trade Flows: Trading Partners and Trading Volumes.” Quarterly Journal of Economics 123: 441–487.
- Hu, Shiran, Muyang Guo, Xinran Cheng and Xuan Zhou. (2026). “Quadlogit: Quadruple Logit Regression for Network Formation Models,” (Version 0.2.1) [Computer program]. Available at https://github.com/HuNeedHelp/quadlogit (Accessed 30 April 2026)
- Jochmans, Koen. (2018). “Semiparametric analysis of network formation.” Journal of Business & Economic Statistics 36, no. 4 (2018): 705-713.
- Yan, Ting, Binyan Jiang, Stephen E. Fienberg and Chenlei Leng. (2019). “Statistical inference in a directed network model with covariates.” Journal of the American Statistical Association 114(526), 857-868.
Code maintainer: Zizhong Yan, Institute for Economic and Social Research (IESR), Jinan University, Guangzhou, China. Email: helloyzz@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file networkfm-0.8.1.tar.gz.
File metadata
- Download URL: networkfm-0.8.1.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc92da59ef4c68107cfee8d426e6e9aa4c8df9377b40a9b8524703e60d629466
|
|
| MD5 |
25f97a4f6e243f937cbcd8712c17ae16
|
|
| BLAKE2b-256 |
175aa9cb49626665e7d7fa16d7ffc45259a99b19865cb1dfbd2295295c89e72d
|
Provenance
The following attestation bundles were made for networkfm-0.8.1.tar.gz:
Publisher:
python-publish.yml on zizhongyan/networkfm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
networkfm-0.8.1.tar.gz -
Subject digest:
bc92da59ef4c68107cfee8d426e6e9aa4c8df9377b40a9b8524703e60d629466 - Sigstore transparency entry: 1437092849
- Sigstore integration time:
-
Permalink:
zizhongyan/networkfm@83e7033492ce61a62d5f95e60332289d0ca9e221 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zizhongyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@83e7033492ce61a62d5f95e60332289d0ca9e221 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file networkfm-0.8.1-py3-none-any.whl.
File metadata
- Download URL: networkfm-0.8.1-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a64af766ee8621fc8caaab464b37de81d0d4f98dc1cf5eeb22af0cf3cfb4f9e5
|
|
| MD5 |
176e735910755e560ee5e1f7c3115e7b
|
|
| BLAKE2b-256 |
de3bbe2f88b4ba946ab5407390a4cab42f04632aa4bee50d44c1b5fc2d38c3dc
|
Provenance
The following attestation bundles were made for networkfm-0.8.1-py3-none-any.whl:
Publisher:
python-publish.yml on zizhongyan/networkfm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
networkfm-0.8.1-py3-none-any.whl -
Subject digest:
a64af766ee8621fc8caaab464b37de81d0d4f98dc1cf5eeb22af0cf3cfb4f9e5 - Sigstore transparency entry: 1437092879
- Sigstore integration time:
-
Permalink:
zizhongyan/networkfm@83e7033492ce61a62d5f95e60332289d0ca9e221 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zizhongyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@83e7033492ce61a62d5f95e60332289d0ca9e221 -
Trigger Event:
workflow_dispatch
-
Statement type: