R/foldFunctions.R
cvFrobeniusLoss.Rd
cvFrobeniusLoss()
evaluates the aggregated Frobenius loss
over a fold
object (from 'origami'
(Coyle and Hejazi 2018)
).
cvFrobeniusLoss(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 Frobenius loss evaluated
on a given fold
.
Coyle J, Hejazi N (2018). “origami: A Generalized Framework for Cross-Validation in R.” Journal of Open Source Software, 3(21), 512. doi: 10.21105/joss.00512 , https://doi.org/10.21105/joss.00512.
#>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]] cvFrobeniusLoss( 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)) ) )#> [[1]] #> # A tibble: 5 x 4 #> estimator hyperparameters loss fold #> <chr> <chr> <dbl> <int> #> 1 linearShrinkEst alpha = 0 55.2 1 #> 2 linearShrinkEst alpha = 1 64.5 1 #> 3 thresholdingEst gamma = 0 64.5 1 #> 4 thresholdingEst gamma = 1 58.5 1 #> 5 sampleCovEst hyperparameters = NA 64.5 1 #>