networkinference.utils.tools.nhbr_mean

Returns array where the ith entry is the average X of network neighbors at a certain distance from node i.

This is used, for example, to create a data matrix for estimating linear-in-means models. For distance=2, this returns the average X of network two-neighbors / friends-of-friends, a common instrument used for estimating linear-in-means models (see [1], [2]). Note: the function converts the network to an unweighted, undirected version by dropping edge weights and directionality of links.

Parameters

Xnumpy array

n-dimensional array of scalar observations or an n x k matrix of n k-dimensional observations.

ANetworkX graph

Network on n nodes. Can be weighted or directed. NOTE: Assumes nodes are labeled 0 through n-1, so that the data for node i is given by the ith component of X.

weightstring

Label of edge weights in A, if A is a weighted graph. Default value: None.

Returns

Xbarnumpy array

n-dimensional array of scalar observations or an n x k matrix of n k-dimensional observations, where the ith row is the average X of i’s friends.

Examples

>>> from networkinference.utils import FakeData, nhbr_mean
>>> import numpy as np
>>> A = FakeData.erdos_renyi()
>>> X = np.random.normal(100)
>>> Xbar = nhbr_mean(X, A)

References

1

Bramoullé, Y., H. Djebbari, and B. Fortin, “Identification of Peer Effects Through Social Networks,” Journal of Econometrics, 2009, 150 (1), 41-55.

2

De Giorgi, G., M. Pellizzari, and S. Redaelli, “Identification of Social Interactions Through Partially Overlapping Peer Groups,” American Economic Journal: Applied Economics, 2010, 2 (2), 241-75.