get_model: Create a Normal-Block Model Object

View source: R/normal_block.R

get_modelR Documentation

Create a Normal-Block Model Object

Description

Creates, without fitting it, the model (or collection of models) that normal_block() would fit for the same arguments.

Usage

get_model(
  data,
  blocks,
  sparsity = 0,
  zero_inflation = FALSE,
  control = NB_control(),
  model = c("var", "mean")
)

Arguments

data

a NormalBlockData object, holding the responses (Y, n x p) and the covariates (X, n x d).

blocks

the clustering of the variables: a p x q indicator matrix for a known clustering (e.g. model.matrix(~ 0 + factor(labels))), a single integer q for an unknown clustering into q clusters, or a vector of distinct integers for a collection over these values of q.

sparsity

the graphical-lasso penalty on Omega: 0 (the default) for none, a positive number for a single penalty, or TRUE for a collection along a path of penalties (see NB_control()).

zero_inflation

whether to model an excess of exact zeros in Y.

control

a list of settings, built with NB_control().

model

the model family: "var" (the default) clusters the variables by how they covary, and infers a network between clusters (see NormalBlockVarBase); "mean" clusters them by how they respond to the covariates, ⁠mu_i = C B' X_i⁠ (see NormalBlockMeanBase). Every combination of the other arguments is available for both families, except a penalty together with zero-inflation for the mean-block family, whose zero-inflated models have a diagonal or spherical Sigma.

Value

an R6 object: a model or a collection of models, not optimized yet.

Examples

ex_data <- generate_normal_block_var_data(n = 50, p = 20, d = 1, q = 3)
data <- NormalBlockData$new(ex_data$Y, ex_data$X)
## the model is created but not fitted, unlike with normal_block()
model <- get_model(data, blocks = 3, control = NB_control(verbose = FALSE))
class(model)

normalblockr documentation built on Nov. 24, 2026, 1:06 a.m.