R6 abstract class shared by the variance-block ([NormalBlockVarBase]) and mean-block ([NormalBlockMeanBase]) model families.
Active bindings
inference_methodinference procedure used (heuristic or integrated with EM)
nnumber of samples
pnumber of responses per sample
dnumber of variables (dimensions in X)
qnumber of blocks
n_edgesnumber of edges of the network (non null coefficient of the sparse precision matrix Omega)
objectiveevolution of the objective function during (V)EM algorithm
loglik(or its variational lower bound)
deviance(or its variational lower bound)
BIC(or its variational lower bound)
entropyEntropy of the conditional distribution when applicable
ICLvariational lower bound of the ICL
EBICvariational lower bound of the EBIC
criteriaa vector with loglik, BIC and number of parameters
sparsity(overall sparsity parameter)
sparsity_term(sparsity_term term in log-likelihood due to sparsity)
membershipscluster memberships
clusteringgiven as the list of elements contained in each cluster
cluster_sizesgiven as a vector of cluster sizes
elements_per_clustergiven as the list of elements contained in each cluster
Methods
NormalBlockBase$new()
Create a new [`NormalBlockBase`] object.
Usage
NormalBlockBase$new(data, q, sparsity = 0, control, zero_inflation = FALSE)Arguments
dataobject of NormalBlockData class, with responses and design matrix
qnumber of block/cluster
sparsitysparsity penalty on the network density
controlstructured list of more specific parameters, to generate with NB_control
zero_inflationwhether the concrete subclass models zero-inflation; set by the ZI subclasses themselves, not meant to be set by the end user. When `FALSE`, the (costly) zero-inflation probability fit (`kappa`/`B0`) is skipped entirely, since it would otherwise never be used downstream.
NormalBlockBase$update()
Update a [`NormalBlockBase`] object
All possible parameters of the child classes
Usage
NormalBlockBase$update(
B = NA,
dm1 = NA,
C = NA,
Omega = NA,
gamma = NA,
mu = NA,
kappa = NA,
alpha = NA,
M = NA,
S = NA,
Psi = NA,
Phi = NA,
Lambda = NA,
ll_list = NA,
warm_started = NA,
clustering_init = NA
)Arguments
Bregression matrix [all]
dm1diagonal vector of inverse variance matrix (variables level) [NBVar]
Cthe matrix of groups memberships (posterior probabilities) [all]
Omegainverse variance matrix (cluster-level for Normal Block models, variable-level for Normal Mean Block models) [all]
gammavariance of posterior distribution of W [NBVar - known]
mumean for posterior distribution of W [NBVar - known]
kappavector of zero-inflation probabilities [ZINBVar, ZINBMean]
alphavector of groups probabilities [NBVar]
Mvariational mean for posterior distribution of W [NBVar - unknown]
Svariational diagonal of variances for posterior distribution of W [NBVar - unknown]
Psivariational expectation of C'Omega C, intermediary term in calculations [NBMean - unknown]
Phivariational correction term used in the Psi/ELBO computations [NBMean - unknown]
Lambdavariational correction term used in the Sigma-hat update [NBMean - unknown]
ll_listlist of log-lik (elbo) values
warm_startedwhether `optim_initialize()` should treat the model as already initialized (reuse B/Omega/dm1/C/alpha/M/S as they stand) rather than recomputing a fresh heuristic initialization. Set by [warm_start_from()] and by [split()]/[merge()].
clustering_initinitial clustering
NormalBlockBase$optimize()
calls optimization (EM or heuristic) and updates relevant fields
Usage
NormalBlockBase$optimize(
control = list(niter = 500, threshold = 1e-04, fixed_point_niter = 5),
warn = TRUE
)Arguments
controla list for controlling the optimization process
warnwhether to warn when the (V)EM stops at the `niter` cap without reaching `threshold` (see `private$warn_if_not_converged()`). Set to `FALSE` for deliberately-truncated trial fits (cheap candidate scoring in `candidates_split()`/`candidates_merge()`, the sparsity-path warm-start probe in [NormalBlockCollectionSparsity]) where stopping at the cap is expected and not a sign of trouble.
NormalBlockBase$best_of_inits()
Try several clustering-initialization heuristics and keep the best-ELBO converged fit (see `NB_control(clustering_init = )` and `inst/methods_initialization_and_refine.md` for the rationale). Every candidate is first screened with a short `trial_niter` run (same idea as `candidates_split()`/`candidates_merge()`), and only the `max_training` best-screened ones are fully retrained with `control`.
Usage
NormalBlockBase$best_of_inits(
inits = private$default_inits,
trial_niter = 10,
max_training = 2,
control = list(niter = 500, threshold = 1e-04, fixed_point_niter = 5)
)Arguments
initsvector of clustering-heuristic names to try; defaults to the model family's own preferred order (`private$default_inits`)
trial_niternumber of (V)EM iterations used to cheaply screen every candidate in `inits` before fully retraining the best few
max_traininghow many of the screened candidates (best `loglik` after `trial_niter` iterations) get fully retrained with `control`
control`optimize()` control list (`niter`/`threshold`) used for the final full retraining of the `max_training` best candidates
NormalBlockBase$candidates_split()
generate and select a set of candidate models by splitting the clusters of the current model
NormalBlockBase$candidates_merge()
generate and select a set of candidate models by merging the clusters of the current model
Arguments
max_candidatesmerge candidates are, unlike split's, quadratic in q (`choose(q, q-2)` pairs): beyond `max_candidates` pairs, only the most promising ones are actually built and trial-optimized, ranked by the family's own `private$merge_score()`. Set to `Inf` to always try every pair.
trial_nitersee [candidates_split()]
NormalBlockBase$predict()
Predicts observations Y for new covariates X, in Y's original units (like `$fitted`, so that predicting on the training X reproduces it).
NormalBlockBase$latent_network()
Extract interaction network in the latent space, as a matrix rather than a plot – see `$plot_network()` to plot it instead.
Usage
NormalBlockBase$latent_network(type = c("partial_cor", "support", "precision"))NormalBlockBase$plot_loglik()
plots the evolution of the objective (log-likelihood or ELBO) across the (V)EM iterations of the last call to `optimize()`.
NormalBlockBase$plot_network()
plot the latent network. To extract the network as a matrix instead of plotting it, use `$latent_network()`.
Usage
NormalBlockBase$plot_network(
type = c("partial_cor", "support"),
output = c("igraph", "corrplot"),
edge.color = c("#F8766D", "#00BFC4"),
remove.isolated = FALSE,
node.labels = NULL,
layout = igraph::layout_in_circle,
plot = TRUE
)Arguments
typeedge value in the network. Either "precision" (coefficient of the precision matrix) or "partial_cor" (partial correlation between species).
outputOutput type. Either `igraph` (for the network) or `corrplot` (for the adjacency matrix)
edge.colorLength 2 color vector. Color for positive/negative edges. Default is `c("#F8766D", "#00BFC4")`. Only relevant for igraph output.
remove.isolatedif `TRUE`, isolated node are remove before plotting. Only relevant for igraph output.
node.labelsvector of character. The labels of the nodes. The default will use the column names ot the response matrix.
layoutan optional igraph layout. Only relevant for igraph output.
plotlogical. Should the final network be displayed or only sent back to the user. Default is `TRUE`.
NormalBlockBase$plot()
plots the evolution of the objective during model optimization (see `plot_loglik()`)
NormalBlockBase$print()
User friendly print method
Usage
NormalBlockBase$print(model = paste("A", self$who_am_I, ".\n"))