select.dynsbm: Dynamic stochastic block model estimation for different...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/select.dynsbm.R

Description

Estimation of dynamic stockastic block models for different number of groups. Each model combines a stochastic block model (SBM) for its static part with independent Markov chains for the evolution of the nodes groups through time.

Usage

1
2
3
4
5
6
7
select.dynsbm(Y, present=NULL, Qmin, Qmax,
			edge.type=c("binary","discrete","continuous"), K=-1,
			directed=FALSE, self.loop=FALSE,
			nb.cores=1,
			iter.max=20, nstart=25, perturbation.rate=0.2,
                        fixed.param=FALSE, bipartition=NULL,
			plot=TRUE)

Arguments

Y

An object of class array of dimension (T x N x N) containing T adjacency matrices of size (N x N), where N is the number of nodes in the network and T is the number of time points.

present

NULL or an object of class matrix of size (N x T) containing the presence/absence (coded with 1/0 respectively) of each N nodes at each of the T time points. When set to NULL, this object is deduced from Y (see the "Details" section). Any node must be present at least once among the time points.

Qmin

Minimum number of groups >1.

Qmax

Maximum number of groups.

edge.type

Type of adjacency matrices. This should be (an unambiguous abbreviation of) one of binary, discrete or continuous. See the "Details" section.

K

Only if edge.type=="discrete". Number of non-zero discrete values (i.e. in 1,..,K).

directed

If TRUE, the network is supposed to be directed (and therefore Y is supposed to be asymmetric).

self.loop

If TRUE, self-loops (edges from one node to the same node) are allowed and taken into acount in the estimation procedure.

nb.cores

Number of cores to use, i.e. how many child processes and how many threads will be run simultaneously during the initialization and the estimation steps respectively.

iter.max

Maximal number of algorithm iterations.

nstart

Number of starting points for the iterative estimation algorithm. See the "Details" section.

perturbation.rate

Rate of perturbation (in [0,1], see nstart) for the iterative estimation algorithm. This rate is the fraction of nodes for which its group is randomly shuffled.

fixed.param

If TRUE, the model parameters remain fixed and constant in time. By default, fixed.param is automatically set to TRUE in the bipartite case (i.e. bipartition is not NULL; see the "Details" section).

bipartition

NULL or a vector of size N specifying a node bipartition in the case of bipartite networks (see the "Details" section). Each element of this vector is set to 1 or 2 to specify the node belongs to the first or second set of nodes.

plot

Display a plot with the loglikelihood and the ICL criteria if edge.type=="binary"/"continuous". See the "Details" section.

Details

This function deals with binary or weighted dynamic/temporal/evolving networks (with discrete or continuous edges). The adjacency matrices must be coded with 0/1 in the binary case, with 0/y where y belongs to the set 1,..,K in the discrete case or with 0/y where y is numeric, must be positive and is supposed to fit a gaussian mixture in the continuous case.

Presence/absence information allows to model node's arrival or departure, birth or death, or simply enables to specify missing data (as absent nodes). If this information is missing (NULL), the presence/absence is deduced automatically from Y by searching for nodes that do not participate in any edges (lines/columns of O in Y) and declaring them as absent. This function does not support the existence of nodes that are never present (error message in this case).

The estimation algorithm is iterative and rely on a starting point. Therefore, it is possible to start the algorithm many times with 'nstart' starting points. The first starting point is obtained with an ad-hoc use of the kmeans function. The follwing starting point are obtained by perturbating the first one (see perturbation.rate). The greater nstart, the more accurate the results.

To select the best number of groups, the "elbow" method consists in finding the point where the slope of the loglikelihood is decreasing (i.e. the loglikelihood is reaching a plateau). If edge.type=="binary", the ICL criteria (plotted in red) has to be used : the best number of nodes is supposed to maximize the ICL criteria.

This function has been extended to the case of bipartite networks. In this case, despite Y has to be of dimension (T x N x N), it is possible to give a bipartition of the nodes into two disjoint sets. For statistical reasons, fixed.param is automatically set to TRUE. Given the total number of groups Q between Qmin and Qmax, there is Q/2 groups for each set of nodes (when Q is odd, there is floor(Q/2)+1 groups for the largest set of nodes); however, there is no guaranty that the final groups are coherent with the bipartition, i.e. that any group is composed by nodes of one of the two sets (if not, a warning message is generated).

Value

Returns a list of dynsbm objects. Each object of class dynsbm is a list with the following components:

transition

The Markov chain transition matrix of size (Q x Q).

membership

An object of class matrix of size (N x T) containing the group membership estimated by MAP (>0, =0 for absent nodes).

beta

An object of class matrix of size (T x Q x Q) containing the sparsity parameters of the model.

gamma

Only if edge.type=="discrete". An object of class matrix of size (T x Q x Q x K) containing the model parameters.

mu/sigma

