Creates two matrices recording times of adoption of the innovation. One matrix records the time period of adoption for each node with zeros elsewhere. The second records the cumulative time of adoption such that there are ones for the time of adoption and every time period thereafter.

toa_mat(obj, labels = NULL, t0 = NULL, t1 = NULL)

Arguments

obj

Either an integer vector of size \(n\) containing time of adoption of the innovation, or a diffnet object.

labels

Character vector of size \(n\). Labels (ids) of the vertices.

t0

Integer scalar. Sets the lower bound of the time window (e.g. 1955).

t1

Integer scalar. Sets the upper bound of the time window (e.g. 2000).

Value

A list of two \(n \times T\)

cumadopt

has 1's for all years in which a node indicates having the innovation.

adopt

has 1's only for the year of adoption and 0 for the rest.

Details

In order to be able to work with time ranges other than \(1,\dots, T\) the function receives as input the boundary labels of the time windows through the variables t0 and t. While by default the function assumes that the the boundaries are given by the range of the times vector, the user can set a personalized time range exceeding the one given by the times vector. For instance, times of adoption may range between 2001 and 2005 but the actual data, the network, is observed between 2000 and 2005 (so there is not left censoring in the data), hence, the user could write:


adopmats <- toa_mat(times, t0=2000, t1=2005)

That way the resulting cumadopt and adopt matrices would have 2005 - 2000 + 1 = 6 columns instead of 2005 - 2001 + 1 = 5 columns, with the first column of the two matrices containing only zeros (as the first adoption happend after the year 2000).

Author

George G. Vega Yon & Thomas W. Valente

Examples

# Random set of times of adoptions
times <- sample(c(NA, 2001:2005), 10, TRUE)

toa_mat(times)
#> $adopt
#>    2001 2002 2003 2004 2005
#> 1     0    0    0    0    1
#> 2     0    0    0    0    0
#> 3     1    0    0    0    0
#> 4     0    1    0    0    0
#> 5     0    0    0    1    0
#> 6     0    1    0    0    0
#> 7     0    1    0    0    0
#> 8     0    0    0    0    0
#> 9     0    0    1    0    0
#> 10    0    0    0    0    0
#> 
#> $cumadopt
#>    2001 2002 2003 2004 2005
#> 1     0    0    0    0    1
#> 2     0    0    0    0    0
#> 3     1    1    1    1    1
#> 4     0    1    1    1    1
#> 5     0    0    0    1    1
#> 6     0    1    1    1    1
#> 7     0    1    1    1    1
#> 8     0    0    0    0    0
#> 9     0    0    1    1    1
#> 10    0    0    0    0    0
#> 

# Now, suppose that we observe the graph from 2000 to 2006
toa_mat(times, t0=2000, t1=2006)
#> $adopt
#>    2000 2001 2002 2003 2004 2005 2006
#> 1     0    0    0    0    0    1    0
#> 2     0    0    0    0    0    0    0
#> 3     0    1    0    0    0    0    0
#> 4     0    0    1    0    0    0    0
#> 5     0    0    0    0    1    0    0
#> 6     0    0    1    0    0    0    0
#> 7     0    0    1    0    0    0    0
#> 8     0    0    0    0    0    0    0
#> 9     0    0    0    1    0    0    0
#> 10    0    0    0    0    0    0    0
#> 
#> $cumadopt
#>    2000 2001 2002 2003 2004 2005 2006
#> 1     0    0    0    0    0    1    1
#> 2     0    0    0    0    0    0    0
#> 3     0    1    1    1    1    1    1
#> 4     0    0    1    1    1    1    1
#> 5     0    0    0    0    1    1    1
#> 6     0    0    1    1    1    1    1
#> 7     0    0    1    1    1    1    1
#> 8     0    0    0    0    0    0    0
#> 9     0    0    0    1    1    1    1
#> 10    0    0    0    0    0    0    0
#>