critFunC: Functions for Generalized blockmodeling for valued networks.

Description Usage Arguments Value Author(s) References See Also Examples

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 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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)
    
    
optParC(M, nMode = NULL,isSym = NULL, diag = 1, clu, approaches, blocks,
    useMulti = FALSE, maxPar = 50, IM = NULL, EM = NULL, Earr = NULL,
    justChange = FALSE, 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",
    save.initial.param = TRUE)

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. The network can have one or more modes (diferent kinds of units with no ties among themselves). If the network is not two-mode, the matrix must be square.

clu

A partition. Each unique value represents one cluster. If the nework is one-mode, than this should be a vector, else a list of vectors, one for each mode.

approaches

One of the approaches (for each relation in multi-relational netowrks in a vector) described in Žiberna (2006). Possible values are:
"bin" - binary blockmodeling,
"val" - valued blockmodeling,
"ss" - sum of squares homogenity blockmodeling, and
"ad" - absolute deviations homogenity blockmodeling.

blocks

A vector, a list of vectors or an array with names of allowed blocy types.

Only listing of allowed block types (blockmodel is not pre-specified).
A vector with names of allowed blocktypes. For multi-relational networks, it can be a list of such vectors. For approaches = "bin" or approaches = "val", at least two should be selected. Possible values are:
"nul" - null or empty block
"com" - complete block
"rdo", "cdo" - row and column-dominant blocks (binary and valued approach only)
"reg" - (f-)regular block
"rre", "cre" - row and column-(f-)regular blocks
"rfn", "cfn" - row and column-dominant blocks (binary, valued only)
"den" - density block (binary approach only)
"avg" - average block (valued approach only)
"dnc" - do not care block - the error is always zero
The ordering is important, since if several block types have identical error, the first on the list is selected.

A pre-specified blockmodel.
An array with dimensions four dimensions (see example below). The third and the fourth represent the clusters (for rows and columns). The first is as long as the maximum number of allows block types for a given block. If some block has less possible block types, the empty slots should have values NA. The second dimension is the number of relations (1 for single-relational networks). The values in the array should be the ones from above.

isTwoMode

1 for one-mode networks and 2 for two-mode networks. The default value is set to NULL.

isSym

Specifying if the matrix (for each relation) is symetric.

diag

Should the special stauts of diagonal be acknowladged. The default value is set to 1.

IM

The obtained image for objects.

EM

Block errors by blocks.

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.

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 damand the same blockmodel image for all relations. The default value is set to FALSE.

regFun

Function f used in row-f-regular, column-f-regular, and f-regular blocks. Not used in binary approach. For multi-relational networks, it can be a vector of such character strings. The default value is set to "max".

homFun

In case of homogenity blockmodeling two vairability criteria can be used: "ss" - sum of squares (set by default) and "ad" - absolute deviations.

usePreSpecM

Specifiying weather a pre-specified value should be used when computing inconsistency.

preSpecM

Suficient value for individual cells for valued approach. Can be a number or a character string giving the name of a function. Set to "max" for implicit approach. For multi-relational networks, it can be a vector of such values. In case ob binary blockmodeling this argument is a threshold used for binerizing the network. Therefore all values with values lower than preSpecM are recoded into 0s, all other into 1s. For multi-relational networks, it can be a vector of such values.

save.initial.param

Should the inital parameters (approaches, ...) be saved. The default value is TRUE.

relWeights

Weights for all type of relations in a blockmodel. The default value is set to 1.

posWeights

Weigths for positions in the blockmodel (the dimensions must be the same as the error matrix). For now this is a matix (two-dimensional) even for multi-relational networks.

blockTypeWeights

Weights for each type of block used, if they are to be different accros block types (see blocks above). It must be suplied in form of a named vetor. The default value is set to 1.

combWeights

Weights for all type of block used, The default value is set to NULL.

returnEnv

Should the function also return the environment after its completion.

useMulti

Which version of local search should be used. The default value is set to FALSE. If FALSE, first possible all moves in random order and then all possible exchanges in random order are tired. When a move with lower value of criterion function is found, the algorithm moves to this new partition. If TRUE the version of local search where all possible moves and exchanges are tired first and then the one with the lowest error is selected and used. In this case, several optimal partitions are found. maxPar best partitions are returned.

maxPar

The number of partitions with optimal criterion fuction to be returned. Only used If useMulti is TRUE.

nMode

Number of nodes. If NULL, then determined from clu.

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.

Value

A list:

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.

Author(s)

Aleš Žiberna

References

ŽIBERNA, Aleš (2006): Generalized Blockmodeling of Valued Networks. Social Networks, Jan. 2007, vol. 29, no. 1, 105-126. http://dx.doi.org/10.1016/j.socnet.2006.04.002.

ŽIBERNA, Aleš. Direct and indirect approaches to blockmodeling of valued networks in terms of regular equivalence. J. math. sociol., 2008, vol. 32, no. 1, 57-84. http://www.informaworld.com/smpp/content?content=10.1080/00222500701790207.

DOREIAN, Patrick, BATAGELJ, Vladimir, FERLIGOJ, Anuška (2005): Generalized blockmodeling, (Structural analysis in the social sciences, 25). Cambridge [etc.]: Cambridge University Press, 2005. XV, 384 p., ISBN 0-521-84085-6.

See Also

optRandomParC, IM, clu, err, plot.crit.fun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## 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 relativly small
res$BM  ## The block means are around 0 or 4
plot(res)

## Computation of criterion function with the correct partition and correct pre-specified 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 relativly small
res$IM 
plot(res)

## Computation of criterion function with the correct partition 
# and pre-specified blockmodel with some alternatives
## Prespecified blockmodel used
## nul nul|com
## 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 relativly small
res$IM 
plot(res)

## Computation of criterion function with random partition
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
res.rnd$BM  ## random block means
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 relativly small
res$IM 
## The image corresponds to the one used for generation of
## The network
plot(res)

## Computation of criterion function with random partition
res.rnd <- critFunC(M = net, clu = clu.rnd, approaches = "val",
blocks = c("nul", "com"), preSpecM = 4)
res.rnd$err ## the error is larger
res.rnd$IM ## all blocks are probably nul
plot(res.rnd)

blockmodelingOld documentation built on May 2, 2019, 5:11 p.m.