| nmfre.ecv | R Documentation |
Selects the basis rank Q for nmfre by Wold-style
element-wise (entry-holdout) cross-validation that exercises the
random effects. For each fold the held-out entries are hidden and filled by
iterative imputation: fit the NMF-RE model on the current matrix, replace the
held-out entries with the BLUP prediction X(\Theta A + U), and repeat.
The score is the held-out prediction RMSE (sigma); the selected
rank minimizes it.
Because the held-out entries of a column are predicted using the random
effect u_n fitted from that column's retained entries, this
evaluates the full NMF-RE model (including U) — unlike
nmfkc.ecv, which masks entries by zero weight and predicts from
the fixed-effect fit X\Theta A only. The two scores are therefore
not directly comparable.
nmfre.ecv(Y, A = NULL, rank = 1:3, C.signed = TRUE, ...)
Y |
Observation matrix (P x N), non-negative. |
A |
Covariate matrix (K x N). Default is a row of ones (intercept only). |
rank |
Integer vector of ranks |
C.signed |
Logical. Sign convention for |
... |
Additional arguments:
|
A list of class "nmfre.ecv" with components:
rankThe ranks evaluated.
sigmaNamed numeric vector of held-out RMSE per rank
(same field name as nmfkc.ecv).
bestThe rank minimizing sigma.
nfolds, rounds, C.signedSettings used.
nmfre, nmfre.inference, nmfkc.ecv
if (requireNamespace("nlme", quietly = TRUE)) {
Y <- matrix(nlme::Orthodont$distance, 4, 27)
male <- ifelse(nlme::Orthodont$Sex[seq(1, 108, 4)] == "Male", 1, 0)
A <- rbind(intercept = 1, male = male)
cv <- nmfre.ecv(Y, A, rank = 1:3)
cv$best
plot(cv)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.