Only edge.type=="continuous"An object of class matrix of size (T x Q x Q) and a vector containing the model parameters.

loglikelihood

Completed data log-likelihood.

iter

Number of used algorithm iterations.

directed

Specifies whether the model is build for directed networks.

self.loop

Specifies whether the model allows self-loops.

Author(s)

Authors: Catherine Matias, Vincent Miele

Maintainer: Vincent Miele <vincent.miele@univ-lyon1.fr>

References

Catherine Matias and Vincent Miele, Statistical clustering of temporal networks through a dynamic stochastic block model, Journal of the Royal Statistical Society: Series B (2017) http://dx.doi.org/10.1111/rssb.12200 http://arxiv.org/abs/1506.07464

Vincent Miele and Catherine Matias, Revealing the hidden structure of dynamic ecological networks, Royal Society Open Science (2017) http://dx.doi.org/10.1098/rsos.170251 https://arxiv.org/abs/1701.01355

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(simdataT5Q4N40binary)

## estimation for Q=1..6 groups
list.dynsbm <- select.dynsbm(simdataT5Q4N40binary, 
				Qmin=1, Qmax=6, edge.type="binary", nstart=1)
				
## Not run: 
## better to use nstart>1 starting points
## but estimation can take 1-2 minutes
list.dynsbm <- select.dynsbm(simdataT5Q4N40binary, 
				Qmin=1, Qmax=6, edge.type="binary", nstart=25)

## End(Not run)

## selection of Q=4
dynsbm <- list.dynsbm[[4]]

## plotting intra/inter connectivity patterns
connectivity.plot(dynsbm, simdataT5Q4N40binary)

## plotting switches between groups
alluvial.plot(dynsbm)

Example output

--------------
Default style:
-----------
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"
--------------
[1] "checking edges"
Updated styles:
$`T1-1`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-2`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-3`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-4`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-1`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-2`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-3`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-4`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-1`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-2`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-3`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-4`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-1`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-2`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-3`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-4`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T5-1`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T5-2`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T5-3`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T5-4`
$col
[1] "gray47"

$lty
[1] 0

$textcol
[1] "black"

$nodestyle
[1] "regular"

$srt
[1] "90"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-1->T2-1`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-2->T2-2`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-2->T2-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-3->T2-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-4->T2-2`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T1-4->T2-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-1->T3-1`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-2->T3-2`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-3->T3-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-3->T3-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-4->T3-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T2-4->T3-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-1->T4-1`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-1->T4-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-2->T4-2`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-3->T4-1`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-3->T4-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T3-4->T4-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-1->T5-1`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-2->T5-2`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-3->T5-3`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

$`T4-4->T5-4`
$nodestyle
[1] "regular"

$col
[1] "grey"

$srt
[1] "90"

$lty
[1] 1

$textcol
[1] "black"

$textcex
[1] 1

$edgecol
[1] "gradient"

$edgestyle
[1] "sin"

attr(,"class")
[1] "list"           "riverplotStyle"

--------------
[1] "calculating sizes"
$lefts
T1-1 T1-2 T1-3 T1-4 T2-1 T2-2 T2-3 T2-4 T3-1 T3-2 T3-3 T3-4 T4-1 T4-2 T4-3 T4-4 
0.00 0.00 0.00 0.00 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 
T5-1 T5-2 T5-3 T5-4 
0.45 0.45 0.45 0.45 

$rights
T1-1 T1-2 T1-3 T1-4 T2-1 T2-2 T2-3 T2-4 T3-1 T3-2 T3-3 T3-4 T4-1 T4-2 T4-3 T4-4 
0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 
T5-1 T5-2 T5-3 T5-4 
0.00 0.00 0.00 0.00 

$sizey
T1-1 T1-2 T1-3 T1-4 T2-1 T2-2 T2-3 T2-4 T3-1 T3-2 T3-3 T3-4 T4-1 T4-2 T4-3 T4-4 
0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 
T5-1 T5-2 T5-3 T5-4 
0.45 0.45 0.45 0.45 

[1] "calculating positions"
[1] 0.18
       ID x y
T1-1 T1-1 1 1
T1-2 T1-2 1 2
T1-3 T1-3 1 3
T1-4 T1-4 1 4
T2-1 T2-1 2 1
T2-2 T2-2 2 2
T2-3 T2-3 2 3
T2-4 T2-4 2 4
T3-1 T3-1 3 1
T3-2 T3-2 3 2
T3-3 T3-3 3 3
T3-4 T3-4 3 4
T4-1 T4-1 4 1
T4-2 T4-2 4 2
T4-3 T4-3 4 3
T4-4 T4-4 4 4
T5-1 T5-1 5 1
T5-2 T5-2 5 2
T5-3 T5-3 5 3
T5-4 T5-4 5 4
[1] "done"
[1] "drawing edges"
[1] "drawing nodes"

dynsbm documentation built on March 26, 2020, 7:33 p.m.