peer.avg | R Documentation |
The peer.avg
function computes peer average values using network data (provided as a list of adjacency matrices) and observable characteristics.
peer.avg(Glist, V, export.as.list = FALSE)
Glist |
An adjacency matrix or a list of sub-adjacency matrices representing the network structure. |
V |
A vector or matrix of observable characteristics. |
export.as.list |
(optional) A boolean indicating whether the output should be a list of matrices ( |
The matrix product diag(Glist[[1]], Glist[[2]], ...) %*% V
, where diag()
represents the block diagonal operator.
simnetwork
, vec.to.mat
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.