# For a single behavior -----------------------------------------------------
# Generating a random vector of time
set.seed(123)
times <- sample(2000:2005, 10, TRUE)
# Computing the TOA differences
toa_diff(times)
# For Q=2 behaviors ---------------------------------------------------------
# Generating a matrix time
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)
# Computing the TOA differences
toa_diff(times)
# Or, from a diffnet object
graph <- lapply(2001:2008, function(x) rgraph_er(4))
diffnet <- new_diffnet(graph, times)
# Computing the TOA differences
toa_diff(diffnet)
Run the code above in your browser using DataLab