normal_block_sequential: Cluster Variables in the Mean, then in the Residual...

View source: R/normal_block_sequential.R

normal_block_sequentialR Documentation

Cluster Variables in the Mean, then in the Residual Covariance

Description

Fits the two model families one after the other: a mean-block model (NormalBlockMeanBase) groups the variables by how they respond to the covariates, then a variance-block model (NormalBlockVarBase) groups the residuals of that fit by how they co-vary. The two answer different questions and generally return unrelated partitions, so running both is often more informative than choosing one.

Usage

normal_block_sequential(
  data,
  blocks_mean,
  blocks_var,
  crit = c("ICL", "BIC"),
  zero_inflation = FALSE,
  control_mean = NB_control(verbose = FALSE),
  control_var = NB_control(verbose = FALSE)
)

Arguments

data

a NormalBlockData object

blocks_mean

number of clusters for the mean-block stage: an integer, a vector of integers to explore, or a p x q indicator matrix. It can also be a mean-block model or collection already fitted on data (by normal_block(data, ..., model = "mean")), in which case the first stage is not refitted: a collection is reduced to its best model by crit.

blocks_var

idem for the variance-block stage, run on the residuals

crit

criterion used to pick a model when a range is explored, "ICL" (the default) or "BIC"

zero_inflation

whether Y carries structural zeros. Both stages are then zero-inflated, sharing the same mask: the second one would otherwise re-derive it from residuals, which are never exactly zero.

control_mean

control list for the mean-block stage, see NB_control()

control_var

control list for the variance-block stage

Details

The second stage uses an intercept-only design on purpose: the covariate effects have already been removed by the first stage.

This is a heuristic two-stage estimator, not a joint model.

Value

an object of class normal_block_sequential, a list with the fitted mean and var models and the residual matrix residuals handed from one stage to the other.

Examples

ex   <- generate_normal_block_mean_data(n = 80, p = 20, d = 1, q = 3)
data <- NormalBlockData$new(ex$Y, ex$X)
fit  <- normal_block_sequential(data, blocks_mean = 3, blocks_var = 2)
fit

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