Model and Parameter Selection in msma

Overview

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

  • ncompsearch(): number of components;
  • regparasearch(): regularization parameters;
  • optparasearch(): combined selection.

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
#> Optimal number of components: (block) 3, (super) 1
#> Criterion: BIC
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:

  • "regparaonly": regularization search for fixed components;
  • "ncomp1st": component search followed by regularization search;
  • "regpara1st": regularization search followed by component search;
  • "simultaneous": repeated joint search.
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

  • Start with a small candidate grid.
  • Use BIC to screen candidate models before cross-validation.
  • Fix seed for fold allocation and intseed for model estimation.
  • Keep expensive searches as explicit user actions rather than vignette build steps.

Session information

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] msma_4.0       rmarkdown_2.32
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.39    R6_2.6.1         fastmap_1.2.0    xfun_0.61       
#>  [5] maketools_1.3.2  cachem_1.1.0     knitr_1.52       htmltools_0.5.9 
#>  [9] buildtools_1.0.0 lifecycle_1.0.5  cli_3.6.6        sass_0.4.10     
#> [13] jquerylib_0.1.4  compiler_4.6.1   sys_3.4.3        tools_4.6.1     
#> [17] evaluate_1.0.5   bslib_0.12.0     yaml_2.3.12      otel_0.2.0      
#> [21] jsonlite_2.0.0   rlang_1.3.0