Multiblock and Nested Component Analysis

knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5)
library(msma)

Multiblock data

Multiblock data are represented by a list of matrices. Rows are observations, columns are variables, and every block must have the same number of rows.

dat <- simdata(
  n = 40, rho = 0.8,
  Xps = c(4, 5), Yps = c(3, 4),
  seed = 2
)
X <- dat$X
Y <- dat$Y
names(X) <- c("X_block_1", "X_block_2")
names(Y) <- c("Y_block_1", "Y_block_2")
lapply(X, dim)
lapply(Y, dim)

Multiblock PCA

fit_mb_pca <- msma(X = X, comp = 2, intseed = 1)
fit_mb_pca

For X, the fitted object contains block-level weights and scores (wbX, sbX) and super-level weights and scores (wsX, ssX).

lapply(fit_mb_pca$wbX, dim)
lapply(fit_mb_pca$sbX, dim)
lapply(fit_mb_pca$wsX, dim)
lapply(fit_mb_pca$ssX, dim)
plot(fit_mb_pca, axes = 1, plottype = "bar", block = "block", las = 2)
plot(fit_mb_pca, axes = 1, plottype = "bar", block = "super")

Sparse multiblock PCA

lambdaX has one value per X block. lambdaXsup controls sparsity at the super level.

fit_sparse <- msma(
  X = X, comp = 2,
  lambdaX = c(0.10, 0.15),
  lambdaXsup = 0.05,
  intseed = 1
)
fit_sparse$nzwbX
fit_sparse$nzwsX

Nested components

A two-element comp specifies the numbers of root and super components:

comp = c(number_of_root_components, number_of_super_components)

For example, comp = c(2, 3) estimates three super components for each of two root components.

fit_nested <- msma(X = X, comp = c(2, 3), intseed = 1)
lapply(fit_nested$wsX, dim)
lapply(fit_nested$ssX, dim)
plot(fit_nested, axes = 1, axes2 = 1, plottype = "bar", block = "super")
plot(fit_nested, axes = 1, axes2 = 2, plottype = "bar", block = "super")

Supervised multiblock PCA

set.seed(2)
Z <- rnorm(nrow(X[[1]]))
fit_supervised <- msma(
  X = X, Z = Z, comp = 2,
  lambdaX = c(0.10, 0.10),
  muX = 0.20,
  intseed = 1
)
fit_supervised$predictiv

Multiblock PLS

fit_mb_pls <- msma(
  X = X, Y = Y, comp = 2,
  lambdaX = c(0.10, 0.10),
  lambdaY = c(0.10, 0.10),
  intseed = 1
)
fit_mb_pls

The four regularization arguments have distinct roles:

fit_nested_pls <- msma(
  X = X, Y = Y, comp = c(2, 2),
  lambdaX = c(0.10, 0.10),
  lambdaY = c(0.10, 0.10),
  lambdaXsup = 0.05,
  lambdaYsup = 0.05,
  intseed = 1
)
lapply(fit_nested_pls$ssX, dim)
lapply(fit_nested_pls$ssY, dim)

Session information

sessionInfo()


Try the msma package in your browser

Any scripts or data that you put into this service are public.

msma documentation built on Oct. 3, 2026, 9:07 a.m.