| Type: | Package |
| Title: | Handling Missing Data in Stochastic Block Models |
| Version: | 1.2.0 |
| Maintainer: | Julien Chiquet <julien.chiquet@inrae.fr> |
| Description: | When a network is partially observed (here, NAs in the adjacency matrix rather than 1 or 0 due to missing information between node pairs), it is possible to account for the underlying process that generates those NAs. 'missSBM', presented in 'Barbillon, Chiquet and Tabouy' (2022) <doi:10.18637/jss.v101.i12>, adjusts the popular stochastic block model from network data sampled under various missing data conditions, as described in 'Tabouy, Barbillon and Chiquet' (2019) <doi:10.1080/01621459.2018.1562934>. |
| URL: | https://grosssbm.github.io/missSBM/ |
| BugReports: | https://github.com/grossSBM/missSBM/issues |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| Depends: | R (≥ 3.4.0) |
| Imports: | Rcpp, methods, igraph, ggplot2, future.apply, R6, rlang, sbm, magrittr, Matrix, RSpectra |
| LinkingTo: | Rcpp, RcppArmadillo |
| Collate: | 'utils_missSBM.R' 'R6Class-networkSampling.R' 'R6Class-networkSampling_fit.R' 'R6Class-simpleSBM_fit.R' 'R6Class-missSBM_fit.R' 'R6Class-missSBM_collection.R' 'R6Class-networkSampler.R' 'R6Class-partlyObservedNetwork.R' 'RcppExports.R' 'er_network.R' 'estimateMissSBM.R' 'frenchblog2007.R' 'kmeans.R' 'missSBM-package.R' 'observeNetwork.R' 'war.R' |
| Suggests: | aricode, corrplot, future, testthat (≥ 2.1.0), covr, knitr, rmarkdown, spelling |
| VignetteBuilder: | knitr |
| Language: | en-US |
| Config/roxygen2/version: | 8.1.1 |
| NeedsCompilation: | yes |
| Packaged: | 2026-12-02 17:25:02 UTC; jchiquet |
| Author: | Julien Chiquet |
| Repository: | CRAN |
| Date/Publication: | 2026-12-02 18:50:02 UTC |
missSBM: Handling Missing Data in Stochastic Block Models
Description
When a network is partially observed (here, NAs in the adjacency matrix rather than 1 or 0 due to missing information between node pairs), it is possible to account for the underlying process that generates those NAs. 'missSBM', presented in 'Barbillon, Chiquet and Tabouy' (2022) doi:10.18637/jss.v101.i12, adjusts the popular stochastic block model from network data sampled under various missing data conditions, as described in 'Tabouy, Barbillon and Chiquet' (2019) doi:10.1080/01621459.2018.1562934.
The missSBM package provides the following top-level functions:
Details
-
observeNetworka function to draw a partially observe network from an existing, fully observed network according to a variety of sampling designs -
estimateMissSBMa function to perform inference of SBM from a partially observed under various sampling designs. -
missSBM_parama function to define the list of parameters controllingestimateMissSBM
These function leads to the manipulation of a variety of R objects instantiated from some R6 classes, with their respective fields and methods. They are all generated by the top-level functions itemized above, so that the user should generally not use their constructor or internal methods directly. The user should only have a basic understanding of the fields of each object to manipulate the output in R. The main objects are the following:
-
missSBM_fitan object that put together an SBM fit and and network sampling fit - the main point of the missSBM package ! -
missSBM_collectionan object to store a collection of missSBM_fit, ordered by number of block -
SimpleSBM_fit_noCovan object to define and store an SBM fit without covariates, on the observed dyads (designs dyad, node, block-node, block-dyad, and the covariates only in the sampling) -
SimpleSBM_fit_withCovan object to define and store an SBM fit with covariates -
SimpleSBM_fit_doubleStandardan object to define and store an SBM fit under the double-standard sampling -
SimpleSBM_fit_degreean object to define and store an SBM fit under the degree sampling -
networkSamplingan object to define and store a network sampling fit
missSBM extends some functionality of the package sbm, by inheriting from classes and methods associated to simple stochastic block models.
Author(s)
Maintainer: Julien Chiquet julien.chiquet@inrae.fr (ORCID)
Authors:
Julien Chiquet julien.chiquet@inrae.fr (ORCID)
Pierre Barbillon pierre.barbillon@agroparistech.fr (ORCID)
Timothée Tabouy timothee.tabouy@agroparistech.fr
Other contributors:
Jean-Benoist Léger jbleger@hds.utc.fr (provided C++ implementation of K-means) [contributor]
großBM team [contributor]
Pierre Barbillon pierre.barbillon@agroparistech.fr
Julien Chiquet julien.chiquet@inrae.fr
Timothée Tabouy timothee.tabouy@gmail.com
References
Pierre Barbillon, Julien Chiquet & Timothée Tabouy (2022) "missSBM: An R Package for Handling Missing Values in the Stochastic Block Model", Journal of Statistical Software, doi:10.18637/jss.v101.i12
Timothée Tabouy, Pierre Barbillon & Julien Chiquet (2019) “Variational Inference for Stochastic Block Models from Sampled Data”, Journal of the American Statistical Association, doi:10.1080/01621459.2018.1562934
See Also
Useful links:
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Base internal class for adjusting a binary Stochastic Block Model in the context of missSBM.
Description
It is not designed to be called directly by the user; see the concrete variants
SimpleSBM_fit_noCov, SimpleSBM_fit_withCov, SimpleSBM_fit_doubleStandard and
SimpleSBM_fit_degree.
Super classes
sbm::SBM -> sbm::SimpleSBM -> SimpleSBM_fit
Active bindings
typethe type of SBM (distribution of edges values, network type, presence of covariates)
nbObservedDyadsthe number of observed dyads
penaltydouble, value of the penalty term in ICL: the connectivity and the effects of the covariates are estimated on the observed dyads, which are counted instead of all the possible dyads (as sbm does for a network with missing values)
entropydouble, value of the entropy due to the clustering distribution
vExpecdouble: variational expectation of the complete log-likelihood of the observed dyads and of the blocks
loglikdouble: approximation of the log-likelihood (variational lower bound) reached
ICLdouble: the ICL (Integrated Classification Likelihood) of the SBM alone: -2 times the variational expectation of the complete log-likelihood of the observed dyads at the MAP memberships (each node in its most probable block), plus the penalty, as for missSBM_fit
Methods
Public methods
Inherited methods
SimpleSBM_fit$new()
constructor for simpleSBM_fit for missSBM purpose
Usage
SimpleSBM_fit$new(networkData, clusterInit, covarList = list())
Arguments
networkDataa structure to store network under missing data condition: either a matrix possibly with NA, or a missSBM:::partlyObservedNetwork
clusterInitInitial clustering: a vector with size
ncol(adjacencyMatrix), providing a user-defined clustering withnbBlockslevels.covarListAn optional list with M entries (the M covariates).
SimpleSBM_fit$doVEM()
method to perform estimation via variational EM
Usage
SimpleSBM_fit$doVEM( threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = FALSE )
Arguments
thresholdstop when an optimization step changes the objective function by less than threshold. Default is 1e-4.
maxIterV-EM algorithm stops when the number of iteration exceeds maxIter. Default is 10
fixPointIternumber of fix-point iterations in the Variational E step. Default is 5.
tracelogical for verbosity. Default is
FALSE.
SimpleSBM_fit$reorder()
permute group labels by order of decreasing probability
Usage
SimpleSBM_fit$reorder()
Returns
invisibly, the permutation o applied (new block k is former block
o[k]), so that the parameters of the sampling indexed by the blocks can follow
SimpleSBM_fit$get_state()
a lightweight snapshot of the mutable VEM state (as opposed to clone(),
which duplicates the whole object, including the – possibly large – network data)
Usage
SimpleSBM_fit$get_state()
SimpleSBM_fit$set_state()
restore a state previously returned by get_state()
Usage
SimpleSBM_fit$set_state(state)
Arguments
statea state, as returned by
get_state()
SimpleSBM_fit$polish_log_tau()
for each node, the log-likelihood of the observed dyads it would contribute
to each block if hard-assigned there (parameters held fixed), plus the term of the
sampling: the gains of the node swaps of missSBM_fit$polish()
Usage
SimpleSBM_fit$polish_log_tau(log_lambda = 0, ...)
Arguments
log_lambdaterm of the sampling depending on the blocks, added as is (0 for the designs whose sampling does not depend on them)
...additional arguments, not used
Returns
an N x Q matrix
SimpleSBM_fit$clone()
The objects of this class are cloneable with this method.
Usage
SimpleSBM_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Internal class for a binary SBM fit under the degree sampling design (MNAR, depending on the degrees).
Description
Without imputations (nu = NULL), the SBM is fitted on the observed dyads, as
SimpleSBM_fit_noCov: the first stage of the estimation of this design. With the
imputations of the sampling, the blocks and the connectivity are updated on the network
completed by them: the coordinate ascent of the variational bound of the degree sampling
(factorized q(Z) q(Y^m)), its third stage (see missSBM_fit). Only the pattern of the missing
dyads is used for the imputations.
It is not designed to be called directly by the user.
Super classes
sbm::SBM -> sbm::SimpleSBM -> SimpleSBM_fit -> SimpleSBM_fit_noCov -> SimpleSBM_fit_degree
Methods
Public methods
Inherited methods
sbm::SBM$print()sbm::SBM$rNetwork()sbm::SimpleSBM$plot()sbm::SimpleSBM$predict()sbm::SimpleSBM$rEdges()sbm::SimpleSBM$rMemberships()sbm::SimpleSBM$show()SimpleSBM_fit$doVEM()SimpleSBM_fit$get_state()SimpleSBM_fit$initialize()SimpleSBM_fit$reorder()SimpleSBM_fit$set_state()SimpleSBM_fit_noCov$vExpec_at()SimpleSBM_fit_noCov$vExpec_imputed()
SimpleSBM_fit_degree$update_parameters()
update parameters estimation (M-step)
Usage
SimpleSBM_fit_degree$update_parameters(nu = NULL, ...)
Arguments
nuthe imputations of the missing dyads (sparse matrix with the pattern of the missing dyads), or
NULLto fit the SBM on the observed dyads...additional arguments, not used
SimpleSBM_fit_degree$update_blocks()
update variational estimation of blocks (VE-step)
Usage
SimpleSBM_fit_degree$update_blocks(log_lambda = 0, nu = NULL, ...)
Arguments
log_lambdanot used (0 for the degree sampling)
nuthe imputations of the missing dyads, or
NULLto use the observed dyads only...additional arguments, not used
SimpleSBM_fit_degree$polish_log_tau()
for each node, the expected complete log-likelihood it would contribute to
each class if hard-assigned there (parameters and imputations held fixed), used to decide
node-swap moves in missSBM_fit$polish().
Usage
SimpleSBM_fit_degree$polish_log_tau(log_lambda = 0, nu = NULL, ...)
Arguments
log_lambdanot used (0 for the degree sampling)
nuthe imputations of the missing dyads, or
NULLto use the observed dyads only...additional arguments, not used
Returns
an N x Q matrix
SimpleSBM_fit_degree$clone()
The objects of this class are cloneable with this method.
Usage
SimpleSBM_fit_degree$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Internal class for a binary SBM fit under the double-standard sampling design (MNAR, depending on the value of each dyad).
Description
The missing dyads are integrated out given the blocks. A dyad between blocks q and l is
missing with probability m_{ql} = \pi_{ql}(1 - p_1) + (1 - \pi_{ql})(1 - p_0), where
(p_0, p_1) are the parameters of the sampling: the update of the blocks gets the term
\sum_{j} \sum_l \tau_{jl} \log m_{ql} over the missing dyads (i, j), given by the sampling
(log_lambda() of doubleStandardSampling_fit), as for the samplings depending on the
blocks. The missing dyads
tie the connectivity to (p_0, p_1): the M-step maximizes over the three jointly, by EM
on the missing dyads (the posterior probability that a missing dyad between blocks q and l
is an edge is \nu_{ql} = \pi_{ql}(1 - p_1) / m_{ql}), iterated to convergence, all in
Q x Q given the memberships.
It is not designed to be called directly by the user.
Super classes
sbm::SBM -> sbm::SimpleSBM -> SimpleSBM_fit -> SimpleSBM_fit_noCov -> SimpleSBM_fit_doubleStandard
Methods
Public methods
Inherited methods
sbm::SBM$print()sbm::SBM$rNetwork()sbm::SimpleSBM$plot()sbm::SimpleSBM$predict()sbm::SimpleSBM$rEdges()sbm::SimpleSBM$rMemberships()sbm::SimpleSBM$show()SimpleSBM_fit$doVEM()SimpleSBM_fit$get_state()SimpleSBM_fit$initialize()SimpleSBM_fit$polish_log_tau()SimpleSBM_fit$reorder()SimpleSBM_fit$set_state()SimpleSBM_fit_noCov$update_blocks()SimpleSBM_fit_noCov$vExpec_at()SimpleSBM_fit_noCov$vExpec_imputed()
SimpleSBM_fit_doubleStandard$update_parameters()
update parameters estimation (M-step)
Usage
SimpleSBM_fit_doubleStandard$update_parameters( psi = NULL, tol = 1e-08, maxit = 10000 )
Arguments
psithe parameters (p0, p1) of the sampling, starting point of the joint M-step. If
NULL, or with a single block (where the sampling is constrained to dyad sampling), the SBM is fitted on the observed dyads.tol, maxittolerance on the parameters and maximal number of iterations of the EM on the missing dyads
Returns
invisibly, the updated (p0, p1), or NULL if the SBM is fitted on the
observed dyads
SimpleSBM_fit_doubleStandard$clone()
The objects of this class are cloneable with this method.
Usage
SimpleSBM_fit_doubleStandard$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Internal class for a binary SBM fit on the observed dyads, without covariates: MAR sampling designs, 'block-node' and 'block-dyad' (with their sampling term in the update of the blocks) and 'degree'.
Description
It is not designed to be called directly by the user.
Super classes
sbm::SBM -> sbm::SimpleSBM -> SimpleSBM_fit -> SimpleSBM_fit_noCov
Active bindings
imputationthe matrix of imputed values
Methods
Public methods
Inherited methods
sbm::SBM$print()sbm::SBM$rNetwork()sbm::SimpleSBM$plot()sbm::SimpleSBM$predict()sbm::SimpleSBM$rEdges()sbm::SimpleSBM$rMemberships()sbm::SimpleSBM$show()SimpleSBM_fit$doVEM()SimpleSBM_fit$get_state()SimpleSBM_fit$initialize()SimpleSBM_fit$polish_log_tau()SimpleSBM_fit$reorder()SimpleSBM_fit$set_state()
SimpleSBM_fit_noCov$update_parameters()
update parameters estimation (M-step)
Usage
SimpleSBM_fit_noCov$update_parameters(...)
Arguments
...additional arguments, only required for MNAR cases
SimpleSBM_fit_noCov$update_blocks()
update variational estimation of blocks (VE-step)
Usage
SimpleSBM_fit_noCov$update_blocks(log_lambda = 0, ...)
Arguments
log_lambdan x Q matrix, the term of the sampling in the update of the blocks (
log_lambda()of the sampling: 'block-node', 'block-dyad', 'double-standard'), added to the term of the observed dyads; 0 when the sampling does not depend on the blocks...additional arguments, only required for MNAR cases
SimpleSBM_fit_noCov$vExpec_imputed()
variational expectation of the log-likelihood of the missing dyads, given their imputations (used by the ICL of 'degree', see missSBM_fit)
Usage
SimpleSBM_fit_noCov$vExpec_imputed(nu, Z = private$Z)
Arguments
nuthe imputations of the missing dyads (sparse matrix with the pattern of the missing dyads)
Zan n x Q matrix of memberships (default: the current variational ones)
SimpleSBM_fit_noCov$vExpec_at()
variational expectation of the log-likelihood of the observed dyads and of the blocks at given memberships (used by the ICL, at the MAP memberships)
Usage
SimpleSBM_fit_noCov$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
SimpleSBM_fit_noCov$clone()
The objects of this class are cloneable with this method.
Usage
SimpleSBM_fit_noCov$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Internal class for a binary SBM fit under MAR sampling designs with covariates.
Description
It is not designed to be called directly by the user.
Super classes
sbm::SBM -> sbm::SimpleSBM -> SimpleSBM_fit -> SimpleSBM_fit_withCov
Active bindings
imputationthe matrix of imputed values
Methods
Public methods
Inherited methods
sbm::SBM$print()sbm::SBM$rNetwork()sbm::SimpleSBM$plot()sbm::SimpleSBM$predict()sbm::SimpleSBM$rEdges()sbm::SimpleSBM$rMemberships()sbm::SimpleSBM$show()SimpleSBM_fit$doVEM()SimpleSBM_fit$get_state()SimpleSBM_fit$initialize()SimpleSBM_fit$polish_log_tau()SimpleSBM_fit$reorder()SimpleSBM_fit$set_state()
SimpleSBM_fit_withCov$update_parameters()
update parameters estimation (M-step) via Newton-Raphson: the M-step objective is a weighted logistic regression (concave), so Newton converges in a handful of iterations – no external optimizer is required.
Usage
SimpleSBM_fit_withCov$update_parameters(...)
Arguments
...use for compatibility
SimpleSBM_fit_withCov$update_blocks()
update variational estimation of blocks (VE-step)
Usage
SimpleSBM_fit_withCov$update_blocks(...)
Arguments
...use for compatibility
SimpleSBM_fit_withCov$vExpec_at()
variational expectation of the log-likelihood of the observed dyads and of the blocks at given memberships (used by the ICL, at the MAP memberships)
Usage
SimpleSBM_fit_withCov$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
SimpleSBM_fit_withCov$clone()
The objects of this class are cloneable with this method.
Usage
SimpleSBM_fit_withCov$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a block dyad sampler
Description
Class for defining a block dyad sampler
Super classes
networkSampling -> networkSampler -> dyadSampler -> blockDyadSampler
Active bindings
dfthe number of parameters of this sampling
Methods
Public methods
Inherited methods
blockDyadSampler$new()
constructor for networkSampling
Usage
blockDyadSampler$new( parameters = NA, nbNodes = NA, directed = FALSE, clusters = NA )
Arguments
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
clustersa vector of class memberships
blockDyadSampler$clone()
The objects of this class are cloneable with this method.
Usage
blockDyadSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a block-dyad sampling
Description
Class for fitting a block-dyad sampling
Super classes
networkSampling -> networkSampling_fit -> networkSamplingDyads_fit -> blockDyadSampling_fit
Active bindings
dfthe number of parameters:
Q^2, orQ(Q+1)/2in an undirected network (\psiis symmetric)
Methods
Public methods
Inherited methods
blockDyadSampling_fit$new()
constructor
Usage
blockDyadSampling_fit$new(partlyObservedNetwork, blockInit)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
blockInitn x Q matrix of initial block indicators
blockDyadSampling_fit$update_parameters()
update the parameters: the observation rate of the dyads between each pair
of blocks, \hat\psi_{q\ell} = (Z^\top R Z)_{q\ell} / (Z^\top (R + \bar R) Z)_{q\ell},
symmetrized in an undirected network (where R and \bar R only hold the upper
triangle)
Usage
blockDyadSampling_fit$update_parameters(Z, ...)
Arguments
Zprobabilities of block memberships
...use for compatibility
blockDyadSampling_fit$reorder()
permute the parameters indexed by the blocks, after the blocks of the SBM were permuted
Usage
blockDyadSampling_fit$reorder(o)
Arguments
othe permutation applied to the blocks (new block k is former block
o[k])
blockDyadSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling at given
memberships: the expectation of the log (not the log of the expectation), consistent
with the update of psi and with log_lambda, computed through Z^\top R Z and
Z^\top \bar R Z, without any n x n matrix
Usage
blockDyadSampling_fit$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
blockDyadSampling_fit$log_lambda()
the term of the sampling in the update of the blocks: for each node i and
block q, \sum_j \sum_l Z_{jl} \log \psi_{ql} over its observed dyads (i, j), plus
the same with \log(1 - \psi_{ql}) over its missing dyads
Usage
blockDyadSampling_fit$log_lambda(Z)
Arguments
Zan n x Q matrix of memberships
blockDyadSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
blockDyadSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a block node sampler
Description
Class for defining a block node sampler
Super classes
networkSampling -> networkSampler -> nodeSampler -> blockNodeSampler
Methods
Public methods
Inherited methods
blockNodeSampler$new()
constructor for networkSampling
Usage
blockNodeSampler$new( parameters = NA, nbNodes = NA, directed = FALSE, clusters = NA )
Arguments
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
clustersa vector of class memberships
blockNodeSampler$clone()
The objects of this class are cloneable with this method.
Usage
blockNodeSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a block-node sampling
Description
Class for fitting a block-node sampling
Super classes
networkSampling -> networkSampling_fit -> networkSamplingNodes_fit -> blockNodeSampling_fit
Methods
Public methods
Inherited methods
blockNodeSampling_fit$new()
constructor
Usage
blockNodeSampling_fit$new(partlyObservedNetwork, blockInit)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
blockInitn x Q matrix of initial block indicators
blockNodeSampling_fit$update_parameters()
update the parameters: the observation rate of the nodes of each block
Usage
blockNodeSampling_fit$update_parameters(Z, ...)
Arguments
Zprobabilities of block memberships
...use for compatibility
blockNodeSampling_fit$reorder()
permute the parameters indexed by the blocks, after the blocks of the SBM were permuted
Usage
blockNodeSampling_fit$reorder(o)
Arguments
othe permutation applied to the blocks (new block k is former block
o[k])
blockNodeSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling at given memberships (used by the ICL, at the MAP memberships)
Usage
blockNodeSampling_fit$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
blockNodeSampling_fit$log_lambda()
the term of the sampling in the update of the blocks: \log \psi_q for
an observed node, \log(1 - \psi_q) for a missing one
Usage
blockNodeSampling_fit$log_lambda(Z = NULL)
Arguments
Znot used: the sampling of a node only depends on its own block
blockNodeSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
blockNodeSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Extract model coefficients
Description
Extracts model coefficients from objects missSBM_fit returned by estimateMissSBM()
Usage
## S3 method for class 'missSBM_fit'
coef(
object,
type = c("mixture", "connectivity", "covariates", "sampling"),
...
)
Arguments
object |
an R6 object with class |
type |
type of parameter that should be extracted. Either "mixture" (default), "connectivity", "covariates" or "sampling" |
... |
additional parameters for S3 compatibility. Not used |
Value
A vector or matrix of coefficients extracted from the missSBM_fit model.
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
myModel <- collection$bestModel
coef(myModel, "mixture")
coef(myModel, "connectivity")
coef(myModel, "sampling")
Class for fitting a dyad sampling with covariates
Description
Class for fitting a dyad sampling with covariates
Super classes
networkSampling -> networkSampling_fit -> networkSamplingDyads_fit -> covarDyadSampling_fit
Methods
Public methods
Inherited methods
covarDyadSampling_fit$new()
constructor
Usage
covarDyadSampling_fit$new(partlyObservedNetwork, ...)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
...used for compatibility
covarDyadSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling
Usage
covarDyadSampling_fit$vExpec_at(Z = NULL)
Arguments
Znot used: the sampling does not depend on the blocks
covarDyadSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
covarDyadSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a node-centered sampling with covariate
Description
Class for fitting a node-centered sampling with covariate
Super classes
networkSampling -> networkSampling_fit -> networkSamplingNodes_fit -> covarNodeSampling_fit
Methods
Public methods
Inherited methods
covarNodeSampling_fit$new()
constructor
Usage
covarNodeSampling_fit$new(partlyObservedNetwork, ...)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
...used for compatibility
covarNodeSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling
Usage
covarNodeSampling_fit$vExpec_at(Z = NULL)
Arguments
Znot used: the sampling does not depend on the blocks
covarNodeSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
covarNodeSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a degree sampler
Description
Class for defining a degree sampler
Super classes
networkSampling -> networkSampler -> nodeSampler -> degreeSampler
Methods
Public methods
Inherited methods
degreeSampler$new()
constructor for networkSampling
Usage
degreeSampler$new(parameters = NA, degrees = NA, directed = FALSE)
Arguments
parametersthe vector of parameters associated to the sampling at play
degreesvector of nodes' degrees
directedlogical, directed network of not
degreeSampler$clone()
The objects of this class are cloneable with this method.
Usage
degreeSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a degree sampling
Description
Class for fitting a degree sampling
Super classes
networkSampling -> networkSampling_fit -> networkSamplingNodes_fit -> degreeSampling_fit
Methods
Public methods
Inherited methods
degreeSampling_fit$new()
constructor
Usage
degreeSampling_fit$new(partlyObservedNetwork, blockInit, connectInit)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
blockInitn x Q matrix of initial block indicators
connectInitQ x Q matrix of initial block probabilities of connection
degreeSampling_fit$update_parameters()
update the parameters given the imputations: the expected degrees, the parameters zeta of the bound of Jaakkola and Jordan, then (a, b)
Usage
degreeSampling_fit$update_parameters(nu, ...)
Arguments
nuthe imputations of the missing dyads (sparse matrix with the pattern of the missing dyads)
...used for compatibility
degreeSampling_fit$update_imputation()
a method to update the imputation of the missing entries.
Usage
degreeSampling_fit$update_imputation(PI, ...)
Arguments
PIthe matrix of inter/intra class probability of connection
...use for compatibility
degreeSampling_fit$vExpec_at()
lower bound of the variational expectation of the log-likelihood of the
sampling, by the bound of Jaakkola and Jordan: with x_i = a + b D_i,
\log \sigma(x) \geq \log \sigma(\zeta) + (x - \zeta)/2 + h(\zeta)(x^2 - \zeta^2)
and \log(1 - \sigma(x)) = \log \sigma(x) - x, in expectation over the imputations
Usage
degreeSampling_fit$vExpec_at(Z = NULL)
Arguments
Znot used: the sampling depends on the imputations, not on the blocks
degreeSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
degreeSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a double-standard sampler
Description
Class for defining a double-standard sampler
Super classes
networkSampling -> networkSampler -> dyadSampler -> doubleStandardSampler
Methods
Public methods
Inherited methods
doubleStandardSampler$new()
constructor for networkSampling
Usage
doubleStandardSampler$new(parameters = NA, adjMatrix = NA, directed = FALSE)
Arguments
parametersthe vector of parameters associated to the sampling at play
adjMatrixmatrix of adjacency
directedlogical, directed network of not
doubleStandardSampler$clone()
The objects of this class are cloneable with this method.
Usage
doubleStandardSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a double-standard sampling
Description
A dyad is observed with probability p_0 if it is 0, p_1 if it is 1 (the vector of
parameters is (p_0, p_1)). Given the blocks, a dyad between blocks q and l is missing
with probability m_{ql} = \pi_{ql}(1 - p_1) + (1 - \pi_{ql})(1 - p_0): the missing dyads
are integrated out given the blocks, and the posterior probability that a missing dyad between
blocks q and l is an edge is \nu_{ql} = \pi_{ql}(1 - p_1) / m_{ql}, a Q x Q matrix.
The parameters are updated jointly with the connectivity of the SBM (see
SimpleSBM_fit_doubleStandard): this class only stores them, with the terms of the sampling.
With a single block, (\pi, p_0, p_1) are not identifiable: the observed data only inform
\pi p_1 and (1 - \pi) p_0. The fit is then constrained to p_0 = p_1, that is,
to dyad sampling, with one parameter.
Super classes
networkSampling -> networkSampling_fit -> networkSamplingDyads_fit -> doubleStandardSampling_fit
Active bindings
dfthe number of parameters: 2, or 1 with a single block (p0 = p1)
blockImputationQ x Q matrix, the posterior probability that a missing dyad between blocks q and l is an edge, with the current parameters
Methods
Public methods
Inherited methods
doubleStandardSampling_fit$new()
constructor
Usage
doubleStandardSampling_fit$new(partlyObservedNetwork, blockInit, connectInit)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
blockInitn x Q matrix of initial block indicators
connectInitQ x Q matrix of initial connectivity of the SBM
doubleStandardSampling_fit$update_parameters()
stores the parameters, updated jointly with the connectivity of the SBM (see SimpleSBM_fit_doubleStandard), and the current blocks
Usage
doubleStandardSampling_fit$update_parameters(Z, theta, psi = NULL, ...)
Arguments
Zprobabilities of block memberships
thetathe connectivity of the SBM
psithe updated (p0, p1);
NULLwith a single block, where p0 = p1 is the observation rate (dyad sampling)...use for compatibility
doubleStandardSampling_fit$reorder()
permute the parameters indexed by the blocks, after the blocks of the SBM were permuted
Usage
doubleStandardSampling_fit$reorder(o)
Arguments
othe permutation applied to the blocks (new block k is former block
o[k])
doubleStandardSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling at given
memberships, the missing dyads being integrated out given the blocks:
E_\tau[\log p(R \mid Y^o, Z)]
Usage
doubleStandardSampling_fit$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
doubleStandardSampling_fit$log_lambda()
the term of the missing dyads in the update of the blocks: for each node i
and block q, \sum_j \sum_l Z_{jl} \log m_{ql} over the missing dyads (i, j) (the
observed dyads give a term that does not depend on the blocks)
Usage
doubleStandardSampling_fit$log_lambda(Z)
Arguments
Zan n x Q matrix of memberships
doubleStandardSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
doubleStandardSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Virtual class for all dyad-centered samplers
Description
Virtual class for all dyad-centered samplers
Super classes
networkSampling -> networkSampler -> dyadSampler
Methods
Public methods
Inherited methods
dyadSampler$new()
constructor for networkSampling
Usage
dyadSampler$new(type = NA, parameters = NA, nbNodes = NA, directed = FALSE)
Arguments
typecharacter for the type of sampling. must be in ("dyad", "covar-dyad", "node", "covar-node", "block-node", "block-dyad", "double-standard", "degree")
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
dyadSampler$clone()
The objects of this class are cloneable with this method.
Usage
dyadSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a dyad sampling
Description
Class for fitting a dyad sampling
Super classes
networkSampling -> networkSampling_fit -> networkSamplingDyads_fit -> dyadSampling_fit
Methods
Public methods
Inherited methods
dyadSampling_fit$new()
constructor
Usage
dyadSampling_fit$new(partlyObservedNetwork, ...)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
...used for compatibility
dyadSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling
Usage
dyadSampling_fit$vExpec_at(Z = NULL)
Arguments
Znot used: the sampling does not depend on the blocks
dyadSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
dyadSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
ER ego centered network
Description
A dataset containing the weighted PPI network centered around the ESR1 (ER) protein
Usage
er_network
Format
A sparse symmetric matrix with 741 rows and 741 columns ESR1
Source
Examples
data("er_network")
class(er_network)
Estimation of simple SBMs with missing data
Description
Variational EM inference of Stochastic Block Models indexed by block number from a partially observed network.
Usage
estimateMissSBM(
adjacencyMatrix,
vBlocks,
sampling,
covariates = list(),
control = missSBM_param()
)
Arguments
adjacencyMatrix |
The N x N adjacency matrix of the network data. If |
vBlocks |
The vector of number of blocks considered in the collection. |
sampling |
The sampling design, the model of the process that originates the missing data: MAR designs ("dyad", "node", "covar-dyad", "covar-node", "snowball") and MNAR designs ("double-standard", "block-dyad", "block-node", "degree") are available. See details. |
covariates |
An optional list with M entries (the M covariates). If the covariates are node-centered, each entry of |
control |
a list-like structure for controlling advanced features, with default generated
by |
Details
Internal functions use future_lapply, so set your plan to 'multisession' or
'multicore' to use several cores/workers.
The sampling designs are either Missing At Random (MAR) or Missing Not At Random (MNAR), and observe either dyads or nodes (all the dyads of an observed node). See doi:10.1080/01621459.2018.1562934 for a complete description. The parameters of each design:
Missing At Random (MAR)
"dyad": p, the probability that a dyad is observed.
"node": p, the probability that a node is observed.
"covar-dyad":
\beta \in R^M, a dyad (i, j) being observed with probabilitylogistic(\beta' x_{ij}),x_{ij}the covariates of the dyad."covar-node":
\beta \in R^M, a node i being observed with probabilitylogistic(\beta' x_i),x_ithe covariates of the node."snowball": (number of waves, proportion of the nodes observed in the first wave); the nodes of each wave are the neighbors of the nodes of the previous one. It is fitted as "node" sampling.
Missing Not At Random (MNAR)
"double-standard": (p0, p1), the probabilities that a dyad is observed if it is 0 and if it is 1. (p0, p1) are identified through the differences of connectivity between the blocks: with a single block, they are not identifiable, and the model is fitted with p0 = p1, i.e. as dyad sampling (with a warning).
"block-node":
(p_1, \dots, p_Q),p_qthe probability that a node of block q is observed."block-dyad": the Q x Q matrix
(p_{ql}),p_{ql}the probability that a dyad between blocks q and l is observed."degree": (a, b), a node i being observed with probability
logistic(a + b D_i),D_iits degree.
The number of blocks is selected by the ICL (Integrated Classification Likelihood,
the smaller the better): -2 times the variational lower bound of the log-likelihood of the
observed data (the observed dyads and the sampling matrix), at the MAP memberships, plus a
penalty, in which the connectivity counts the observed dyads and the parameters of the sampling
all the dyads (or all the nodes). The ICLs of different designs fitted to the same data can be
compared to choose the design. When their samplings carry the same information (e.g.
"block-node" and "degree" on an assortative network, where the degree depends on the block),
the ICLs differ by a few units, about the penalty of one parameter (log N), and the partitions
are the same: such a difference is no evidence for one design. Each number of blocks is fitted
from a spectral clustering, then improved by a polish and by passes of exploration splitting
and merging blocks (see missSBM_param); one pass is enough on small networks,
two are advised for a reference analysis of a network with many blocks.
Value
Returns an R6 object with class missSBM_collection.
See Also
observeNetwork, missSBM_collection, missSBM_fit and missSBM_param.
Examples
## SBM parameters
N <- 100 # number of nodes
Q <- 3 # number of blocks
pi <- rep(1,Q)/Q # block proportion
theta <- list(mean = diag(.45,Q) + .05 ) # connectivity matrix
## Sampling parameters
samplingParameters <- .75 # the sampling rate
sampling <- "dyad" # the sampling design
## generate an undirected binary SBM with no covariate
sbm <- sbm::sampleSimpleSBM(N, pi, theta)
## Uncomment to set parallel computing with future
## future::plan("multicore", workers = 2)
## Sample some dyads data + Infer SBM with missing data
collection <-
observeNetwork(sbm$networkData, sampling, samplingParameters) %>%
estimateMissSBM(vBlocks = 1:4, sampling = sampling)
plot(collection, "monitoring")
plot(collection, "icl")
collection$ICL
coef(collection$bestModel$fittedSBM, "connectivity")
myModel <- collection$bestModel
plot(myModel, "expected")
plot(myModel, "imputed")
plot(myModel, "meso")
coef(myModel, "sampling")
coef(myModel, "connectivity")
predict(myModel)[1:5, 1:5]
Extract model fitted values from object missSBM_fit, return by estimateMissSBM()
Description
Extract model fitted values from object missSBM_fit, return by estimateMissSBM()
Usage
## S3 method for class 'missSBM_fit'
fitted(object, ...)
Arguments
object |
an R6 object with class |
... |
additional parameters for S3 compatibility. |
Value
A matrix of estimated probabilities of connection
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
myModel <- collection$bestModel
fitted(myModel)[1:5, 1:5]
Political Blogosphere network prior to 2007 French presidential election
Description
French Political Blogosphere network dataset consists of a single day snapshot of over 200 political blogs automatically extracted the 14 October 2006 and manually classified by the "Observatoire Présidentielle" project. Originally part of the 'mixer' package
Usage
frenchblog2007
Format
An igraph object with 196 nodes. The vertex attribute "party" provides a possible clustering of the nodes.
Source
The "Observatoire Présidentielle" project of Linkfluence (now part of Meltwater); the network was distributed in the package 'mixer', archived on CRAN: https://CRAN.R-project.org/package=mixer
Examples
data(frenchblog2007)
igraph::V(frenchblog2007)$party
igraph::plot.igraph(frenchblog2007,
vertex.color = factor(igraph::V(frenchblog2007)$party),
vertex.label = NA
)
L1-similarity
Description
Compute l1-similarity between two vectors
Usage
l1_similarity(x, y)
Arguments
x |
a vector |
y |
a vector |
Value
a vector equal to -abs(x-y)
Examples
l1_similarity(1:5, 5:1)
An R6 class to represent a collection of SBM fits with missing data
Description
The function estimateMissSBM() fits a collection of SBM with missing data for
a varying number of block. These models with class missSBM_fit are stored in an instance
of an object with class missSBM_collection, described here.
Fields are accessed via active binding and cannot be changed by the user.
This class comes with a set of R6 methods, some of them being useful for the user and exported
as S3 methods. See the documentation for show() and print()
Active bindings
modelsa list of models
ICLthe vector of the ICL (Integrated Classification Likelihood, the smaller the better) of the models of the collection, see missSBM_fit
bestModelthe best model according to the ICL, restricted to models without collapsed classes when at least one such model is available (see
$degenerate)vBlocksa vector with the number of blocks
occupiedBlocksa vector with the number of classes actually occupied in each model (see missSBM_fit's
occupiedBlocks)degeneratelogical vector,
TRUEfor models with collapsed classes (occupiedBlocks < vBlocks, see missSBM_fit'srepair())optimizationSettingsthe control list used by estimate()/polish()/explore() when not overridden per call (set at construction by
estimateMissSBM())optimizationStatusa data.frame summarizing the optimization process for all models
Methods
Public methods
missSBM_collection$new()
constructor for networkSampling
Usage
missSBM_collection$new(partlyObservedNet, sampling, clusterInit, control)
Arguments
partlyObservedNetAn object with class
partlyObservedNetwork.samplingThe sampling design for the modelling of missing data: MAR designs ("dyad", "node") and MNAR designs ("double-standard", "block-dyad", "block-node" ,"degree")
clusterInitInitial clustering: a list of vectors, each with size
ncol(adjacencyMatrix).controla list of parameters controlling advanced features. Only 'trace' and 'useCov' are relevant here. See
estimateMissSBM()for details.
missSBM_collection$estimate()
method to launch the estimation of the collection of models
Usage
missSBM_collection$estimate(control = NULL)
Arguments
controloptional list of parameters overriding the collection's stored control (set at construction by
estimateMissSBM(), see its details for the full list). DefaultNULLuses the stored control as-is.
missSBM_collection$estimate_chain()
alternative to estimate(): fits each model in increasing order of
number of blocks, initializing vBlocks[k] by splitting (see missSBM_fit's
split()/candidates_split()) the already-converged model at
vBlocks[k-1] instead of an independent, cold spectral clustering. Meant to reduce
VEM component collapse at higher numbers of blocks (see $degenerate), at the cost
of being sequential in the number of blocks (unlike estimate(), which fits every
model in parallel) – can be slower in wall-clock time with many workers available.
Falls back to this slot's own cold-started clustering (built at construction, same as
estimate() would use) whenever nothing is splittable along the chain.
Usage
missSBM_collection$estimate_chain(control = NULL)
Arguments
controloptional list of parameters overriding the collection's stored control (set at construction by
estimateMissSBM(), see its details for the full list). DefaultNULLuses the stored control as-is.
missSBM_collection$polish()
method to node-swap-polish every model in the collection (see
missSBM_fit's polish()); fixes individually misclassified nodes at each
model's own number of blocks, unlike explore() which searches across blocks.
Usage
missSBM_collection$polish(control = NULL)
Arguments
controloptional list of parameters overriding the collection's stored control (set at construction by
estimateMissSBM(), see its details for the full list). DefaultNULLuses the stored control as-is.
missSBM_collection$explore()
method for performing exploration of the ICL (split/merge search across
numbers of blocks, see missSBM_fit's candidates_split()/candidates_merge()).
Uses the collection's stored control by default; iterates lets the caller override
it for this call only, without altering the stored control – handy to alternate
explore()/polish() calls without having to reconstruct a full control list
each time. iterates <= 0 is a no-op.
Usage
missSBM_collection$explore(control = NULL, iterates = NULL, direction = "both")
Arguments
controloptional list of parameters overriding the collection's stored control (set at construction by
estimateMissSBM(), see its details for the full list). DefaultNULLuses the stored control as-is.iteratesoptional integer overriding
control$iteratesfor this call only.directioncharacter ("forward", "backward", "both" or "none") controlling which directions are searched. Default "both".
missSBM_collection$plot()
plot method for missSBM_collection
Usage
missSBM_collection$plot(type = c("icl", "elbo", "monitoring"))
Arguments
typethe type specifies the field to plot, either "icl", "elbo" or "monitoring". Default is "icl"
missSBM_collection$show()
show method for missSBM_collection
Usage
missSBM_collection$show()
missSBM_collection$print()
User friendly print method
Usage
missSBM_collection$print()
missSBM_collection$clone()
The objects of this class are cloneable with this method.
Usage
missSBM_collection$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## Uncomment to set parallel computing with future
## future::plan("multicore", workers = 2)
## Sample 75% of dyads in French political Blogosphere's network data
adjacencyMatrix <- missSBM::frenchblog2007 %>%
igraph::delete_vertices(1:100) %>%
igraph::as_adjacency_matrix() %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.75)
collection <- estimateMissSBM(adjacencyMatrix, 1:5, sampling = "dyad")
class(collection)
An R6 class to represent an SBM fit with missing data
Description
The function estimateMissSBM() fits a collection of SBM for varying number of block.
Each fitted SBM is an instance of an R6 object with class missSBM_fit, described here.
This class implements the designs whose missing dyads are integrated out given the blocks
("dyad", "node", "covar-dyad", "covar-node", "block-node", "block-dyad", "snowball"). The two
other designs have their own classes, inheriting from it: missSBM_fit_doubleStandard
(missing dyads integrated out too, with a joint update of the connectivity and of the sampling
parameters) and missSBM_fit_degree (missing dyads that cannot be integrated out, imputed by
variational parameters). Use new_missSBM_fit() to build the fit of any design.
Fields are accessed via active binding and cannot be changed by the user.
This class comes with a set of R6 methods, some of them being useful for the user and exported
as S3 methods. See the documentation for show(), print(), fitted(), predict(), plot().
Active bindings
fittedSBMthe fitted SBM with class
SimpleSBM_fit_noCov,SimpleSBM_fit_withCov,SimpleSBM_fit_degreeorSimpleSBM_fit_doubleStandardinheriting from classsbm::SimpleSBM_fitfittedSamplingthe fitted sampling, inheriting from class
networkSamplingand corresponding fitsimputedNetworkThe network data as a matrix with NAs values imputed with the current model
monitoringa list carrying information about the optimization process
occupiedBlocksthe number of classes actually occupied by at least one node; can be less than
fittedSBM$nbBlocksfor an over-specified fit whose VEM has collapsed one or more classes (seerepair())degenerateTRUEifoccupiedBlocks < fittedSBM$nbBlocksimputationsthe variational parameters of the missing dyads (sparse matrix with their pattern), for the designs whose missing dyads cannot be integrated out (
missSBM_fit_degree);NULLfor the other designs, which integrate them out given the blocks (seeimputedNetworkfor the imputed network of any design)entropyImputedthe entropy of the variational distribution of the missing dyads (0 when they are integrated out given the blocks)
entropythe entropy of the variational distribution: of the blocks, and of the missing dyads when they are not integrated out
vExpecdouble: variational expectation of the log-likelihood of the observed data (the observed dyads and the sampling matrix) and of the blocks, and of the missing dyads when they are not integrated out
penaltydouble, value of the penalty term in the ICL: the connectivity of the SBM (and the effects of the covariates) counts the observed dyads, on which it is estimated, the parameters of the sampling all the dyads (or all the nodes), as the sampling matrix is fully observed
loglikdouble: approximation of the log-likelihood (variational lower bound) reached
ICLdouble: the ICL (Integrated Classification Likelihood, the smaller the better), built on the observed data (the observed dyads and the sampling matrix), the missing dyads being integrated out: -2 times the variational lower bound of the log-likelihood of the observed data and of the blocks, evaluated at the MAP memberships (hard assignment of each node to its most probable block), plus the penalty. When the missing dyads cannot be integrated out (
missSBM_fit_degree), the bound includes the expected log-likelihood and the entropy of their variational distribution.
Methods
Public methods
missSBM_fit$new()
constructor for networkSampling
Usage
missSBM_fit$new(partlyObservedNet, netSampling, clusterInit, useCov = TRUE)
Arguments
partlyObservedNetAn object with class
partlyObservedNetwork.netSamplingThe sampling design for the modelling of missing data (see
estimateMissSBM()), one of the designs of the class: "double-standard" formissSBM_fit_doubleStandard, "degree" formissSBM_fit_degree, the others formissSBM_fit(seenew_missSBM_fit())clusterInitInitial clustering: a vector with size
ncol(adjacencyMatrix), providing a user-defined clustering. The number of blocks is deduced from the number of levels in withclusterInit.useCovlogical. If covariates are present in partlyObservedNet, should they be used for the inference or of the network sampling design, or just for the SBM inference? default is TRUE.
missSBM_fit$doVEM()
a method to perform inference of the current missSBM fit with variational EM
Usage
missSBM_fit$doVEM( control = list(threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = TRUE) )
Arguments
controla list of VEM control parameters (see
estimateMissSBM())
missSBM_fit$split()
clone of the current fit after splitting block index in two, via a
spectral bipartition of the sub-network it induces. Builds but does not fit the
candidate (see candidates_split()).
Usage
missSBM_fit$split(index, in_place = FALSE, base_net = NULL)
Arguments
indexindex (integer) of the block to split
in_placereplace
self's own fit (TRUE) or return a new object (FALSE, the default)?base_netoptional precomputed network to bipartition (as built internally at the top of this method); lets
candidates_split()avoid recomputing it once per candidate.
Returns
a new missSBM_fit with one more block, or NULL if index cannot
be split (its induced sub-network has zero variance)
missSBM_fit$candidates_split()
generate and cheaply trial-fit candidates obtained by splitting each
splittable block in two (see split()). A block is splittable if it has at
least 4 members and non-zero variance in its induced sub-network.
Usage
missSBM_fit$candidates_split( control = list(threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = TRUE), trial_niter = 2 )
Arguments
controla list of VEM control parameters (see
estimateMissSBM());maxIteris overridden bytrial_nitertrial_niternumber of VEM iterations used for the trial fits. Default is 2.
Returns
a list of trial-fitted missSBM_fit candidates (one per splittable block)
missSBM_fit$merge()
clone of the current fit after merging blocks indices[1] and
indices[2] into one. Builds but does not fit the candidate (see
candidates_merge()).
Usage
missSBM_fit$merge(indices, in_place = FALSE)
Arguments
indicesindices (couple of integers) of the blocks to merge
in_placereplace
self's own fit (TRUE) or return a new object (FALSE, the default)?
Returns
a new missSBM_fit with one fewer block
missSBM_fit$candidates_merge()
generate and cheaply trial-fit candidates obtained by merging pairs of
blocks (see merge()). Beyond max_candidates pairs (quadratic in the
number of blocks), only the most similar-connectivity pairs are tried.
Usage
missSBM_fit$candidates_merge( control = list(threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = TRUE), max_candidates = 30, trial_niter = 2 )
Arguments
controla list of VEM control parameters (see
estimateMissSBM());maxIteris overridden bytrial_nitermax_candidatescap on the number of pairs tried. Default is 30.
trial_niternumber of VEM iterations used for the trial fits. Default is 2.
Returns
a list of trial-fitted missSBM_fit candidates
missSBM_fit$repair()
recovers a degenerate fit (fewer occupied classes than its structural
nbBlocks, e.g. after a VEM component collapse) by filling the empty classes (see
repair_empty_classes()) and refitting the full VEM. Mutates self in place;
a no-op if the fit is not degenerate.
Usage
missSBM_fit$repair( control = list(threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = TRUE) )
Arguments
controla list of VEM control parameters (see
estimateMissSBM())
Returns
invisibly, self
missSBM_fit$polish()
discrete node-swap polishing (Kernighan-Lin / greedy-ICL style): after VEM
convergence, tau is near-hard and its fixed point cannot relocate a single
misclassified node (only split()/merge() fix group-level mistakes). Each
sweep computes, for every node, the closed-form complete-data log-likelihood gain of
moving it to its best alternative class (theta/pi held fixed), applies the improving,
non-class-emptying moves, then runs a full VEM to resettle. Stops as soon as a sweep
fails to improve the ICL, mutates self in place, and never leaves the ICL worse
than before the call.
Usage
missSBM_fit$polish( control = list(threshold = 0.01, maxIter = 100, fixPointIter = 3, trace = TRUE), max_sweeps = 10 )
Arguments
controla list of VEM control parameters (see
estimateMissSBM())max_sweepsmaximum number of swap sweeps. Default is 10.
Returns
invisibly, self
missSBM_fit$show()
show method for missSBM_fit
Usage
missSBM_fit$show()
missSBM_fit$print()
User friendly print method
Usage
missSBM_fit$print()
missSBM_fit$clone()
The objects of this class are cloneable with this method.
Usage
missSBM_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## Sample 75% of dyads in French political Blogosphere's network data
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.75)
collection <- estimateMissSBM(adjMatrix, 3:5, sampling = "dyad")
my_missSBM_fit <- collection$bestModel
class(my_missSBM_fit)
plot(my_missSBM_fit, "imputed")
An R6 class to represent an SBM fit under the degree sampling
Description
Inherits from missSBM_fit. A node is observed with a probability that depends
on its degree, i.e. on a whole row of the network: the missing dyads cannot be integrated out
given the blocks. Their variational distribution is factorized, with one parameter per missing
dyad (the field imputations), and the expectation of the sampling term is bounded below
by the bound of Jaakkola and Jordan. The variational EM runs in three stages, each stopping on
the objective it increases:
the SBM part on the observed dyads, stopping on its bound (the VEM of a MAR design);
the sampling part (imputations, (a, b), zeta) given the SBM part, to convergence;
the coordinate ascent of the bound of the model in all the variables: the blocks and the connectivity are updated on the network completed by the imputations, the sampling part converged at each M-step. Starting the coordinate ascent from stages 1 and 2 avoids its poor local optima from the initial clustering.
Build it with new_missSBM_fit().
Super class
missSBM_fit -> missSBM_fit_degree
Active bindings
imputationsthe variational parameters of the missing dyads (sparse matrix with their pattern),
NULLbefore the first fit
Methods
Public methods
Inherited methods
missSBM_fit_degree$clone()
The objects of this class are cloneable with this method.
Usage
missSBM_fit_degree$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
An R6 class to represent an SBM fit under the double-standard sampling
Description
Inherits from missSBM_fit. A dyad equal to 1 (resp. 0) is observed with
probability p1 (resp. p0): the sampling depends on the value of each dyad, but the missing
dyads are still integrated out given the blocks (a missing dyad between blocks q and l is an
edge with probability \nu_{ql}, field blockImputation of
doubleStandardSampling_fit). The missing dyads tie the connectivity to (p0, p1): they are
updated jointly, by an EM on the missing dyads iterated to convergence at each M-step (see
SimpleSBM_fit_doubleStandard).
Build it with new_missSBM_fit().
Super class
missSBM_fit -> missSBM_fit_doubleStandard
Methods
Public methods
Inherited methods
missSBM_fit_doubleStandard$clone()
The objects of this class are cloneable with this method.
Usage
missSBM_fit_doubleStandard$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Control of a missSBM fit
Description
Helper to define the list of parameters that controls estimateMissSBM(). All arguments have defaults.
Usage
missSBM_param(
threshold = 0.01,
maxIter = 50,
fixPointIter = 3,
imputation = c("median", "average", "zero"),
similarity = l1_similarity,
useCov = TRUE,
clusterInit = NULL,
polish = TRUE,
iterates = 1,
maxMergeCandidates = 30,
stopOnDegenerate = TRUE,
maxConsecutiveDegenerate = 2,
warmChain = FALSE,
trace = TRUE
)
Arguments
threshold |
the VEM stops when an optimization step changes the objective function or the parameters by less than threshold. Default is 1e-2. |
maxIter |
the VEM stops when the number of iterations exceeds maxIter. Default is 50. |
fixPointIter |
number of fixed-point iterations in the variational E step. Default is 3. |
imputation |
character, the imputation strategy used to build the initial clustering (see
|
similarity |
an R x R -> R function to compute similarities between node covariates.
Default is |
useCov |
logical. If |
clusterInit |
initial clustering: |
polish |
logical, should each model be node-swap-polished (see missSBM_fit's
|
iterates |
integer, the number of forward/backward exploration passes searching for a
better number of blocks by splitting/merging blocks (unlike |
maxMergeCandidates |
integer, caps the number of block-pair merge candidates tried during backward exploration (quadratic in the number of blocks otherwise). Beyond this cap, only the pairs with the most similar fitted connectivity profiles are tried, since merging two blocks with very different connectivity is rarely competitive anyway. Default is 30. |
stopOnDegenerate |
logical. A requested number of blocks can be higher than what the
network actually supports: VEM then collapses one or more classes (see missSBM_fit's
|
maxConsecutiveDegenerate |
integer, the run length that triggers |
warmChain |
logical (work in progress). If |
trace |
logical for verbosity. Default is TRUE. |
Value
a list of parameters configuring the fit, with class missSBM_param.
See Also
Examples
my_control <- missSBM_param(iterates = 2, polish = FALSE)
my_control$iterates
Definition of R6 Class 'networkSampling_sampler'
Description
This class is use to define a sampling model for a network. Inherits from 'networkSampling'. Owns a rSampling method which takes an adjacency matrix as an input and send back an object with class partlyObservedNetwork.
Super class
networkSampling -> networkSampler
Active bindings
samplingMatrixa matrix of logical indicating observed entries
Methods
Public methods
Inherited methods
networkSampler$new()
constructor for networkSampling
Usage
networkSampler$new(type = NA, parameters = NA, nbNodes = NA, directed = FALSE)
Arguments
typecharacter for the type of sampling. must be in ("dyad", "covar-dyad", "node", "covar-node", "block-node", "block-dyad", "double-standard", "degree")
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
networkSampler$rSamplingMatrix()
a method for drawing a sampling matrix according to the current sampling design
Usage
networkSampler$rSamplingMatrix()
networkSampler$clone()
The objects of this class are cloneable with this method.
Usage
networkSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Definition of R6 Class 'networkSampling'
Description
this virtual class is the mother of all subtypes of networkSampling (either sampler or fit) It is used to define a sampling model for a network. It has a rSampling method which takes an adjacency matrix as an input and send back an object with class partlyObservedNetwork.
Active bindings
typea character for the type of sampling
parametersthe vector of parameters associated with the sampling at play
dfthe number of entries in the vector of parameters
Methods
Public methods
networkSampling$new()
constructor for networkSampling
Usage
networkSampling$new(type = NA, parameters = NA)
Arguments
typecharacter for the type of sampling. must be in ("dyad", "covar-dyad", "node", "covar-node", "block-node", "block-dyad", "double-standard", "degree")
parametersthe vector of parameters associated to the sampling at play
networkSampling$show()
show method
Usage
networkSampling$show( type = paste0(private$name, "-model for network sampling\n") )
Arguments
typecharacter used to specify the type of sampling
networkSampling$print()
User friendly print method
Usage
networkSampling$print()
networkSampling$clone()
The objects of this class are cloneable with this method.
Usage
networkSampling$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Virtual class of the fits of the sampling designs on the dyads
Description
Virtual class of the fits of the sampling designs on the dyads
Super classes
networkSampling -> networkSampling_fit -> networkSamplingDyads_fit
Methods
Public methods
Inherited methods
networkSamplingDyads_fit$new()
constructor
Usage
networkSamplingDyads_fit$new(partlyObservedNetwork, name)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
namea character for the name of sampling to fit on the partlyObservedNetwork
networkSamplingDyads_fit$clone()
The objects of this class are cloneable with this method.
Usage
networkSamplingDyads_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Virtual class of the fits of the sampling designs on the nodes
Description
Virtual class of the fits of the sampling designs on the nodes
Super classes
networkSampling -> networkSampling_fit -> networkSamplingNodes_fit
Methods
Public methods
Inherited methods
networkSamplingNodes_fit$new()
constructor
Usage
networkSamplingNodes_fit$new(partlyObservedNetwork, name)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
namea character for the name of sampling to fit on the partlyObservedNetwork
networkSamplingNodes_fit$clone()
The objects of this class are cloneable with this method.
Usage
networkSamplingNodes_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Virtual class of the fits of a sampling design
Description
The mother of networkSamplingDyads_fit and networkSamplingNodes_fit, with the defaults
of a sampling that does not depend on the blocks: no parameter indexed by the blocks, nothing
to update along the VEM, no term in the update of the blocks. Each design defines
vExpec_at(Z), the expected log-likelihood of the sampling at memberships Z (which it
ignores if it does not depend on the blocks); vExpec is its value at the memberships of
the last update of the parameters.
Super class
networkSampling -> networkSampling_fit
Active bindings
penaltydouble, value of the penalty term in ICL: the parameters of the sampling count all the sampling units (dyads or nodes), the sampling matrix being fully observed
vExpecvariational expectation of the log-likelihood of the sampling, at the memberships of the last update of the parameters
Methods
Public methods
Inherited methods
networkSampling_fit$show()
show method
Usage
networkSampling_fit$show()
networkSampling_fit$update_parameters()
update the parameters along the VEM: nothing to do by default, the parameters of a sampling not depending on the blocks being estimated once
Usage
networkSampling_fit$update_parameters(...)
Arguments
...use for compatibility
networkSampling_fit$reorder()
permute the parameters indexed by the blocks, after the blocks of the SBM were permuted. By default, nothing to do (no parameter indexed by the blocks)
Usage
networkSampling_fit$reorder(o)
Arguments
othe permutation applied to the blocks (new block k is former block
o[k])
networkSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling at given memberships (used by the ICL, at the MAP memberships), defined by each design
Usage
networkSampling_fit$vExpec_at(Z)
Arguments
Zan n x Q matrix of memberships
networkSampling_fit$log_lambda()
the term of the sampling in the update of the blocks (log lambda): for each node i and block q, the expected log-likelihood of the sampling terms involving i if it were in block q, the other nodes following the memberships Z. 0 when the sampling does not depend on the blocks
Usage
networkSampling_fit$log_lambda(Z)
Arguments
Zan n x Q matrix of memberships
networkSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
networkSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Build the fit of an SBM with missing data
Description
Chooses the class of the fit from the sampling design: missSBM_fit_doubleStandard for
"double-standard", missSBM_fit_degree for "degree", missSBM_fit for the other designs,
whose missing dyads are integrated out given the blocks.
Usage
new_missSBM_fit(partlyObservedNet, netSampling, clusterInit, useCov = TRUE)
Arguments
partlyObservedNet |
An object with class |
netSampling |
The sampling design (see |
clusterInit |
Initial clustering: a vector with size the number of nodes. The number of blocks is deduced from its number of levels. |
useCov |
logical. Should the covariates of |
Value
an object inheriting from missSBM_fit, not fitted yet (see its method
doVEM())
Virtual class for all node-centered samplers
Description
Virtual class for all node-centered samplers
Super classes
networkSampling -> networkSampler -> nodeSampler
Methods
Public methods
Inherited methods
nodeSampler$clone()
The objects of this class are cloneable with this method.
Usage
nodeSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for fitting a node sampling
Description
Class for fitting a node sampling
Super classes
networkSampling -> networkSampling_fit -> networkSamplingNodes_fit -> nodeSampling_fit
Methods
Public methods
Inherited methods
nodeSampling_fit$new()
constructor
Usage
nodeSampling_fit$new(partlyObservedNetwork, ...)
Arguments
partlyObservedNetworka object with class partlyObservedNetwork representing the observed data with possibly missing entries
...used for compatibility
nodeSampling_fit$vExpec_at()
the variational expectation of the log-likelihood of the sampling
Usage
nodeSampling_fit$vExpec_at(Z = NULL)
Arguments
Znot used: the sampling does not depend on the blocks
nodeSampling_fit$clone()
The objects of this class are cloneable with this method.
Usage
nodeSampling_fit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Observe a network partially according to a given sampling design
Description
This function draws observations in an adjacency matrix according to a given network sampling design.
Usage
observeNetwork(
adjacencyMatrix,
sampling,
parameters,
clusters = NULL,
covariates = list(),
similarity = l1_similarity,
intercept = 0
)
Arguments
adjacencyMatrix |
The N x N adjacency matrix of the network to sample. The diagonal is expected to be NA (no self-loops); any other pre-existing NA entry is treated as an absent edge (coded 0) before sampling is applied on top of it, with a warning. |
sampling |
The sampling design used to observe the adjacency matrix, see details. |
parameters |
The sampling parameters (adapted to each sampling, see details). |
clusters |
An optional clustering membership vector of the nodes. Only necessary for block samplings. |
covariates |
An optional list with M entries (the M covariates). If the covariates are node-centered, each entry of |
similarity |
an R x R -> R function to compute similarities between node covariates.
Default is |
intercept |
An optional intercept term to be added in case of the presence of covariates. Default is 0. |
Details
Internal functions use future_lapply, so set your plan to 'multisession' or
'multicore' to use several cores/workers.
The sampling designs are either Missing At Random (MAR) or Missing Not At Random (MNAR), and observe either dyads or nodes (all the dyads of an observed node). See doi:10.1080/01621459.2018.1562934 for a complete description. The parameters of each design:
Missing At Random (MAR)
"dyad": p, the probability that a dyad is observed.
"node": p, the probability that a node is observed.
"covar-dyad":
\beta \in R^M, a dyad (i, j) being observed with probabilitylogistic(\beta' x_{ij}),x_{ij}the covariates of the dyad."covar-node":
\beta \in R^M, a node i being observed with probabilitylogistic(\beta' x_i),x_ithe covariates of the node."snowball": (number of waves, proportion of the nodes observed in the first wave); the nodes of each wave are the neighbors of the nodes of the previous one. It is fitted as "node" sampling.
Missing Not At Random (MNAR)
"double-standard": (p0, p1), the probabilities that a dyad is observed if it is 0 and if it is 1. (p0, p1) are identified through the differences of connectivity between the blocks: with a single block, they are not identifiable, and the model is fitted with p0 = p1, i.e. as dyad sampling (with a warning).
"block-node":
(p_1, \dots, p_Q),p_qthe probability that a node of block q is observed."block-dyad": the Q x Q matrix
(p_{ql}),p_{ql}the probability that a dyad between blocks q and l is observed."degree": (a, b), a node i being observed with probability
logistic(a + b D_i),D_iits degree.
The number of blocks is selected by the ICL (Integrated Classification Likelihood,
the smaller the better): -2 times the variational lower bound of the log-likelihood of the
observed data (the observed dyads and the sampling matrix), at the MAP memberships, plus a
penalty, in which the connectivity counts the observed dyads and the parameters of the sampling
all the dyads (or all the nodes). The ICLs of different designs fitted to the same data can be
compared to choose the design. When their samplings carry the same information (e.g.
"block-node" and "degree" on an assortative network, where the degree depends on the block),
the ICLs differ by a few units, about the penalty of one parameter (log N), and the partitions
are the same: such a difference is no evidence for one design. Each number of blocks is fitted
from a spectral clustering, then improved by a polish and by passes of exploration splitting
and merging blocks (see missSBM_param); one pass is enough on small networks,
two are advised for a reference analysis of a network with many blocks.
Value
an adjacency matrix with the same dimension as the input, yet with additional NAs.
Examples
## SBM parameters
N <- 300 # number of nodes
Q <- 3 # number of blocks
pi <- rep(1,Q)/Q # block proportion
theta <- list(mean = diag(.45,Q) + .05 ) # connectivity matrix
## simulate an undirected binary SBM without covariate
sbm <- sbm::sampleSimpleSBM(N, pi, theta)
## Sample network data
# some sampling design and their associated parameters
sampling_parameters <- list(
"dyad" = .3,
"node" = .3,
"double-standard" = c(0.4, 0.8),
"block-node" = c(.3, .8, .5),
"block-dyad" = theta$mean,
"degree" = c(.01, .01),
"snowball" = c(2,.1)
)
observed_networks <- list()
for (sampling in names(sampling_parameters)) {
observed_networks[[sampling]] <-
missSBM::observeNetwork(
adjacencyMatrix = sbm$networkData,
sampling = sampling,
parameters = sampling_parameters[[sampling]],
clusters = sbm$memberships
)
}
An R6 Class used for internal representation of a partially observed network
Description
This class is not exported to the user
Active bindings
samplingRateThe percentage of observed dyads
nbNodesThe number of nodes
nbDyadsThe number of dyads
is_directedlogical indicating if the network is directed or not
networkDataThe adjacency matrix of the network
covarArraythe array of covariates
covarMatrixthe matrix of covariates
samplingMatrixmatrix of observed and non-observed edges
samplingMatrixBarmatrix of observed and non-observed edges
observedNodesa vector of observed and non-observed nodes (observed means at least one non NA value)
Methods
Public methods
partlyObservedNetwork$new()
constructor
Usage
partlyObservedNetwork$new( adjacencyMatrix, covariates = list(), similarity = l1_similarity )
Arguments
adjacencyMatrixThe adjacency matrix of the network
covariatesA list with M entries (the M covariates), each of whom being either a size-N vector or N x N matrix.
similarityAn R x R -> R function to compute similarities between node covariates. Default is
l1_similarity, that is, -abs(x-y).
partlyObservedNetwork$clustering()
method to cluster network data with missing value
Usage
partlyObservedNetwork$clustering( vBlocks, imputation = ifelse(is.null(private$phi), "median", "average") )
Arguments
vBlocksThe vector of number of blocks considered in the collection.
imputationcharacter indicating the type of imputation among "median", "average"
partlyObservedNetwork$imputation()
basic imputation from existing clustering
Usage
partlyObservedNetwork$imputation(type = c("median", "average", "zero"))
Arguments
typea character, the type of imputation. Either "median" or "average"
partlyObservedNetwork$clone()
The objects of this class are cloneable with this method.
Usage
partlyObservedNetwork$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Visualization for an object missSBM_fit
Description
Plot function for the various fields of a missSBM_fit: the fitted
SBM (network or connectivity), and a plot monitoring the optimization.
Usage
## S3 method for class 'missSBM_fit'
plot(
x,
type = c("imputed", "expected", "meso", "monitoring"),
dimLabels = list(row = "node", col = "node"),
...
)
Arguments
x |
an object with class |
type |
the type specifies the field to plot, either "imputed", "expected", "meso", or "monitoring" |
dimLabels |
: a list of two characters specifying the labels of the nodes. Default to |
... |
additional parameters for S3 compatibility. Not used |
Value
a ggplot object
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
myModel <- collection$bestModel
plot(myModel, "expected")
plot(myModel, "imputed")
plot(myModel, "monitoring")
Prediction of a missSBM_fit (i.e. network with imputed missing dyads)
Description
Prediction of a missSBM_fit (i.e. network with imputed missing dyads)
Usage
## S3 method for class 'missSBM_fit'
predict(object, ...)
Arguments
object |
an R6 object with class |
... |
additional parameters for S3 compatibility. |
Value
an adjacency matrix between pairs of nodes. Missing dyads are imputed with their expected values, i.e. by there estimated probabilities of connection under the missing SBM.
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
myModel <- collection$bestModel
## the observed dyads, and the imputations of the missing ones
predict(myModel)[1:5, 1:5]
Class for defining a simple dyad sampler
Description
Class for defining a simple dyad sampler
Super classes
networkSampling -> networkSampler -> dyadSampler -> simpleDyadSampler
Methods
Public methods
Inherited methods
simpleDyadSampler$new()
constructor for networkSampling
Usage
simpleDyadSampler$new( parameters = NA, nbNodes = NA, directed = FALSE, covarArray = NULL, intercept = 0 )
Arguments
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
covarArrayan array of covariates used
interceptdouble, intercept term used to compute the probability of sampling in the presence of covariates. Default 0.
simpleDyadSampler$clone()
The objects of this class are cloneable with this method.
Usage
simpleDyadSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a simple node sampler
Description
Class for defining a simple node sampler
Super classes
networkSampling -> networkSampler -> nodeSampler -> simpleNodeSampler
Methods
Public methods
Inherited methods
simpleNodeSampler$new()
constructor for networkSampling
Usage
simpleNodeSampler$new( parameters = NA, nbNodes = NA, directed = FALSE, covarMatrix = NULL, intercept = 0 )
Arguments
parametersthe vector of parameters associated to the sampling at play
nbNodesnumber of nodes in the network
directedlogical, directed network of not
covarMatrixa matrix of covariates used
interceptdouble, intercept term used to compute the probability of sampling in the presence of covariates. Default 0.
simpleNodeSampler$clone()
The objects of this class are cloneable with this method.
Usage
simpleNodeSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Class for defining a snowball sampler
Description
Class for defining a snowball sampler
Super classes
networkSampling -> networkSampler -> nodeSampler -> snowballSampler
Methods
Public methods
Inherited methods
snowballSampler$new()
constructor for networkSampling
Usage
snowballSampler$new(parameters = NA, adjacencyMatrix = NA, directed = FALSE)
Arguments
parametersthe vector of parameters associated to the sampling at play
adjacencyMatrixthe adjacency matrix of the network
directedlogical, directed network of not
snowballSampler$clone()
The objects of this class are cloneable with this method.
Usage
snowballSampler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Summary method for a missSBM_collection
Description
Summary method for a missSBM_collection
Usage
## S3 method for class 'missSBM_collection'
summary(object, ...)
Arguments
object |
an R6 object with class |
... |
additional parameters for S3 compatibility. |
Value
a basic printing output
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
summary(collection)
Summary method for a missSBM_fit
Description
Summary method for a missSBM_fit
Usage
## S3 method for class 'missSBM_fit'
summary(object, ...)
Arguments
object |
an R6 object with class |
... |
additional parameters for S3 compatibility. |
Value
a basic printing output
Examples
## a fit of the French political blogosphere, 30% of its dyads missing
adjMatrix <- missSBM::frenchblog2007 %>%
igraph::as_adjacency_matrix(sparse = FALSE) %>%
missSBM::observeNetwork(sampling = "dyad", parameters = 0.7)
collection <- estimateMissSBM(adjMatrix, 1:3, "dyad",
control = missSBM_param(trace = FALSE, iterates = 0))
myModel <- collection$bestModel
summary(myModel)
War data set
Description
This dataset contains two networks where the nodes are countries and an
edge in network "belligerent" means that the two countries have been at
least once at war between years 1816 to 2007 while an edge in network "alliance"
means that the two countries have had a formal alliance between years 1816 to 2012.
The network belligerent have less nodes since countries which have not been at
war are not considered.
Usage
war
Format
A list with 2 two igraph objects, alliance and belligerent.
Each graph have three attributes: 'name' (the country name), 'power' (a score related to military power: the higher, the better) and
'trade' (a score related to the trade effort between pairs of countries).
Source
networks were extracted from https://correlatesofwar.org/
References
Sarkees, Meredith Reid and Frank Wayman (2010). Resort to War: 1816 - 2007. Washington DC: CQ Press.
Gibler, Douglas M. 2009. International military alliances, 1648-2008. CQ Press
Examples
data(war)
class(war$belligerent)
igraph::gorder(war$alliance)
igraph::gorder(war$belligerent)
igraph::edges(war$alliance)
igraph::graph_attr(war$alliance)