opt.random.par {blockmodeling}R Documentation

Optimizes a set of partitions based on the value of a criterion function.

Description

The function optimizes a set partitions based on the value of a criterion function (see crit.fun 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 be specified (opt.these.par) or the number of clusters and a number of partitions to generate (opt.random.par).

Usage

opt.random.par(M, k, n = NULL, rep, return.all = FALSE,
   return.err = TRUE, maxiter = 50, m = NULL, approach,
   trace.iter = FALSE, switch.names = NULL,
   save.initial.param = TRUE, skip.par = NULL,
   save.checked.par = TRUE,
   merge.save.skip.par = any(!is.null(skip.par), save.checked.par),
   skip.allready.checked.par = TRUE, check.skip = "iter",
   print.iter = FALSE, max.iden = 10, seed = NULL,
   parGenFun = genRandomPar, mingr = 1, maxgr = Inf,
   addParam = list(genPajekPar = TRUE, probGenMech = NULL),
   maxTriesToFindNewPar = rep * 10, ...)

opt.these.par(M, partitions, return.all = FALSE, return.err = TRUE,
   skip.allready.checked.par = TRUE, maxiter = 50, m = NULL,
   approach, trace.iter = FALSE, switch.names = TRUE,
   save.initial.param = TRUE, skip.par = NULL,
   save.checked.par = !is.null(skip.par),
   merge.save.skip.par = all(!is.null(skip.par), save.checked.par),
   check.skip = "never", print.iter = FALSE, ...)

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.
n The vector of the number of units in each mode (only necessary if mode is larger than 2.
rep The number of repetitions/different starting partitions to check.
partitions A list of partitions. 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.
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
maxiter Maximum number of iterations
m 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.
approach One of the approaches described in Žiberna (2007). Possible values are:
"bin" - binary blockmodeling,
"val" - valued blockmodeling,
"imp" - implicit blockmodeling,
"ss" - sum of squares homogenity blockmodeling, and
"ad" - absolute deviations homogenity blockmodeling.
trace.iter Should the result of each iteration (and not only of the best one) be saved
switch.names Should partitions that differ only in diferent names of positions be treated as different. It should be set to TRUE only if a asymetric blockmodel via BLOCKS is specified.
save.initial.param Should the inital parameters (approach,...) be saved
skip.par The partitions that are not allowed or were already checked and should therfire be skiped.
save.checked.par Should the checked partitions be saved. For example, so that they can be used in the next call as skip.par
merge.save.skip.par Should the checked partitions be merged with skiped ones?
skip.allready.checked.par If TRUE,the partitions that were already checked when runing opt.par form different statrting points will be skiped.
check.skip When should the check be preformed:
"all" - before every call to 'crit.fun' (Time demanding)
"iter" - at the end of eack iteratiton
"opt.par" - before every call to opt.par, when starting the optimization of a new partition.
"never" - never
print.iter Should the progress of each iteration be printed?
max.iden The 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).
seed Optional. The seed for random generation of partitions.
parGenFun The fucntion (object) that will generate rendom partitions. The deault fuction is genRandomPar. The function has to accept the following parameters: k (number 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 dthe default function genRandomPar:
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
... Argumets passed to other functions, see crit.fun

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

This function can be extremly slow. The time complexity is incrising with the number od units and the number of clusters. It is advaisable to firtst time the function on a smaller network.

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

crit.fun, check.these.par, opt.par, plot.opt.more.par

Examples

n<-8 #if larger, the number of partitions increases dramaticaly,
     #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<-opt.par(M=net,
   clu=all.par[[sample(1:length(all.par),size=1)]],
   approach="ss",blocks="com")
plot(res) #Hopefully we get the original partition

#optimizing 10 random chosen partitions with opt.these.par
res<-opt.these.par(M=net,
   partitions=all.par[sample(1:length(all.par),size=10)],
   approach="ss", blocks="com")
plot(res) #Hopefully we get the original partition

#optimizing 10 random chosen partitions with opt.random.par
res<-opt.random.par(M=net,k=2,rep=10,approach="ss",blocks="com")
plot(res) #Hopefully we get the original partition

[Package blockmodeling version 0.1.7 Index]