optRandomParC: Optimizes a set of partitions based on the value of a...

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

Description

The function optimizes a set partitions based on the value of a criterion function (see critFunC for details on the criterion function) for a given network and blockmodel for Generalized blockmodeling (Žiberna, 2006) based on other parameters (see below). The optimization is done through local optimization, where the neighborhood of a partition includes all partitions that can be obtained by moving one unit from one cluster to another or by exchanging two units (from different clusters). A list of paritions can or the number of clusters and a number of partitions to generate can be specified (optParC).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
optRandomParC(M, k, rep, save.initial.param = TRUE,
              save.initial.param.opt = FALSE, deleteMs = TRUE,
              max.iden = 10, switch.names = NULL, return.all =
              FALSE, return.err = TRUE, seed = NULL, RandomSeed =
              NULL, parGenFun = genRandomPar, mingr = NULL, maxgr =
              NULL, addParam = list(genPajekPar = TRUE, probGenMech
              = NULL), maxTriesToFindNewPar = rep * 10, skip.par =
              NULL, useOptParMultiC = FALSE, useMulti =
              useOptParMultiC, printRep = ifelse(rep <= 10, 1,
              round(rep/10)), n = NULL, nCores = 1, ...) 

Arguments

M

A matrix representing the (usually valued) network. For now, only one-relational networks are supported. The network can have one or more modes (diferent kinds of units with no ties among themselvs. If the network is not two-mode, the matrix must be square.

k

The number of clustrs used in generation of partitions.

rep

The number of repetitions/different starting partitions to check.

save.initial.param

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

save.initial.param.opt

Should the inital parameters(approaches, ...) of using optParC be saved. The default value is FALSE.

deleteMs

Delete networks/matrices from results of to save space.

max.iden

Maximum number of results that should be saved (in case there are more than max.iden results with minimal error, only the first max.iden will be saved.)

switch.names

Should partitions that only differ in group names be considert equal.

return.all

If FALSE, solution for only the best (one or more) partition/s is/are returned.

return.err

Should the error for each optimized partition be returned.

seed

Optional. The seed for random generation of partitions.

RandomSeed

Optional. integer vector, containing the random number generator.It is only looked for in the user's workspace.

parGenFun

The function (object) that will generate random partitions. The default fuction is genRandomPar. The function has to accept the following parameters: k (number o of partitions by modes, n (number of units by modes), seed (seed value for random generation of partition), addParam (a list of additional parametres).

mingr

Minimal alowed group size

maxgr

Maximal alowed group size

addParam

A list of additional parameters for function specified above. In the usage section they are specified for the default function genRandomPar.

genPajekPar

Should the partitions be generated as in Pajek.

probGenMech

Should the probabilities for different mechanizems for specifying the partitions be set. If probGenMech is not set, it is determined based on the parameter genPajekPar .

maxTriesToFindNewPar

The maximum number of partition try when trying to find a new partition to optimize that was not yet checked before - the default value is rep*1000.

skip.par

The partitions that are not allowed or were already checked and should therfire be skiped.

useOptParMultiC

For backward compatibility. May be removed soon. See next argumetent.

useMulti

Which version of local search should be used. Default is currently 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 be used. In this case, several optimal partitions are found. maxPar best partitions are returned.

printRep

Should some information about each optimization be printed.

n

the number of units by "modes". It is used only for generating random partitions. It has to be set only if there are more than two modes or if there are two modes, but the matrix representing the network is one mode (both modes are in rows and columns).

nCores

Number of cores to be used. Value 0 means all available cores. It can also be a cluster object.

...

Argumets passed to other functions, see critFunC

Value

M

The matrix of the network analyzed

res

If return.all = TRUE - A list of results the same as best - one best for each partition optimized

best

A list of results from crit.fun.tmp with the same elements as the result of crit.fun, only without M

err

If return.err = TRUE - The vector of errors or inconsistencies of the emplirical network with the ideal network for a given blockmodel (model,approach,...) and parititions

nIter

The vector of number of iterations used - one value for each starting partition that was optimized. It can show that maxiter is to low if a lot of these values have the value of maxiter

checked.par

If selected - A list of checked parititions. If merge.save.skip.par is TRUE, this list also includs the partitions in skip.par.

call

The call used to call the function.

initial.param

If selected - The inital parameters used.

Warning

It should be noted that the time complexity of package blockmodeling is increasing with the number of units and the number of clusters (due to its algorithm). Therefore the analysis of network with more than 100 units can take a lot of time (from a few hours to few days).

Author(s)

Aleš Žiberna

References

ŽIBERNA, Aleš (2007): 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.

BATAGELJ, Vladimir, MRVAR, Andrej (2006): Pajek 1.11, http://vlado.fmf.uni-lj.si/pub/networks/pajek/ (accessed January 6, 2006).

See Also

critFunC

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
n <- 8 # if larger, the number of partitions increases dramatically 
# as does if we increase the number of clusters
net <- matrix(NA, ncol = n, nrow = n)
clu <- rep(1:2, times = c(3, 5))
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)

# we select a random parition and then optimise it

all.par <- nkpartitions(n = n, k = length(tclu))
# forming the partitions
all.par <- lapply(apply(all.par, 1, list), function(x)x[[1]])
# to make a list out of the matrix

# optimizing one partition
res <- optParC(M = net,
   clu = all.par[[sample(1:length(all.par), size = 1)]],
   approaches = "hom", homFun = "ss", blocks = "com")
plot(res) # Hopefully we get the original partition

# optimizing 10 random chosen partitions with optRandomParC
res <- optRandomParC(M = net, k = 2, rep = 10, 
approaches = "hom", homFun = "ss", blocks = "com")
plot(res) # Hopefully we get the original partition

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