networksns.statistical_models.tgrg_directed

networksns.statistical_models.tgrg_directed(time_series, tol=0.01, maxit=100.0)

Estimate, by an expectation-maximization algorithm, the parameters of the Temporally Generalized Random Graph model (\(TGRG\)).

In the \(TGRG\) model for directed graphs [1] , with temporal network represented by a time series of non-symmetric adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\), each node \(i\) is characterized by two latent variables, \(\theta_i^{t,in}\) and \(\theta_i^{t,out}\), both of them evolving in time by following a covariance stationary autoregressive process \(AR(1)\):

\(\phantom{aaaaaaaaaaaaaaaaaaa} \theta_i^{t, in} = \varphi_{0,i}^{in} + \varphi_{1,i}^{in} \theta_i^{t-1, in} + \epsilon_i^{t, in}\),

\(\phantom{aaaaaaaaaaaaaaaaaaa} \theta_i^{t, out} = \varphi_{0,i}^{out} + \varphi_{1,i}^{out} \theta_i^{t-1, out} + \epsilon_i^{t, out},\)

where \(\varphi_{0,i}^{in}, \varphi_{0,i}^{out}\in \mathbb{R}\), \(|\varphi_{1,i}^{in}|, |\varphi_{1,i}^{out}|<1\), and i.i.d. normal innovations \(\epsilon_i^{t, in}\sim \mathcal{N}(0, {\sigma_i^{in}}^{2})\) and \(\epsilon_i^{t, out}\sim \mathcal{N}(0, {\sigma_i^{out}}^2)\).

Then, the observation equation for the network snapshot at time \(t\) is given by \(N(N-1)\) independent Bernoulli trials whose conditional probability is:

\(\phantom{aaaaaaaaaaaaaaaaaaa}\mathbb{P}(A^t| \Theta^t) = \prod_{j\neq i} \frac{e^{A^t_{ij}(\theta_i^{t, out} + \theta_j^{t, in})}}{1 + e^{\theta_i^{t, out} + \theta_j^{t, in}}},\)

where \(\Theta^t \equiv \{\theta_i^{t, in}, \theta_i^{t, out}\}_{i = 1, \dots, n}\).

Parameters:
  • time_series (List object) – List of adjacency matrices [\(A_1, \dots, A_T\)] with binary entries and zero diagonal.

  • tol (float) – Relative error of the estimated parameters. Default: 1e-2.

  • maxit (integer) – Maximum number of iterations in the learning process. Default: 1e2.

Returns:

  • phi_0 (array) – Vector of length \(2n\) with the estimated values of \(\varphi_0\). The first \(n\) entries contain \(\varphi_0^{out}\), while the last \(n\) entries contain \(\varphi_0^{in}\).

  • phi_1 (array) – Vector of length \(2n\) with the estimated values of \(\varphi_1\). The first \(n\) entries contain \(\varphi_1^{out}\), while the last \(n\) entries contain \(\varphi_1^{in}\).

  • sigma (array) – Vector of length \(2n\) with the estimated values of \(\sigma\). The first \(n\) entries contain \(\sigma^{out}\), while the last \(n\) entries contain \(\sigma^{in}\).

  • theta_naive (array_like) – Matrix of size \(2n \times T\), that in the entry \((i, t)\) has a naive estimation of the \(\theta\) parameters. The first \(n\) rows contain the values of the \({\theta^{t}_i}^{out}\) while the last \(n\) rows contain the \({\theta^{t}_i}^{in}\).

  • theta (array_like) – Matrix of size \(2n \times T\), that in the entry \((i, t)\) has the estimation of the \(\theta\) parameters. The first \(n\) rows contain the values of the \({\theta^{t}_i}^{out}\) while the last \(n\) rows contain the \({\theta^{t}_i}^{in}\).

Examples

>>>  from networksns import statistical_models as sm
>>>  import numpy as np

Create temporal network

>>>    n = 60
>>>    T = 150
>>>    phi0 = np.ones(n) * 0.2
>>>    phi1 = np.ones(n) * 0.6
>>>    time_series = tgrg_directed_simulation(n, T, phi_0_in=phi0, phi_0_out=phi0, phi_1_in=phi1, phi_1_out=phi1)

Estimate the \(TGRG\) model parameters

>>>    phi_0, phi_1, sigma, theta_naive, theta = sm.tgrg_directed(time_series)

References