nmf.rrr.cv: Sample-wise k-fold Cross-Validation for nmfae

View source: R/nmfae.R

nmf.rrr.cvR Documentation

Sample-wise k-fold Cross-Validation for nmfae

Description

nmfae.cv performs k-fold cross-validation by splitting columns (samples) of Y_1 and Y_2 into div folds. For each fold, the model Y_1 \approx X_1 \Theta X_2 Y_2 is fitted on the training samples and predictive performance is evaluated on the held-out samples.

When Y2 is a kernel matrix created by nmfkc.kernel (detected via attributes), the symmetric kernel splitting convention is used: Y2[train, train] for training and Y2[train, test] for prediction.

Usage

nmf.rrr.cv(
  Y1,
  Y2 = Y1,
  rank1 = 2,
  rank2 = NULL,
  ...,
  rank = NULL,
  rank.encoder = NULL
)

Arguments

Y1

Output matrix Y_1 (P1 x N). Non-negative.

Y2

Input matrix Y_2 (P2 x N), or a kernel matrix (N x N). Default is Y1 (autoencoder).

rank1

Integer. Rank of the response basis. Default is 2.

rank2

Integer. Rank of the covariate basis. Default (NULL) = rank1.

...

Additional arguments passed to nmfae (e.g., epsilon, maxit, Y1.weights). Also accepts: nfolds (number of folds, default 5; div also accepted), seed (integer seed, default 123), shuffle (logical, default TRUE). For backward compatibility, Q, R are accepted as aliases for rank, rank.encoder.

rank, rank.encoder

Deprecated aliases of rank1 / rank2.

Value

A list with components:

objfunc

Mean squared error per valid element over all folds.

sigma

Residual standard error (RMSE), same scale as Y_1.

objfunc.block

Per-fold squared error totals.

block

Integer vector of fold assignments (1, ..., div) for each column.

Lifecycle

This function is experimental. The interface may change in future versions; details are to be described in an upcoming paper.

See Also

nmfae, nmfae.ecv, nmfae.kernel.beta.cv, nmfkc.cv

Examples

Y <- t(iris[1:30, 1:4])
res <- nmf.rrr.cv(Y, rank1 = 2, rank2 = 2, nfolds = 5, maxit = 500)
res$sigma


nmfkc documentation built on July 14, 2026, 1:07 a.m.