hierband.cv: Performs nfolds-cross validation

Description Usage Arguments Value See Also Examples

Description

This function can be used to select a value of lam that performs well according to a user-specified measure of error.

Usage

1
2
hierband.cv(pathObj, x, errfun = function(est, true) sum((est - true)^2),
  nfolds = 5)

Arguments

pathObj

output of hierband.path

x

n by p matrix

errfun

a user-specified function measuring the loss incurred by estimating est (first argument) when the true covariance matrix is true (second argument). Default: Squared Frobenius norm.

nfolds

number of folds (default: 5)

Value

errs:

A nlam-by-nfolds matrix of errors. errs[i,j] is error incurred in using lamlist[i] on fold j

m:

CV error error for each value of lambda.

se:

Standard error (estimated over folds) for each value of lambda

lam.best:

Value of lamlist minimizing CV error.

ibest:

Index of lamlist minimizing CV error.

lam.1se.rule:

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.

i.1se.rule:

Index of lamlist of one-standard-error rule.

See Also

hierband hierband.path

Examples

 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)

Example output

1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920
1234567891011121314151617181920

hierband documentation built on May 2, 2019, 4:16 a.m.