View source: R/normal_block_cv.R
| normal_block_cv | R Documentation |
Splits the observations into folds, fits normal_block() on all but one
fold and evaluates the held-out log-likelihood of the left-out fold (see
heldout_loglik() in NormalBlockBase), for every model of the
collection. It selects the number of clusters without a penalty, and
compares models of different families, shapes of Sigma or scalings.
normal_block_cv(
data,
blocks,
model = c("var", "mean"),
zero_inflation = FALSE,
sparsity = 0,
folds = 5,
control = NB_control(verbose = FALSE)
)
data |
a NormalBlockData object |
blocks |
as in |
model, zero_inflation, sparsity |
as in |
folds |
the number of folds, or a vector of |
control |
a list of controls, see |
an object of class normal_block_cv: a data frame with one row
per model (q), the total held-out log-likelihood over the n
observations (loglik, larger is better) and its standard error
(se, from the spread of the per-observation values); the
per-observation values are kept in the per_observation attribute
(n x number of models) and the folds in folds. Its best attribute
is the q chosen by the one-standard-error rule, the smallest q within one
standard error of the maximum; best_max is the maximum itself, which
tends to over-select.
ex <- generate_normal_block_var_data(n = 60, p = 15, d = 1, q = 3)
data <- NormalBlockData$new(ex$Y, ex$X)
set.seed(1)
cv <- normal_block_cv(data, blocks = 2:4, folds = 3)
cv
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.