critFunC {blockmodeling}  R Documentation 
Functions for Generalized blockmodeling for valued networks
Description
Functions for implementation of Generalized blockmodeling for valued
networks where the values of the ties are assumed to be measured on at least interval
scale. critFunC
calculates the criterion function, based on the network, partition and blockmodel/equivalece.
optParC
optimizes a partition based on the criterion function based on a local search algorithm.
Usage
critFunC(
M,
clu,
approaches,
blocks,
isTwoMode = NULL,
isSym = NULL,
diag = 1,
IM = NULL,
EM = NULL,
Earr = NULL,
justChange = FALSE,
rowCluChange = c(0, 0),
colCluChange = c(0, 0),
sameIM = FALSE,
regFun = "max",
homFun = "ss",
usePreSpecM = NULL,
preSpecM = NULL,
save.initial.param = TRUE,
relWeights = 1,
posWeights = 1,
blockTypeWeights = 1,
combWeights = NULL,
returnEnv = FALSE,
mulReg = TRUE,
addGroupLlErr = TRUE
)
optParC(
M,
clu,
approaches,
blocks,
nMode = NULL,
isSym = NULL,
diag = 1,
useMulti = FALSE,
maxPar = 50,
IM = NULL,
EM = NULL,
Earr = NULL,
justChange = TRUE,
sameIM = FALSE,
regFun = "max",
homFun = "ss",
usePreSpecM = NULL,
preSpecM = NULL,
minUnitsRowCluster = 1,
minUnitsColCluster = 1,
maxUnitsRowCluster = 9999,
maxUnitsColCluster = 9999,
relWeights = 1,
posWeights = 1,
blockTypeWeights = 1,
combWeights = NULL,
exchageClusters = "all",
fixClusters = NULL,
save.initial.param = TRUE,
mulReg = TRUE,
addGroupLlErr = TRUE
)
Arguments
M 
A matrix representing the (usually valued) network. For multirelational networks, this should be an array with the third dimension representing the relation. The network can have one or more modes (diferent kinds of units with no ties among themselves). If the network is not twomode, the matrix must be square. 
clu 
A partition. Each unique value represents one cluster. If the nework is onemode, than this should be a vector, else a list of vectors, one for each mode. Similarly, if units are comprised of several sets, 
approaches 
One of the approaches (for each relation in multirelational netowrks in a vector) described in Žiberna (2007). Possible values are: 
blocks 
A vector, a list of vectors or an array with names of allowed blocy types. 
isTwoMode 

