Skip to main content

networkinference is a Python 3 package implementing econometric methods for inference with data exhibiting network dependence or other forms of complex or unknown weak dependence. The package is developed by Michael P. Leung and distributed under the 3-Clause BSD license. Much of the package is based on work supported by NSF grant SES-1755100.

Installation

Install via command line using pip3, which is included with Python 3.4+:

$ pip3 install networkinference

Overview

The package contains three main classes:

  • OLS: OLS estimator.

  • TSLS: 2SLS estimator.

  • IPW: Horvitz-Thompson estimator (inverse-probability weighting estimator with known propensity scores).

Each class contains five methods for constructing confidence intervals and two methods implementing scalar equality tests. These methods are based on three classes of inference procedures. The first uses a network HAC variance estimator [1] [2]. The second constructs network clusters using spectral clustering and applies a cluster-robust inference method [4]. Both require network data and account for a general form of network dependence in which observations are less correlated when further apart in the network (in the sense of shortest path distance) [1]. The third involves resampling and can be applied to weakly dependent network, clustered, time series, or spatial data (or combination or these) without knowledge of the particular type of dependence [3] [5]. However, it is more computationally intensive and requires a larger amount of data to ensure adequate size control and power.

The methods are also available as independent functions through the core class for use with custom estimators.

The core class and utils subpackage contain various utilities for computing summary statistics, plotting the spectrum of the Laplacian, constructing friends-of-friends instruments for estimating linear-in-means models, and simulating data.

Example Usage

>>> import networkinference as ni               # main package
>>> from networkinference.utils import FakeData # utilities for generating fake data
>>> Y, X, W, A = FakeData.tsls()                # simulate data from linear-in-means model
>>> tsls = ni.TSLS(Y, X, W, A)                  # load data into tsls object
>>> tsls.network_se()                           # print estimates with network-robust SEs
>>> help(tsls)                                  # displays documentation for tsls object

References

Dependencies

  • Matplotlib v3.7+

  • NetworkX v3.0+

  • NumPy v1.24+

  • Scikit-learn v1.2+

  • SciPy v1.10+

  • Seaborn v0.12+

  • Tabulate v0.9+

Metadata

Release files for networkinference 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for networkinference 0.0.4
File Size Uploaded
networkinference-0.0.4.tar.gz 24.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for networkinference 0.0.4
File Interpreter ABI Platform
networkinference-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / networkinference-0.0.4.tar.gz

Download URL networkinference-0.0.4.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
21069425e4f607580f53a0433a9f84bc0bf25cab58db405f3d0bafaedb111082
BLAKE2b-256 checksum
How to use checksums
e130a3e8afca9c9bbf2eaf1e670ce78d9ea54042cd9d6f7a0151f7b72d79bf28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / networkinference-0.0.4-py3-none-any.whl

Download URL networkinference-0.0.4-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
feae329058eab6e90017acced06f5802374fca236291786cd5cb5d7e781febdf
BLAKE2b-256 checksum
How to use checksums
812000f56936ac3abd87943bf0ba702651f9bfba1c2d3c8b3c4145f631b4d061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page