networksns.statistical_models.tgrg¶
- networksns.statistical_models.tgrg(time_series, tol=0.01, maxit=100.0)¶
Estimate by an expectation-maximization algorithm the parameters of the Temporally Generalized Random Graph model (\(TGRG\)).
For the \(TGRG\) model [1], with temporal network is represented by a time series of adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\), each node \(i\) is described by a latent variable \(\theta_i^t\), namely the fitness of the node, which evolves over time by following a covariance stationary autoregressive process \(AR(1)\):
\(\phantom{aaaaaaaaaaaaaaaaaaa}\theta_i^t = \varphi_{0,i} + \varphi_{1,i} \theta_i^{t-1} + \epsilon_i^t\),
with \(\varphi_{0,i}\in \mathbb{R}\), \(|\varphi_{1,i}|<1\), and i.i.d. normal innovations \(\epsilon_i^t\sim \mathcal{N}(0, \sigma_i^2)\).
Then, the observation equation for the network snapshot at time \(t\) is given by \(\binom{N}{2}\) independent Bernoulli trials whose conditional probability is:
\(\phantom{aaaaaaaaaaaaaaaaaaa}\mathbb{P}(A^t| \Theta^t) = \prod_{i<j} \frac{e^{A^t_{ij}(\theta_i^t + \theta_j^t)}}{1 + e^{\theta_i^t + \theta_j^t}}\),
with \(\Theta^t \equiv \{\theta_i^t\}_{i = 1, \dots, n}\).
- Parameters:
time_series (List object) – List of symmetric 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 with the estimated values of the \({\varphi_0}_i\).
phi_1 (array) – Vector with the estimated values of \({\varphi_1}_i\),
sigma (array) – Vector with the estimated values of \(\sigma_i\),
theta_naive (array_like) – Matrix that in the entry \((i, t)\) has a naive estimation of the \(\theta_i^t\).
theta (array_like) – Matrix that in the entry \((i, t)\) has the estimated values of \(\theta_i^t\).
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_simulation(n, T, phi_0=phi0, phi_1=phi1)
Estimate the \(TGRG\) model parameters
>>> phi_0, phi_1, sigma, theta_naive, theta = sm.tgrg(time_series)
References