optRandomParC {blockmodeling} | R Documentation |

The function optimizes a set of 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, 2007) 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).
The number of clusters and a number of partitions to generate can be specified (`optParC`

).

```
optRandomParC(
M,
k,
approaches,
blocks,
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,
useParLapply = FALSE,
useLB = NULL,
chunk.size = 1,
cl = NULL,
stopcl = is.null(cl),
useRegParrallaBackend = FALSE,
...
)
## S3 method for class 'optMorePar'
print(x, ...)
```

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

`k` |
The number of clusters used in the generation of partitions. |

`approaches` |
One of the approaches (for each relation in multi-relational 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. |

`rep` |
The number of repetitions/different starting partitions to check. |

`save.initial.param` |
Should the inital parameters ( |

`save.initial.param.opt` |
Should the inital parameters( |

`deleteMs` |
Delete networks/matrices from the results of to save space. |

`max.iden` |
Maximum number of results that should be saved (in case there are more than |

`switch.names` |
Should partitions that only differ in group names be considered equal. By default it is set to |

`return.all` |
If |

`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 function is |

`mingr` |
Minimal allowed group size. |

`maxgr` |
Maximal allowed group size. |

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

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

`skip.par` |
The partitions that are not allowed or were already checked and should therefore be skipped. |

`useOptParMultiC` |
For backward compatibility. May be removed soon. See next argument. |

`useMulti` |
Which version of local search should be used. Default is currently |

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

`useParLapply` |
Should |

`useLB` |
Should be logical if set. Only used if |

`chunk.size` |
chunk.size used in |

`cl` |
The cluster to use (if formed beforehand). Defaults to |

`stopcl` |
Should the cluster be stoped after the function finishes. Defaults to |

`useRegParrallaBackend` |
Should the function use already registered parallel backend. Defaults to |

`...` |
Arguments passed to other functions, see |

`x` |
The result of |

`genPajekPar` |
Should the partitions be generated as in Pajek. |

`probGenMech` |
Should the probabilities for different mechanisms for specifying the partitions be set. If |

`M` |
The matrix of the network analyzed. |

`res` |
If |

`best` |
A list of results from |

`err` |
If |

`nIter` |
The vector of the number of iterations used - one value for each starting partition that was optimized. It can show that |

`checked.par` |
If selected - A list of checked partitions. If |

`call` |
The call used to call the function. |

`initial.param` |
If selected - The initial parameters are used. |

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 a few days).

Aleš, Žiberna

Batagelj, V., & Mrvar, A. (2006). Pajek 1.11. Retrieved from http://vlado.fmf.uni-lj.si/pub/networks/pajek/

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), 105-126. 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), 57-84. doi: 10.1080/00222500701790207

Žiberna, A. (2014). Blockmodeling of multilevel networks. Social Networks, 39(1), 46-61. doi: 10.1016/j.socnet.2014.04.002

`critFunC`

, `IM`

, `clu`

, `err`

, `plot.optMorePar`

```
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)
# 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
```

[Package *blockmodeling* version 1.1.4 Index]