networksns.statistical_models.cdarn¶
- networksns.statistical_models.cdarn(time_series, p, B, z_p='uniform', model_cross='neighbors', q='global', y='global', kernel=None, bandwidth=None)¶
Simulate a temporal network following the \(CDARN(p)\) model.
The \(CDARN(p)\) model [1] is a generalization of the \(DARN(p)\) model where also cross-correlations between links are taken into account.
For a temporal network described by a time series of adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\) the \(CDARN(p)\) model describes the state \(A^{t}_{ij}\) of the link \((i,j)\) at time \(t\) with the following copying mechanism: (i) with probability \(q_{ij}\), the link is copied from a past state of a link in the backbone \(B\) chosen by an assigned probability distribution, (ii) then the lag is selected with probability \(z_i\) with \(i=1,\ldots,p\), where \(p\) represents the order of the memory, (iii) while with probability \(1-q_{ij}\), it is sampled with (marginal) probability \(y_{ij}\).
In other words, the state \(A_{ij}^t\) of the link \((i,j)\) is described by the following stochastic process at discrete time
\(\phantom{aaaaaaaaaaaaaaaaaaa}A^{t}_{ij}= Q^{t}_{ij} A^{t-Z_p^{t}}_{M_{ij}^t} + (1-Q^{t}_{ij}) Y^{t}_{ij}\)
with \(Q_{ij}^t\sim B(q_{ij})\) Bernoulli variable, \(M_{ij}\) random variable picking values between the links in the backbone of \((i,j)\), \(Z_p^t\) is a random variable picking values from \(1\) to \(p\) with probability \(z_i\) \(i=1,\ldots,p\), respectively, and \(Y_{ij}^t\sim B(y_{ij})\) is a Bernoulli variable.
The random variable \(M_{ij}^t\) depends both on the coupling model and the constant \(c\):
Local Cross Correlation (LCC): \(M_{ij}^t\) picks \((i,j)\) with probability \(1-c\) and any other link in the neighbourhood \(\partial B_{ij}\) of \((i,j)\) with probability \(\frac{c}{|\partial B_{ij}|}\).
Uniform Cross Correlation (UCC): \(M_{ij}^t\) picks \((i,j)\) with probability \(1-c\) and any other link in the backbone \(B\) of \((i,j)\) with probability \(\frac{c}{|B-1|}\).
Here \(|\partial B_{ij}|\) and \(|B-1|\) denote the number of links adjacent to \((i,j)\) and the number of links in the backbone different from \((i, j)\), respectively.
In the case of local likelihood estimation, the (global) parameters are time-varying, i.e. \(\{q^t,c^t,y^t\}_{t=1,\ldots,s}\).
- Parameters:
time_series (List object) – List of symmetric matrices [\(A_0, A_1, \dots, A_T\)].
p (integer) – Markov order.
B (array_like) – Symmetric matrix. Backbone of the temporal graph.
z_p (array/string, optional) –
stochastic array of length \(p\) representing the memory distribution \(Z_p\). Default:
'uniform'. Possible strings:'uniform': \(Z_p = (\frac{1}{p}, \dots, \frac{1}{p}\)),'exponential': \(Z_p = \frac{(1, e^{-1}, \dots, e^{-p+1})}{\left|\left|(1, e^{-1}, \dots, e^{-p+1}\right|\right|_2)}\)'normal': let \(f(x)=\frac{e^{-(x-1)^2/2}}{\sqrt{2\pi}}\) then \(Z_p = \frac{(f(0), \dots, f(p-1))}{\left|\left|(f(0), \dots, f(p-1))\right|\right|}\)
model_cross (string, optional) – Type of cross correlation. When
'neighbors'links are coupled to all other neighbouring links in the network backbone with equal strength (LCC), when'all'links are coupled to all other links in the backbone with equal strength (UCC). Default:'neighbors'.q (string, optional) – Probability of copying from the past. If
'global'the probability does not depend on the link, if'local'it depends on the link. Default:'global'.y (string, optional) – Link density. If
'global'the density does not depend on the link, if'local'it depends on the link. Default:'global'.kernel (string, optional) – If not None parameters are time dependent. Default: None. Possible values:
'epanechnikov','gaussian'.bandwidth (integer, optional) – Needed only when kernel is not None; bandwidth of the kernel.
- Returns:
q (float/array_like) – Probability parameter of copying from the past. Float when \(q\) is
'global'and time independent, array when is'global'and time dependent and symmetric matrix when \(q\) is'local'.c (float/array_like) – Cross correlation parameter. Float when \(c\) is time independent, array when is time dependent.
y (float/array_like) – Link density parameter. Float when \(y\) is
'global'and time independent, array when is'global'and time dependent and symmetric matrix when \(y\) is'local'.
Examples
>>> from networksns import statistical_models as sm >>> import numpy as np
Create temporal network
>>> p = 3 >>> Q = (np.ones((n, n)) - np.diag(np.ones(n))) * 0.5 >>> c = 0.4 >>> Y = (np.ones((n, n)) - np.diag(np.ones(n))) * 0.3 >>> B = (np.ones((n, n)) - np.diag(np.ones(n))) >>> n = 50 >>> s = 100 >>> time_series = sm.cdarn_simulation(p, Q, c, Y, B, n, s)
Estimate the \(CDARN(p)\) model parameters
>>> q, c, y = sm.cdarn(time_series, p, B)
References