llStochBlock {StochBlock} | R Documentation |
Function that computes criterion function used in stochastic one-mode and linked blockmodeling. If clu
is a list, the method for linked/multilevel networks is applied
Description
Function that computes criterion function used in stochastic one-mode and linked blockmodeling. If clu
is a list, the method for linked/multilevel networks is applied
Usage
llStochBlock(
M,
clu,
weights = NULL,
uWeights = NULL,
diagonal = c("ignore", "seperate", "same"),
limitType = c("none", "inside", "outside"),
limits = NULL,
weightClusterSize = 1,
addOne = TRUE,
eps = 0.001
)
Arguments
M |
A matrix representing the (usually valued) network. For multi-relational networks, this should be an array with the third dimension representing the relation. |
clu |
A partition. Each unique value represents one cluster. If the network is one-mode, than this should be a vector, else a list of vectors, one for each mode. Similarly, if units are comprised of several sets, clu should be the list containing one vector for each set. |
weights |
The weights for each cell in the matrix/array. A matrix or an array with the same dimensions as |
uWeights |
The weights for each unit. A vector with the length equal to the number of units (in all sets). |
diagonal |
How should the diagonal values be treated. Possible values are:
|
limitType |
Type of limit to use. Forced to 'none' if |
limits |
If
If |
weightClusterSize |
The weight given to cluster sizes (log-probabilities) compared to ties in loglikelihood. Defaults to 1, which is "classical" stochastic blockmodeling. |
addOne |
Should one tie with the value of the tie equal to the density of the superBlock be added to each block to prevent block means equal to 0 or 1 and also "shrink" the block means toward the superBlock mean. Defaults to TRUE. |
eps |
If addOne = FALSE, the minimal deviation from 0 or 1 that the block mean/density can take. |
Value
- the value of the log-likelihood criterion for the partition clu
on the network represented by M
for binary stochastic blockmodel.
Examples
# Create a synthetic network matrix
set.seed(2022)
library(blockmodeling)
k<-2 # number of blocks to generate
blockSizes<-rep(20,k)
IM<-matrix(c(0.8,.4,0.2,0.8), nrow=2)
clu<-rep(1:k, times=blockSizes)
n<-length(clu)
M<-matrix(rbinom(n*n,1,IM[clu,clu]),ncol=n, nrow=n)
clu<-sample(1:2,nrow(M),replace=TRUE)
plotMat(M,clu) # Have a look at this random partition
ll_pre<-llStochBlock(M,clu) # Calculate its loglikelihood
res<-stochBlockORP(M,k=2,rep=10) # Optimizing the partition
plot(res) # Have a look at the optimized partition
ll_post<-llStochBlock(M,clu(res)) # Calculate its loglikelihood
# We expect the loglikelihood pre-optimization to be smaller:
(-ll_pre)<(-ll_post)