opt.par {blockmodeling}R Documentation

Optimizes a partition based on the value of a criterion function.

Description

The function optimizes a partition based on the value of a criterion function (see crit.fun) 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 neighbourhood 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).

Usage

opt.par(M, clu, maxiter = 50, m = NULL, approach,
   trace.iter = FALSE, switch.names = NULL,
   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", ...)

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.
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
maxiter Maxsimum number of iterations allowed
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 (2006). 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. The default NULL tries to find that.
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?
check.skip When should the check be preformed:
"all" - before every call to 'crit.fun'
"iter" - at the end of eack iteratiton
"never" - never
... Argumets passed to other functions, see crit.fun and arguments to function gen.crit.fun. As this function is not intented to be called directly, it also has no help files. Therefore these arguments are described below:

use.for.opt: Should FORTRAN function be used for optimization if possible. If FORTRAN function is used, the speed is dramatically increast, however some the output is slightly different and the plotting function might not work. FORTRAN subrutines are available for only very special cases, currently only for using "ss" aproach and only complete blocks. If you are using such setting and some special features (these are not implemented in FORTRAN subrutines - e.g. using function parOK to allow only certain kinds of partitions), it's safer to set it to FASLE, as the fuction may miss that these features are not implemented in FORTRAN subrutines and use them nevertheless, leading to wrong results.

use.for: (default = TRUE) Should FORTRAN subrutines be used where available (available for only very special cases, currently only for using "ss" aproach and only complete blocks. If you are using such setting and some special features (these are not implemented in FORTRAN subrutines), it's safer to set it to FASLE, as the fuction may miss that these features are not implemented in FORTRAN subrutines and use them nevertheless, leading to wrong results.

check.switch: If TRUE (the default), the neighborhood of the selected partition also includes the partitions that can be obtained by exchanging (switching) two units from diferent clusters).

check.all: If TRUE (the default), all partitions in the neighborhood of the selected partition are first evaluated and the current partition than changes to the one with the lowest value of the criterion function (if lower than that of the current partition). If FALSE, the first partition with the criterion lower the current partition becomes the new current partition (and the iteration terminates).

Value

M The matrix of the network analyzed
best A list of results from crit.fun.tmp with the same elements as the result of crit.fun, only without M
iter A list of resoults the same as best - one best for each iteration
err If selected - The vector of errors or inconsistencies of the emplirical network with the ideal network for a given blockmodel (model,approach,...) and parititions
nIter The number of iterations used. It can show that maxiter is to low if this value is equal to maxiter
call The call used to call the function.
initial.param If selected - The inital parameters used.
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.

...

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

crit.fun, check.these.par, opt.random.par, opt.these.par, plot.opt.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
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

[Package blockmodeling version 0.1.7 Index]