Description Usage Arguments Value References See Also Examples
Runs the hierarchical clustering algorithm to improve the solution obtained through GreedyICL.
1 | GreedyMerge(adj_cube, allocations, verbose = FALSE)
|
adj_cube |
A binary array of size |
allocations |
Initial allocations used by the algorithm. This should be a matrix of size |
verbose |
TRUE or FALSE, indicating whether a lenghty output should be printed out. Defaults to FALSE |
computing_time |
Number of seconds required to run the function. |
icl_start |
Exact log-ICL value for the initial allocations. |
icl_end |
Exact log-ICL value for the optimal allocations found. |
allocations |
Optimal allocations. |
Rastelli, R. (2017) "Exact integrated completed likelihood maximisation in a stochastic block transition model for dynamic networks", https://arxiv.org/abs/1710.03551
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 | set.seed(12345)
data(reality_mining_84)
tframes <- dim(reality_mining_84)[3]
N <- dim(reality_mining_84)[1]
### Evaluate matrix containing the degrees of each node at each time
degrees <- apply(X = reality_mining_84, MARGIN = c(1,3), FUN = sum)
### create a binary matrix with ones corresponding to inactive nodes
inactive_nodes <- degrees == 0
### create an edgelist listing all of the ids (time, node_label) of inactive nodes
n_inactive_nodes <- sum(inactive_nodes)
list_of_inactive_nodes <- matrix(NA,n_inactive_nodes,2)
index <- 1
for (t in 1:tframes) for (i in 1:N) if (inactive_nodes[i,t])
{
list_of_inactive_nodes[index,1] = t
list_of_inactive_nodes[index,2] = i
index = index + 1
}
### Find starting allocations using k-means
allocations_init <- GreedyInit(reality_mining_84, 20, list_of_inactive_nodes)
### Run the GreedyICL algorithm (this may take some time)
output_greedy <- GreedyICL(reality_mining_84, allocations_init, max_n_iter = 1)
### max_n_iter is set to 1 to speed up the demonstration:
### please always use max_n_iter = 100 in applications
### Run the hierarchical clustering routine
output_merge <- GreedyMerge(adj_cube = reality_mining_84, allocations = output_greedy$allocations)
str(output_merge)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.