# Generate a list of adjacency matrices
## Sub-network sizes
N <- c(250, 370, 120)
## Rate of friendship
p <- c(0.2, 0.15, 0.18)
## Network data
u <- unlist(lapply(1:3, function(x) rbinom(N[x] * (N[x] - 1), 1, p[x])))
G <- vec.to.mat(u, N, normalise = TRUE)
# Generate a vector y
y <- rnorm(sum(N))
# Compute G %*% y
Gy <- peer.avg(Glist = G, V = y)
Run the code above in your browser using DataLab