GreedyMerge: GreedyMerge

Description Usage Arguments Value References See Also Examples

Description

Runs the hierarchical clustering algorithm to improve the solution obtained through GreedyICL.

Usage

1
GreedyMerge(adj_cube, allocations, verbose = FALSE)

Arguments

adj_cube

A binary array of size NxNxT representing the dynamic network. The generic entry in position [i,j,t] is equal to 1 if i interacts with j during the t-th time frame, or to 0 otherwise. Only undirected networks with no self-edges are supported, so each slice of the array must be a symmetric matrix with null elements on the diagonal.

allocations

Initial allocations used by the algorithm. This should be a matrix of size TxN denoting the cluster membership of each node at each time. Values should be strictly positive integers. The value zero should be used to identify inactive nodes.

verbose

TRUE or FALSE, indicating whether a lenghty output should be printed out. Defaults to FALSE

Value

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.

References

Rastelli, R. (2017) "Exact integrated completed likelihood maximisation in a stochastic block transition model for dynamic networks", https://arxiv.org/abs/1710.03551

See Also

GreedyICL, CollapseLabels.

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

GreedySBTM documentation built on May 2, 2019, 12:40 a.m.