R/select_egoalter.R
select_egoalter.Rd
This function calculates the 16 possible configurations between ego and alter
over two time points in terms of their behavior and tie changes. From time
one to time two, given a binary state of behavior, ego and alter can be
related in 16 different ways. The function adopt_changes
is just an
alias for select_egoalter
.
select_egoalter(graph, adopt, period = NULL)
adopt_changes(graph, adopt, period = NULL)
# S3 method for class 'diffnet_adoptChanges'
summary(object, ...)
A dynamic graph (see netdiffuseR-graphs
).
\(n\times T\) matrix. Cumulative adoption matrix obtained from toa_mat
.
Integer scalar. Optional to make the count for a particular period of time.
An object of class diffnet_adoptChanges
.
Ignored.
An object of class diffnet_adoptChanges
and data.frame
with \(n\times (T-1)\) rows and \(2 + 16\times 3\)
columns. The column names are:
time
Integer represting the time period
id
Node id
select_a_01
, ..., select_a_16
Number of new links classified between categories 1 to 16.
select_d_01
, ..., select_d_16
Number of remove links classified between categories 1 to 16.
select_s_01
, ..., select_s_16
Number of unchanged links classified between categories 1 to 16.
The 16 possibilities are summarized in this matrix:
Alter | ||||||
\(t-1\) | No | Yes | ||||
\(t-1\) | \(t\) | No | Yes | No | Yes | |
Ego | No | No | 1 | 2 | 9 | 10 |
Yes | 3 | 4 | 11 | 12 | ||
Yes | No | 5 | 6 | 13 | 14 | |
Yes | 7 | 8 | 15 | 16 |
The first two Yes/No columns represent Ego's adoption of the innovation in \(t-1\) and \(t\); while the first two Yes/No rows represent Alter's adoption of the innovation in \(t-1\) and t respectively. So for example, number 4 means that while neither of the two had addopted the innovation in \(t-1\), both have in \(t\). At the same time, number 12 means that ego adopted the innovation in \(t\), but alter had already adopted in \(t-1\) (so it has it in both, \(t\) and \(t-1\)).
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 doi:10.1016/j.socscimed.2015.10.001
# Simple example ------------------------------------------------------------
set.seed(1312)
dn <- rdiffnet(20, 5, seed.graph="small-world")
#> Warning: The option -copy.first- is set to TRUE. In this case, the first graph will be treated as a baseline, and thus, networks after T=1 will be replaced with T-1.
ans <- adopt_changes(dn)
str(ans)
#> Classes ‘diffnet_adoptChanges’ and 'data.frame': 80 obs. of 50 variables:
#> $ time : chr "2" "2" "2" "2" ...
#> $ id : int 1 2 3 4 5 6 7 8 9 10 ...
#> $ select_a_01: int 0 0 0 0 0 0 0 0 0 1 ...
#> $ select_a_02: int 0 0 0 0 0 1 0 0 0 0 ...
#> $ select_a_03: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_04: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_05: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_06: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_07: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_08: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_09: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_10: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_11: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_12: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_13: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_14: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_15: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_a_16: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_01: int 0 0 0 0 0 1 0 0 0 1 ...
#> $ select_d_02: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_03: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_04: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_05: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_06: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_07: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_08: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_09: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_10: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_11: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_12: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_13: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_14: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_15: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_d_16: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_01: int 2 2 2 2 2 1 2 2 2 0 ...
#> $ select_s_02: int 0 0 0 0 0 0 0 0 0 1 ...
#> $ select_s_03: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_04: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_05: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_06: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_07: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_08: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_09: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_10: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_11: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_12: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_13: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_14: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_15: int 0 0 0 0 0 0 0 0 0 0 ...
#> $ select_s_16: int 0 0 0 0 0 0 0 0 0 0 ...
summary(ans)
#> $`added (a)`
#> $`added (a)`$`period 2`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 1 1
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`added (a)`$`period 3`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 2 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 1 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`added (a)`$`period 4`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 3 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 1 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`added (a)`$`period 5`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 9 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#>
#> $`removed (d)`
#> $`removed (d)`$`period 2`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 2 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`removed (d)`$`period 3`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 1 0
#> Ego|No (t-1)|Yes (t) 1 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 1 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`removed (d)`$`period 4`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 3 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 1 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`removed (d)`$`period 5`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 9 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#>
#> $`unchanged (s)`
#> $`unchanged (s)`$`period 2`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 32 1
#> Ego|No (t-1)|Yes (t) 1 0
#> Ego|Yes (t-1)|No (t) 1 1
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 1 0
#> Ego|No (t-1)|Yes (t) 1 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`unchanged (s)`$`period 3`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 30 2
#> Ego|No (t-1)|Yes (t) 1 0
#> Ego|Yes (t-1)|No (t) 2 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 2 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`unchanged (s)`$`period 4`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 33 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 1 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 2 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#> $`unchanged (s)`$`period 5`
#> Alter|No (t-1)|No (t) Alter|No (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 31 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#> Alter|Yes (t-1)|No (t) Alter|Yes (t-1)|Yes (t)
#> Ego|No (t-1)|No (t) 0 0
#> Ego|No (t-1)|Yes (t) 0 0
#> Ego|Yes (t-1)|No (t) 0 0
#> Ego|Yes (t-1)|Yes (t) 0 0
#>
#>