Infectiousness and Susceptibility
# Generating a random graph
set.seed(1234)
n <- 100
nper <- 20
graph <- rgraph_er(n,nper, p=.40, undirected = FALSE)
toa <- sample(1:(1+nper-1), n, TRUE)
head(toa)
## [1] 19 7 8 1 17 14
# Creating a diffnet object
diffnet <- as_diffnet(graph, toa)
# Visualizing distribution of suscep/infect
out <- plot_infectsuscep(graph, toa, K=1, logscale = TRUE)
## Warning in plot_infectsuscep.list(graph, toa, t0, normalize, K, r,
## expdiscount, : When applying logscale some observations are missing.

plot_infectsuscep(diffnet, K=1, logscale = TRUE)
## Warning in plot_infectsuscep.list(graph$graph, graph$toa, t0, normalize, :
## When applying logscale some observations are missing.

Threshold
# Generating a random graph
set.seed(123)
n <- 6
nper <- 5
toa <- sample(2000:(2000+nper-1), n, TRUE)
nper <- length(unique(toa))
graph <- rgraph_er(n,nper, p=.3, undirected = FALSE)
adopt <- toa_mat(toa)
# Computing exposure
expos <- exposure(graph, adopt$cumadopt)
x<-plot_threshold(graph, expos, toa, undirected = FALSE)

plot_threshold(graph, expos, toa, vertex.cex = 1/4)

# Not everybody adopted!
toa[2] <- NA
adopt <- toa_mat(toa)
# Computing exposure
expos <- exposure(graph, adopt$cumadopt)
plot_threshold(graph, expos, toa, undirected = FALSE)

plot_threshold(graph, expos, toa, vertex.cex = 1/4)
