R/generalize-userfunction.R
mlvsbm_create_generalized_network.Rd
Create a GenMLVSBM object from observed data
mlvsbm_create_generalized_network(X, A, directed = NULL, distribution = NULL)
A list of \(L\) square matrices with binary or count data, ordered from upper to lower level
A list of \(L-1\) matrices the affiliation matrix, linking X[[l]]
and X[[l+1]] with nrow(A[[l]]) == nrow(X[[l+1]])
and
ncol(A[[l]]) == nrow(X[[l]])
. Rows may have any number of affiliations
but will be rescaled so that each rows sum either to 1 or 0.
A vector of L booleans are the levels directed or not. Default will check if the matrix are symmetric or not.
A vector of length L, the distribution of X, only "bernoulli" and "poisson" are implemented.
An unfitted MLVSBM object corresponding to the multilevel network
# A standard binary 2 levels multilevel network
ind_adj <- matrix(stats::rbinom(n = 20**2, size = 1, prob = .2),
nrow = 20, ncol = 20)
diag(ind_adj) <- 0
org_adj <- matrix(stats::rbinom(n = 10**2, size = 1, prob = .3),
nrow = 10, ncol = 10)
diag(org_adj) <- 0
affiliation <- matrix(0, 20, 10)
affiliation[cbind(seq(20), sample(seq(10), 20, replace = TRUE))] <- 1
my_mlvsbm <- mlvsbm_create_generalized_network(X = list(org_adj, ind_adj),
directed = c(TRUE, TRUE),
A = list(affiliation),
distribution = rep("bernoulli", 2))
# A 4 levels temporal network with the same nodes and with count data.
#All the affiliation matrices are diagonal.
X <- replicate(4,
matrix(stats::rpois(n = 20*20, lambda = .7), 20, 20),
simplify = FALSE)
for (m in seq(4)) {diag(X[[m]]) <- 0}
A <- replicate(3, diag(1, 20), simplify = FALSE)
my_mlvsbm <- mlvsbm_create_generalized_network(X = X,
directed = rep(4, TRUE),
A = A,
distribution = rep("poisson", 4))