isSym 
Specifying if the matrix (for each relation) is symmetric. 
diag 
Should the special status of diagonal be acknowledged. A single number or a vector equal to the number of relation. The default value is set to 
IM 
The obtained image for objects. For debugging purposes only. 
EM 
Block errors by blocks. For debugging purposes only. 
Earr 
The array of errors for all allowed block types by next dimensions: allowed block types, relations, row clusters and column clusters. The dimensions should match the dimensions of the block argument if specified as an array. For debugging purposes only. 
justChange 
Value specifying if only the errors for changed clusters should be computed. Used only for debugging purposes by developers. 
rowCluChange 
An array holding the two row clusters where the change occured. Used only for debugging purposes by developers. 
colCluChange 
An array holding the col row clusters where the change occured. Used only for debugging purposes by developers. 
sameIM 
Should we demand the same blockmodel image for all relations. The default value is set to 
regFun 
Function f used in rowfregular, columnfregular, and fregular blocks. Not used in binary approach. For multirelational networks, it can be a vector of such character strings. The default value is set to 
homFun 
In case of homogeneity blockmodeling two variability criteria can be used: 
usePreSpecM 
Specifying weather a prespecified value should be used when computing inconsistency. 
preSpecM 
Sufficient value for individual cells for valued approach. Can be a number or a character string giving the name of a function. Set to 
save.initial.param 
Should the inital parameters ( 
relWeights 
Weights for all type of relations in a blockmodel. The default value is set to 
posWeights 
Weigths for positions in the blockmodel (the dimensions must be the same as the error matrix (rows, columns)). For now this is a matix (twodimensional) even for multirelational networks. 
blockTypeWeights 
Weights for each type of block used, if they are to be different across block types (see 
combWeights 
Weights for all type of block used, The default value is set to 
returnEnv 
Should the function also return the environment after its completion. 
mulReg 
Should the errors that apply to rows/columns (and not to cells) should be multiplied by number of rows/columns. Defaults to TRUE. 
addGroupLlErr 
Used only when stochastic generalized blockmodeling is used. Should the total error included the part based on sizes of groups. Defaults to TRUE. Will return wrong results for twomode networks if critFunC is called directly (should be fine if called via optParC function). 
nMode 
Number of nodes. If 
useMulti 
Which version of local search should be used. The default value is set to 
maxPar 
The number of partitions with optimal criterion fuction to be returned. Only used If 
minUnitsRowCluster 
Minimum number of units in row cluster. 
minUnitsColCluster 
Minimum number of units in col cluster. 
maxUnitsRowCluster 
Maximum number of units in row cluster. 
maxUnitsColCluster 
Maximum number of units in col cluster. 
exchageClusters 
A matrix of dimensions "number of clusters" x "number of clusters" indicating to which clusters can units from a specific cluster be moved. Useful for multilevel blockmodeling or/in some other cases where some units cannot mix. 
fixClusters 
Clusters to be fixed. Used only if 
Value
critFunC
returns a list containing:
M 
The matrix of the network analyzed. 
err 
The error or inconsistency emplirical network with the ideal network for a given blockmodel (model, approach,...) and paritition. 
clu 
The analyzed partition. 
EM 
Block errors by blocks. 
IM 
The obtained image for objects. 
BM 
Block means by block  only for Homogeneity blockmodeling. 
Earr 
The array of errors for all allowed block types by next dimensions: allowed block types, relations, row clusters and column clusters. The dimensions should match the dimensions of the block argument if specified as an array. 
optParC
returns a list containing:
M 
The matrix of the network analyzed. 
err 
The error or inconsistency emplirical network with the ideal network for a given blockmodel (model, approach,...) and paritition. 
clu 
The analyzed partition. 
EM 
Block errors by blocks. 
IM 
The obtained image for objects. 
BM 
Block means by block  only for Homogeneity blockmodeling. 
Earr 
The array of errors for all allowed block types by next dimensions: allowed block types, relations, row clusters and column clusters. The dimensions should match the dimensions of the block argument if specified as an array. 
useMulti 
The value of the input paramter 
bestRowParMatrix 
(If 
sameErr 
The number of partitions with the minimum value of the criterion function. 
Author(s)
Aleš, Žiberna
References
Doreian, P., Batagelj, V., & Ferligoj, A. (2005). Generalized blockmodeling, (Structural analysis in the social sciences, 25). Cambridge [etc.]: Cambridge University Press.
Žiberna, A. (2007). Generalized Blockmodeling of Valued Networks. Social Networks, 29(1), 105126. doi: 10.1016/j.socnet.2006.04.002
Žiberna, A. (2008). Direct and indirect approaches to blockmodeling of valued networks in terms of regular equivalence. Journal of Mathematical Sociology, 32(1), 5784. doi: 10.1080/00222500701790207
Žiberna, A. (2014). Blockmodeling of multilevel networks. Social Networks, 39(1), 4661. doi: 10.1016/j.socnet.2014.04.002
See Also
optRandomParC
, IM
, clu
, err
, plot.critFun
Examples
# Generating a simple network corresponding to the simple Sum of squares
# Structural equivalence with blockmodel:
# nul com
# nul nul
n < 20
net < matrix(NA, ncol = n, nrow = n)
clu < rep(1:2, times = c(5, 15))
tclu < table(clu)
net[clu == 1, clu == 1] < rnorm(n = tclu[1] * tclu[1], mean = 0, sd = 1)
net[clu == 1, clu == 2] < rnorm(n = tclu[1] * tclu[2], mean = 4, sd = 1)
net[clu == 2, clu == 1] < rnorm(n = tclu[2] * tclu[1], mean = 0, sd = 1)
net[clu == 2, clu == 2] < rnorm(n = tclu[2] * tclu[2], mean = 0, sd = 1)
# Computation of criterion function with the correct partition
res < critFunC(M = net, clu = clu, approaches = "hom", homFun = "ss", blocks = "com")
res$err # The error is relatively small
plot(res)
# Computation of criterion function with the correct partition and correct prespecified blockmodel
# Prespecified blockmodel used
# nul com
# nul nul
B < array(NA, dim = c(1, 1, 2, 2))
B[1, 1, , ] < "nul"
B[1, 1, 1, 2] < "com"
B[1, 1, , ]
res < critFunC(M = net, clu = clu, approaches = "hom", homFun = "ss", blocks = B)
res$err # The error is relatively small
res$IM
plot(res)
# Computation of criterion function with the correct partition
# and prespecified blockmodel with some alternatives
# Prespecified blockmodel used
# nul nulcom
# nul nul
B < array(NA, dim = c(2, 2, 2))
B[1, , ] < "nul"
B[2, 1, 2] < "com"
res < critFunC(M = net, clu = clu, approaches = "hom", homFun = "ss", blocks = B)
res$err # The error is relatively small
res$IM
plot(res)
# Computation of criterion function with random partition
set.seed(1)
clu.rnd < sample(1:2, size = n, replace = TRUE)
res.rnd < critFunC(M = net, clu = clu.rnd, approaches = "hom",
homFun = "ss", blocks = "com")
res.rnd$err # The error is larger
plot(res.rnd)
# Adapt network for Valued blockmodeling with the same model
net[net > 4] < 4
net[net < 0] < 0
# Computation of criterion function with the correct partition
res < critFunC(M = net, clu = clu, approaches = "val",
blocks = c("nul", "com"), preSpecM = 4)
res$err # The error is relatively small
res$IM
# The image corresponds to the one used for generation of
# The network
plot(res)
# Optimizing one partition
res < optParC(M = net, clu = clu.rnd,
approaches = "hom", homFun = "ss", blocks = "com")
plot(res) # Hopefully we get the original partition