Model and Parameter Selection in msma

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

Overview

The package provides functions for selecting component numbers and regularization parameters:

BIC is useful for a quick deterministic search. Cross-validation may be more computationally expensive.

dat <- simdata(n = 35, rho = 0.8, Xps = c(4, 4), Yps = c(3, 3), seed = 4)
X <- dat$X
Y <- dat$Y

Selecting the number of components

search_comp <- ncompsearch(X, comps = 1:3, criterion = "BIC", intseed = 1)
search_comp
plot(search_comp)

For nested analysis, candidates may be supplied as a list for root and super components.

search_nested <- ncompsearch(
  X,
  comps = list(1:4, 1:3),
  criterion = "BIC",
  intseed = 1
)

Selecting regularization parameters

The following example is shown but not evaluated during package building to keep the vignette lightweight.

search_lambda <- regparasearch(
  X = X,
  comp = 2,
  criterion = "BIC",
  maxrep = 5,
  intseed = 1
)
search_lambda

Combined selection

optparasearch() supports four workflows:

opt <- optparasearch(
  X = X,
  search.method = "ncomp1st",
  criterion = "BIC",
  intseed = 1
)

fit <- msma(
  X = X,
  comp = opt$optncomp,
  lambdaX = opt$optlambdaX,
  lambdaXsup = opt$optlambdaXsup,
  intseed = 1
)

PLS selection

X-side and Y-side parameters are selected separately in PLS.

opt_pls <- optparasearch(
  X = X, Y = Y,
  search.method = "regparaonly",
  criterion = "BIC",
  intseed = 1
)

fit_pls <- msma(
  X = X, Y = Y,
  comp = opt_pls$optncomp,
  lambdaX = opt_pls$optlambdaX,
  lambdaY = opt_pls$optlambdaY,
  lambdaXsup = opt_pls$optlambdaXsup,
  lambdaYsup = opt_pls$optlambdaYsup,
  intseed = 1
)

Cross-validation

cv <- cvmsma(
  X = X, Y = Y,
  comp = 1,
  lambdaX = c(0.1, 0.1),
  lambdaY = c(0.1, 0.1),
  nfold = 5,
  seed = 1,
  intseed = 1
)
cv

Version 3.2 super-level methods

Model-selection functions accept the super-level method arguments where applicable.

search_snmf <- ncompsearch(
  X,
  comps = list(1:3, 1:3),
  criterion = "BIC",
  sprmethod = "sNMF",
  nneg = "posneg",
  intseed = 1
)

Computational recommendations

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.