# 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)
# For multiple behaviors, the input can be a matrix..
times_1 <- c(2001L, 2004L, 2003L, 2008L)
times_2 <- c(2001L, 2005L, 2006L, 2008L)
times <- matrix(c(times_1, times_2), nrow = 4, ncol = 2)
toa <- toa_mat(times)
toa[[1]]$adopt # time period of adoption for the first behavior
#.. or a diffnet object
graph <- lapply(2001:2008, function(x) rgraph_er(4))
diffnet <- new_diffnet(graph, times)
toa <- toa_mat(diffnet)
toa[[1]]$cumadopt # cumulative adoption matrix for the first behavior
Run the code above in your browser using DataLab