# infection: Susceptibility and Infection In netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks

## Description

Calculates infectiousness and susceptibility for each node in the graph

## Usage

 ```1 2 3 4 5 6 7``` ```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)) ```

## Arguments

 `graph` A dynamic graph (see `netdiffuseR-graphs`). `toa` Integer vector of length n with the times of adoption. `t0` Integer scalar. See `toa_mat`. `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=TRUE` `expdiscount` Logical scalar. When TRUE, exponential discount rate is used (see details). `valued` Logical scalar. When `TRUE` weights will be considered. Otherwise non-zero values will be replaced by ones. `outgoing` Logical scalar. When `TRUE`, computed using outgoing ties.

## Details

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) = [∑_k ∑_j (x(ij,t-k+1) * z(j,t-k))/w(k)]/[∑_k ∑_j (x(ij,t-k+1) * z(j, 1<=t<=t-k))/w(k)] for j != i

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<=t<=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) = [∑_k ∑_j (x(ji,t) * z(j,t+1))/w(k)]/[∑_k ∑_j (x(ji,t) * z(j, t+1<=t<=T))/w(k)] for j != i

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)' = S(i)/[∑_k ∑_j z(j,t-k)/w(k)] I(i)' = I(i)/[∑_k ∑_j z(j,t-k)/w(k)]

For more details on these measurements, please refer to the vignette titled Time Discounted Infection and Susceptibility.

## Value

A numeric column vector (matrix) of size n with either infection/susceptibility rates.

## Discount rate

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).

## Author(s)

George G. Vega Yon

## References

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`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```# 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) susceptibility(graph, toa) # Now with K=4 infection(graph, toa, K=4) susceptibility(graph, toa, K=4) ```