Calculates infectiousness and susceptibility for each node in the graph
infection( graph, toa, t0 = NULL, normalize = TRUE, K = 1L, r = 0.5, expdiscount = FALSE, valued = getOption("diffnet.valued", FALSE), outgoing = getOption("diffnet.outgoing", TRUE) ) susceptibility( graph, toa, t0 = NULL, normalize = TRUE, K = 1L, r = 0.5, expdiscount = FALSE, valued = getOption("diffnet.valued", FALSE), outgoing = getOption("diffnet.outgoing", TRUE) )
graph | A dynamic graph (see |
---|---|
toa | Integer vector of length \(n\) with the times of adoption. |
t0 | Integer scalar. See |
normalize | Logical. Whether or not to normalize the outcome |
K | Integer scalar. Number of time periods to consider |
r | Numeric scalar. Discount rate used when |
expdiscount | Logical scalar. When TRUE, exponential discount rate is used (see details). |
valued | Logical scalar. When |
outgoing | Logical scalar. When |
A numeric column vector (matrix) of size \(n\) with either infection/susceptibility rates.
Normalization, normalize=TRUE
, is applied by dividing the
resulting number from the infectiousness/susceptibility stat
by the number of individuals who adopted the innovation at
time \(t\).
Given that node \(i\) adopted the innovation in time \(t\), its Susceptibility is calculated as follows
$$S_i = \frac{% \sum_{k=1}^K\sum_{j=1}^n x_{ij(t-k+1)}z_{j(t-k)}\times \frac{1}{w_k}}{% \sum_{k=1}^K\sum_{j=1}^n x_{ij(t-k+1)}z_{j(1\leq t \leq t-k)} \times \frac{1}{w_k} }\qquad \mbox{for }i,j=1,\dots,n\quad i\neq j$$
where \(x_{ij(t-k+1)}\) is 1 whenever there's a link from \(i\) to \(j\) at time \(t-k+1\), \(z_{j(t-k)}\) is 1 whenever individual \(j\) adopted the innovation at time \(t-k\), \(z_{j(1\leq t \leq t-k)}\) is 1 whenever \(j\) had adopted the innovation up to \(t-k\), and \(w_k\) is the discount rate used (see below).
Similarly, infectiousness is calculated as follows
$$I_i = \frac{% \sum_{k=1}^K \sum_{j=1}^n x_{ji(t+k-1)}z_{j(t+k)}\times \frac{1}{w_k}}{% \sum_{k=1}^K \sum_{j=1}^n x_{ji(t+k-1)}z_{j(t+k\leq t \leq T)}\times \frac{1}{w_k} }\qquad \mbox{for }i,j=1,\dots,n\quad i\neq j$$
It is worth noticing that, as we can see in the formulas, while susceptibility is from alter to ego, infection is from ego to alter.
When outgoing=FALSE
the algorithms are based on incoming edges, this is
the adjacency matrices are transposed swapping the indexes \((i,j)\) by
\((j,i)\). This can be useful for some users.
Finally, by default both are normalized by the number of individuals who
adopted the innovation in time \(t-k\). Thus, the resulting formulas,
when normalize=TRUE
, can be rewritten as
$$% S_i' = \frac{S_i}{\sum_{k=1}^K\sum_{j=1}^nz_{j(t-k)}\times \frac{1}{w_k}} % \qquad I_i' = \frac{I_i}{\sum_{k=1}^K\sum_{j=1}^nz_{j(t-k)} \times\frac{1}{w_k}}$$
For more details on these measurements, please refer to the vignette titled Time Discounted Infection and Susceptibility.
Discount rate, \(w_k\) in the formulas above, can be either exponential
or linear. When expdiscount=TRUE
, \(w_k = (1 + r)^{k-1}\), otherwise
it will be \(w_k = k\).
Note that when \(K=1\), the above formulas are equal to the ones presented in Valente et al. (2015).
Thomas W. Valente, Stephanie R. Dyal, Kar-Hai Chu, Heather Wipfli, Kayo Fujimoto Diffusion of innovations theory applied to global tobacco control treaty ratification, Social Science & Medicine, Volume 145, November 2015, Pages 89-97, ISSN 0277-9536 http://dx.doi.org/10.1016/j.socscimed.2015.10.001
Myers, D. J. (2000). The Diffusion of Collective Violence: Infectiousness, Susceptibility, and Mass Media Networks. American Journal of Sociology, 106(1), 173–208. https://doi.org/10.1086/303110
The user can visualize the distribution of both statistics
by using the function plot_infectsuscep
Other statistics:
bass
,
classify_adopters()
,
cumulative_adopt_count()
,
dgr()
,
ego_variance()
,
exposure()
,
hazard_rate()
,
moran()
,
struct_equiv()
,
threshold()
,
vertex_covariate_dist()
# Creating a random dynamic graph set.seed(943) graph <- rgraph_er(n=100, t=10) toa <- sample.int(10, 100, TRUE) # Computing infection and susceptibility (K=1) infection(graph, toa)#> infection #> 1 0.00000000 #> 2 0.00000000 #> 3 0.00000000 #> 4 0.00000000 #> 5 0.08333333 #> 6 0.00000000 #> 7 0.00000000 #> 8 0.03030303 #> 9 0.00000000 #> 10 0.00000000 #> 11 0.00000000 #> 12 0.00000000 #> 13 0.00000000 #> 14 0.00000000 #> 15 0.00000000 #> 16 0.00000000 #> 17 0.00000000 #> 18 0.00000000 #> 19 0.00000000 #> 20 0.00000000 #> 21 0.00000000 #> 22 0.09090909 #> 23 0.10000000 #> 24 0.00000000 #> 25 0.00000000 #> 26 0.00000000 #> 27 0.00000000 #> 28 0.00000000 #> 29 0.00000000 #> 30 0.00000000 #> 31 0.00000000 #> 32 0.00000000 #> 33 0.00000000 #> 34 0.00000000 #> 35 0.00000000 #> 36 0.00000000 #> 37 0.00000000 #> 38 0.00000000 #> 39 0.09090909 #> 40 0.00000000 #> 41 0.00000000 #> 42 0.09090909 #> 43 0.00000000 #> 44 0.00000000 #> 45 0.00000000 #> 46 0.00000000 #> 47 0.00000000 #> 48 0.08333333 #> 49 0.00000000 #> 50 0.00000000 #> 51 0.00000000 #> 52 0.00000000 #> 53 0.00000000 #> 54 0.00000000 #> 55 0.09090909 #> 56 0.00000000 #> 57 0.00000000 #> 58 0.00000000 #> 59 0.00000000 #> 60 0.00000000 #> 61 0.00000000 #> 62 0.00000000 #> 63 0.00000000 #> 64 0.00000000 #> 65 0.00000000 #> 66 0.00000000 #> 67 0.00000000 #> 68 0.00000000 #> 69 0.00000000 #> 70 0.00000000 #> 71 0.00000000 #> 72 0.00000000 #> 73 0.00000000 #> 74 0.00000000 #> 75 0.00000000 #> 76 0.00000000 #> 77 0.00000000 #> 78 0.00000000 #> 79 0.00000000 #> 80 0.00000000 #> 81 0.04545455 #> 82 0.00000000 #> 83 0.00000000 #> 84 0.00000000 #> 85 0.00000000 #> 86 0.00000000 #> 87 0.00000000 #> 88 0.00000000 #> 89 0.00000000 #> 90 0.00000000 #> 91 0.00000000 #> 92 0.00000000 #> 93 0.00000000 #> 94 0.00000000 #> 95 0.03571429 #> 96 0.00000000 #> 97 0.00000000 #> 98 0.00000000 #> 99 0.00000000 #> 100 0.00000000susceptibility(graph, toa)#> susceptibility #> 1 0.00000000 #> 2 0.04545455 #> 3 0.00000000 #> 4 0.00000000 #> 5 0.00000000 #> 6 0.00000000 #> 7 0.00000000 #> 8 0.16666667 #> 9 0.00000000 #> 10 0.04545455 #> 11 0.00000000 #> 12 0.00000000 #> 13 0.00000000 #> 14 0.00000000 #> 15 0.00000000 #> 16 0.03030303 #> 17 0.00000000 #> 18 0.00000000 #> 19 0.00000000 #> 20 0.00000000 #> 21 0.00000000 #> 22 0.09090909 #> 23 0.00000000 #> 24 0.00000000 #> 25 0.00000000 #> 26 0.00000000 #> 27 0.00000000 #> 28 0.00000000 #> 29 0.00000000 #> 30 0.00000000 #> 31 0.00000000 #> 32 0.00000000 #> 33 0.08333333 #> 34 0.00000000 #> 35 0.00000000 #> 36 0.00000000 #> 37 0.16666667 #> 38 0.00000000 #> 39 0.00000000 #> 40 0.00000000 #> 41 0.00000000 #> 42 0.00000000 #> 43 0.00000000 #> 44 0.00000000 #> 45 0.00000000 #> 46 0.00000000 #> 47 0.00000000 #> 48 0.00000000 #> 49 0.00000000 #> 50 0.00000000 #> 51 0.10000000 #> 52 0.12500000 #> 53 0.08333333 #> 54 0.00000000 #> 55 0.00000000 #> 56 0.00000000 #> 57 0.00000000 #> 58 0.00000000 #> 59 0.00000000 #> 60 0.00000000 #> 61 0.00000000 #> 62 0.00000000 #> 63 0.00000000 #> 64 0.00000000 #> 65 0.00000000 #> 66 0.00000000 #> 67 0.00000000 #> 68 0.00000000 #> 69 0.00000000 #> 70 0.00000000 #> 71 0.00000000 #> 72 0.00000000 #> 73 0.00000000 #> 74 0.00000000 #> 75 0.00000000 #> 76 0.00000000 #> 77 0.00000000 #> 78 0.00000000 #> 79 0.00000000 #> 80 0.00000000 #> 81 0.00000000 #> 82 0.00000000 #> 83 0.00000000 #> 84 0.00000000 #> 85 0.00000000 #> 86 0.00000000 #> 87 0.00000000 #> 88 0.00000000 #> 89 0.04166667 #> 90 0.00000000 #> 91 0.00000000 #> 92 0.00000000 #> 93 0.00000000 #> 94 0.00000000 #> 95 0.00000000 #> 96 0.00000000 #> 97 0.00000000 #> 98 0.00000000 #> 99 0.00000000 #> 100 0.00000000# Now with K=4 infection(graph, toa, K=4)#> infection #> 1 0.000000000 #> 2 0.014705882 #> 3 0.000000000 #> 4 0.000000000 #> 5 0.044117647 #> 6 0.000000000 #> 7 0.000000000 #> 8 0.013574661 #> 9 0.000000000 #> 10 0.047430830 #> 11 0.000000000 #> 12 0.000000000 #> 13 0.000000000 #> 14 0.000000000 #> 15 0.000000000 #> 16 0.044117647 #> 17 0.005161290 #> 18 0.000000000 #> 19 0.060000000 #> 20 0.000000000 #> 21 0.000000000 #> 22 0.047430830 #> 23 0.064516129 #> 24 0.000000000 #> 25 0.000000000 #> 26 0.000000000 #> 27 0.000000000 #> 28 0.000000000 #> 29 0.000000000 #> 30 0.000000000 #> 31 0.000000000 #> 32 0.000000000 #> 33 0.000000000 #> 34 0.000000000 #> 35 0.000000000 #> 36 0.000000000 #> 37 0.007102693 #> 38 0.016189962 #> 39 0.090909091 #> 40 0.000000000 #> 41 0.000000000 #> 42 0.047430830 #> 43 0.000000000 #> 44 0.000000000 #> 45 0.000000000 #> 46 0.060000000 #> 47 0.013389536 #> 48 0.044117647 #> 49 0.000000000 #> 50 0.000000000 #> 51 0.000000000 #> 52 0.000000000 #> 53 0.000000000 #> 54 0.000000000 #> 55 0.029411765 #> 56 0.011857708 #> 57 0.000000000 #> 58 0.000000000 #> 59 0.000000000 #> 60 0.000000000 #> 61 0.000000000 #> 62 0.000000000 #> 63 0.000000000 #> 64 0.000000000 #> 65 0.000000000 #> 66 0.000000000 #> 67 0.000000000 #> 68 0.000000000 #> 69 0.000000000 #> 70 0.000000000 #> 71 0.000000000 #> 72 0.000000000 #> 73 0.000000000 #> 74 0.000000000 #> 75 0.000000000 #> 76 0.000000000 #> 77 0.000000000 #> 78 0.000000000 #> 79 0.000000000 #> 80 0.000000000 #> 81 0.014746544 #> 82 0.000000000 #> 83 0.000000000 #> 84 0.000000000 #> 85 0.000000000 #> 86 0.000000000 #> 87 0.012951970 #> 88 0.000000000 #> 89 0.000000000 #> 90 0.000000000 #> 91 0.000000000 #> 92 0.018972332 #> 93 0.007339450 #> 94 0.000000000 #> 95 0.022041097 #> 96 0.009174312 #> 97 0.004744958 #> 98 0.047430830 #> 99 0.000000000 #> 100 0.000000000susceptibility(graph, toa, K=4)#> susceptibility #> 1 0.006243496 #> 2 0.024793388 #> 3 0.000000000 #> 4 0.000000000 #> 5 0.000000000 #> 6 0.000000000 #> 7 0.000000000 #> 8 0.066666667 #> 9 0.023529412 #> 10 0.022727273 #> 11 0.000000000 #> 12 0.066666667 #> 13 0.000000000 #> 14 0.008538899 #> 15 0.005376344 #> 16 0.016528926 #> 17 0.000000000 #> 18 0.000000000 #> 19 0.025210084 #> 20 0.000000000 #> 21 0.000000000 #> 22 0.045454545 #> 23 0.000000000 #> 24 0.000000000 #> 25 0.000000000 #> 26 0.000000000 #> 27 0.000000000 #> 28 0.000000000 #> 29 0.000000000 #> 30 0.000000000 #> 31 0.000000000 #> 32 0.000000000 #> 33 0.029411765 #> 34 0.000000000 #> 35 0.000000000 #> 36 0.000000000 #> 37 0.166666667 #> 38 0.000000000 #> 39 0.000000000 #> 40 0.000000000 #> 41 0.000000000 #> 42 0.000000000 #> 43 0.012396694 #> 44 0.000000000 #> 45 0.000000000 #> 46 0.000000000 #> 47 0.000000000 #> 48 0.000000000 #> 49 0.000000000 #> 50 0.000000000 #> 51 0.036290323 #> 52 0.049382716 #> 53 0.035294118 #> 54 0.027272727 #> 55 0.000000000 #> 56 0.000000000 #> 57 0.000000000 #> 58 0.000000000 #> 59 0.022058824 #> 60 0.000000000 #> 61 0.000000000 #> 62 0.000000000 #> 63 0.000000000 #> 64 0.000000000 #> 65 0.000000000 #> 66 0.000000000 #> 67 0.000000000 #> 68 0.000000000 #> 69 0.000000000 #> 70 0.000000000 #> 71 0.000000000 #> 72 0.000000000 #> 73 0.049586777 #> 74 0.012096774 #> 75 0.000000000 #> 76 0.044117647 #> 77 0.042704626 #> 78 0.003023432 #> 79 0.000000000 #> 80 0.049586777 #> 81 0.058823529 #> 82 0.000000000 #> 83 0.000000000 #> 84 0.011029412 #> 85 0.000000000 #> 86 0.000000000 #> 87 0.000000000 #> 88 0.000000000 #> 89 0.018575851 #> 90 0.000000000 #> 91 0.000000000 #> 92 0.000000000 #> 93 0.000000000 #> 94 0.000000000 #> 95 0.000000000 #> 96 0.000000000 #> 97 0.000000000 #> 98 0.000000000 #> 99 0.000000000 #> 100 0.000000000