Learn R Programming

netdiffuseR (version 1.17.0)

toa_mat: Time of adoption matrix

Description

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.

Usage

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 x T$

Details

In order to be able to work with time ranges other than $1,..., 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).

Examples

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

toa_mat(times)

# Now, suppose that we observe the graph from 2000 to 2006
toa_mat(times, t0=2000, t1=2006)

Run the code above in your browser using DataLab