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
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
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 M.
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:
ignore - diagonal values are ignored
seperate - diagonal values are treated separately
same - diagonal values are treated the same as all other values
limitType: Type of limit to use. Forced to 'none' if limits is NULL. Otherwise, one of either outer or inner.
limits: If diagonal is "ignore" or "same", an array with dimensions equal to:
number of clusters (of all types)
number of clusters (of all types)
number of relations
2 - the first is lower limit and the second is upper limit
If diagonal is "seperate", a list of two array. The first should be as described above, representing limits for off diagonal values. The second should be similar with only 3 dimensions, as one of the first two must be omitted.
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.
Returns
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 matrixset.seed(2022)library(blockmodeling)k<-2# number of blocks to generateblockSizes<-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 partitionll_pre<-llStochBlock(M,clu)# Calculate its loglikelihoodres<-stochBlockORP(M,k=2,rep=10)# Optimizing the partitionplot(res)# Have a look at the optimized partitionll_post<-llStochBlock(M,clu(res))# Calculate its loglikelihood# We expect the loglikelihood pre-optimization to be smaller:(-ll_pre)<(-ll_post)