knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5) library(msma)
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
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 )
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
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 )
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 )
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
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 )
seed for fold allocation and intseed for model estimation.sessionInfo()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.