View source: R/foldFunctions.R
cvScaledMatrixFrobeniusLoss | R Documentation |
cvScaledMatrixFrobeniusLoss()
evaluates the scaled matrix
Frobenius loss over a fold
object (from 'origami'
\insertCiteCoyle2018cvCovEst). The squared error loss computed for each
entry of the estimated covariance matrix is scaled by the training set's
sample variances of the variable associated with that entry's row and
column variables. This loss should be used instead of
cvMatrixFrobeniusLoss()
when a dataset's variables' values
are of different magnitudes.
cvScaledMatrixFrobeniusLoss(fold, dat, estimator_funs, estimator_params = NULL)
fold |
A |
dat |
A |
estimator_funs |
An |
estimator_params |
A named |
A tibble
providing information on estimators,
their hyperparameters (if any), and their scaled matrix Frobenius loss
evaluated on a given fold
.
library(MASS)
library(origami)
library(rlang)
# generate 10x10 covariance matrix with unit variances and off-diagonal
# elements equal to 0.5
Sigma <- matrix(0.5, nrow = 10, ncol = 10) + diag(0.5, nrow = 10)
# sample 50 observations from multivariate normal with mean = 0, var = Sigma
dat <- mvrnorm(n = 50, mu = rep(0, 10), Sigma = Sigma)
# generate a single fold using MC-cv
resub <- make_folds(dat,
fold_fun = folds_vfold,
V = 2
)[[1]]
cvScaledMatrixFrobeniusLoss(
fold = resub,
dat = dat,
estimator_funs = rlang::quo(c(
linearShrinkEst, thresholdingEst, sampleCovEst
)),
estimator_params = list(
linearShrinkEst = list(alpha = c(0, 1)),
thresholdingEst = list(gamma = c(0, 1))
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.