get_mle_ERSBM {GoodFitSBM} | R Documentation |
Maximum Likelihood Estimation of edge probabilities between blocks of a graph, under ERSBM
Description
get_mle_ERSBM
obtains MLE for the probability of edges between blocks in a graph, used in calculating the goodness-of-fit test statistic for the ERSBM (Karwa et al. (2023))
Usage
get_mle_ERSBM(G, C)
Arguments
G |
an igraph object which is an undirected graph with no self loop |
C |
a positive integer vector of size n for block assignments of each node; from 1 to K (no of blocks) |
Value
A matrix of maximum likelihood estimates
mleMatr |
a matrix containing the estimated edge probabilities between blocks in a graph |
References
Karwa et al. (2023). "Monte Carlo goodness-of-fit tests for degree corrected and related stochastic blockmodels", Journal of the Royal Statistical Society Series B: Statistical Methodology, doi:10.1093/jrsssb/qkad084
See Also
goftest_ERSBM()
performs the goodness-of-fit test for the ERSBM, where the MLE of the edge probabilities are required
Examples
RNGkind(sample.kind = "Rounding")
set.seed(1729)
# We model a network with 3 even classes
n1 = 2
n2 = 2
n3 = 2
# Generating block assignments for each of the nodes
n = n1 + n2 + n3
class = rep(c(1, 2, 3), c(n1, n2, n3))
# Generating the adjacency matrix of the network
# Generate the matrix of connection probabilities
cmat = matrix(
c(
0.80, 0.05, 0.05,
0.05, 0.80, 0.05,
0.05, 0.05, 0.80
),
ncol = 3,
byrow = TRUE
)
pmat = cmat / n
# Creating the n x n adjacency matrix
adj <- matrix(0, n, n)
for (i in 2:n) {
for (j in 1:(i - 1)) {
p = pmat[class[i], class[j]] # We find the probability of connection with the weights
adj[i, j] = rbinom(1, 1, p) # We include the edge with probability p
}
}
adjsymm = adj + t(adj)
# graph from the adjacency matrix
G = igraph::graph_from_adjacency_matrix(adjsymm, mode = "undirected", weighted = NULL)
# mle of the edge probabilities
get_mle_ERSBM(G, class)