Description Usage Arguments Value See Also Examples
This function can be used to select a value of lam that performs well according to a user-specified measure of error.
1 2 | hierband.cv(pathObj, x, errfun = function(est, true) sum((est - true)^2),
nfolds = 5)
|
pathObj |
output of hierband.path |
x |
|
errfun |
a user-specified function measuring the loss incurred by estimating |
nfolds |
number of folds (default: 5) |
A nlam
-by-nfolds
matrix of errors. errs[i,j]
is error incurred in using lamlist[i]
on fold j
CV error error for each value of lambda.
Standard error (estimated over folds) for each value of lambda
Value of lamlist
minimizing CV error.
Index of lamlist
minimizing CV error.
Selected value of lambda using the one-standard-error rule, a common heuristic that favors a sparser model when there isn't strong evidence against it.
Index of lamlist
of one-standard-error rule.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | set.seed(123)
p <- 100
n <- 50
K <- 10
true <- ma(p, K)
x <- matrix(rnorm(n*p), n, p) %*% true$A
Sighat <- cov(x)
path <- hierband.path(Sighat)
cv <- hierband.cv(path, x)
fit <- hierband(Sighat, lam=cv$lam.best)
## Not run:
plot(cv$m, main="CV Frob Error", type="b")
lines(cv$m+cv$se, main="CV Frob Error")
lines(cv$m-cv$se, main="CV Frob Error")
abline(v=c(cv$ibest,cv$i.1se.rule), lty=2)
## End(Not run)
|
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.