EpiModel-Gallery
EpiModel-Gallery copied to clipboard
example of clustering for network models
For example, people are clustered in households, which are clustered in neighborhoods, and there is a strong propensity for in-household mixing, a slightly weaker propensity for in-neighborhood mixing, and a zero propensity for cross-neighborhood mixing.
nw <- network.initialize(100, directed = FALSE)
hh <- rep(1:4, each = 25)
nb <- rep(1:2, each = 50)
nw %v% "hh" <- hh
nw %v% "nb" <- nb
fit <- ergm(nw ~ edges + nodemix("nb", base = c(1,3)),
target.stats = c(50, 0))
sim <- simulate(fit, nsim = 1e4, statsonly = TRUE,
monitor = ~nodemix("nb", base = 0)+nodemix("hh", base = 0))
colMeans(sim)
this sounds interesting!
For example, people are clustered in households, which are clustered in neighborhoods, and there is a strong propensity for in-household mixing, a slightly weaker propensity for in-neighborhood mixing, and a zero propensity for cross-neighborhood mixing.
nw <- network.initialize(100, directed = FALSE)
hh <- rep(1:4, each = 25) nb <- rep(1:2, each = 50)
nw %v% "hh" <- hh nw %v% "nb" <- nb
fit <- ergm(nw ~ edges + nodemix("nb", base = c(1,3)), target.stats = c(50, 0)) sim <- simulate(fit, nsim = 1e4, statsonly = TRUE, monitor = ~nodemix("nb", base = 0)+nodemix("hh", base = 0)) colMeans(sim)