peer.avg | R Documentation |
peer.avg
computes peer average value using network data (as a list) and observable characteristics.
peer.avg(Glist, V, export.as.list = FALSE)
Glist |
the adjacency matrix or list sub-adjacency matrix. |
V |
vector or matrix of observable characteristics. |
export.as.list |
(optional) boolean to indicate if the output should be a list of matrices or a single matrix. |
the matrix product diag(Glist[[1]], Glist[[2]], ...) %*% V
, where diag()
is the block diagonal operator.
simnetwork
# Generate a list of adjacency matrices
## sub-network size
N <- c(250, 370, 120)
## rate of friendship
p <- c(.2, .15, .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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.