I am trying to create a network animation that shows how nodes change state over time. The use case is contact tracing for Covid-19. I used an agent-based model to simulate Covid-19 spread. From this I extracted my contact network. I am struggling to figure out how the tsna package changes node color (disease state) per time slice. Here is my data and attempt at rendering:
# load libraries
require(sna)
require(tsna)
require(ndtv)
# get data
url <- "https://github.com/aterhorst/data/blob/master/dynamic_network.Rdata?raw=true"
download.file(url, destfile= "data/dynamic_network.Rdata", mode = "wb")
# load data
load("data/dynamic_network.Rdata")
# create a dynamic network object
nd <-networkDynamic(edge.spells = edges,
vertex.spells = nodes)
# render dynamic network object
compute.animation(nd,
animation.mode = "kamadakawai",
slice.par = list(
start = 1,
end = 12,
interval = 1,
aggregate.dur = 2,
rule = "any"))
render.d3movie(nd,
vertex.col = nodes$col,
displaylabels = TRUE)
Because my agent-based model is quite small, edges disappear around day 12. Essentially, everybody has been exposed to the virus by then so further contacts make no difference. My model stops caring. What you see in my example are static node colors. What I want to see are nodes changing color with disease state. Can someone help me get this right?