Skip to main content

Econometric methods for the analysis of networks.

Project description

netrics: a Python 2.7 package for econometric analysis of networks

by Bryan S. Graham, UC - Berkeley, e-mail: bgraham@econ.berkeley.edu

This package includes a Python 2.7 implementation of the two econometric network formation models introduced in Graham (2014, NBER).

This package is offered “as is”, without warranty, implicit or otherwise. While I would appreciate bug reports, suggestions for improvements and so on, I am unable to provide any meaningful user-support. Please e-mail me at bgraham@econ.berkeley.edu

Please cite both the code and the underlying source articles listed below when using this code in your research.

A simple example script to get started is:

>>>> # Import numpy in order to correctly read test data
>>>> import numpy as np

>>>> # Import urllib in order to download test data from Github repo
>>>> import urllib

>>>> # Append location of netrics module base directory to system path
>>>> # NOTE: only required if permanent install not made
>>>> # NOTE: edit path to location on netrics package on local machine
>>>> import sys
>>>> sys.path.append('/Users/bgraham/Dropbox/Sites/software/netrics/')

>>>> # Load netrics module
>>>> import netrics as netrics

>>>> # Download Nyakatoke test dataset from GitHub
>>>> download =  '/Users/bgraham/Dropbox/' # Edit to location on your machine
>>>> url = 'https://github.com/bryangraham/netrics/blob/master/Notebooks/Nyakatoke_Example.npz?raw=true'
>>>> urllib.urlretrieve(url, download + "Nyakatoke_Example.npz")

>>>> # Open dataset
>>>> NyakatokeTestDataset = np.load(download + "Nyakatoke_Example.npz")

>>>> # Extract adjacency matrix
>>>> D = NyakatokeTestDataset['D']

>>>> # Initialize list of dyad-specific covariates as elements
>>>> # W = [W0, W1, W2,...WK-1]
>>>> W = []

>>>> # Initialize list with covariate labels
>>>> cov_names = []

>>>> # Construct list of regressor matrices and corresponding variable names
>>>> for matrix in NyakatokeTestDataset.files:
>>>>     if matrix != 'D':
>>>>         W.append(NyakatokeTestDataset[matrix])
>>>>         cov_names.append(matrix)

>>>> # Apply tetrad logit procedure to dataset
>>>> [beta_TL, vcov_beta_TL, tetrad_frac_TL, success] = \
         netrics.tetrad_logit(D, W, dtcon=None, silent=False, W_names=cov_names)

CODE CITATION

Graham, Bryan S. (2016). “netrics: a Python 2.7 package for econometric analysis of

networks,” (Version 0.0.1) [Computer program]. Available at https://github.com/bryangraham/netrics (Accessed 04 September 2016)

PAPER CITATIONS

Graham, Bryan S. (2014). “An econometric model of link formation with degree

heterogeneity,” NBER Working Paper No. w20341.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netrics-0.0.4.tar.gz (15.7 kB view details)

Uploaded Source

File details

Details for the file netrics-0.0.4.tar.gz.

File metadata

  • Download URL: netrics-0.0.4.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for netrics-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f49388486488ad0383aed5b980416c3bd0eb441c5ac679f0c38da73e7b10cc75
MD5 20d6cf9947fd95ce77350212ac2834a1
BLAKE2b-256 4d05fd42bfc12e4b645ecea46f53e138721a4f8dea86ea1bdd6f4cc60e4ce257

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page