Banded.Sample.CV: Selects bandwidth for sample covariance matrix by cross...

Description Usage Arguments Value Examples

Description

Selects bandwidth for sample covariance matrix by k-fold cross validation

Usage

1
banded.sample.cv(X, bandwidth, folds = 3, est.eval = TRUE, Frob = TRUE)

Arguments

X

A data matrix with n rows and p columns. Rows are assumed to be independent realizations from a p-variate distribution with covariance Σ.

bandwidth

A vector of candidate bandwidths. Candidate bandwidths can only positive integers such that the maximum is less than p-1

.

folds

The number of folds used for cross validation. Default is folds =3.

est.eval

Logical: est.eval = TRUE returns a list with both the selected bandwidth and the estimated covariance matrix. est.eval=FALSE returns a list with only the selected bandwidth. The default is est.eval = TRUE.

Frob

Logical: Frob = TRUE uses squared Frobenius norm loss for cross-validation. Frob = FALSE uses operator norm loss. Default is Frob = TRUE.

Value

A list with

bandwidth.min

the bandwidth minimizing cv error

est

the sample covariance matrix at bandwidth.min

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## set sample size and dimension
n=20
p=100

## create covariance with AR1 structure
Sigma = matrix(0, nrow=p, ncol=p)
for(l in 1:p){
  for(m in 1:p){
    Sigma[l,m] = .5^(abs(l-m))
  }
}

## simulation Normal data
eo1 = eigen(Sigma)
Sigma.sqrt = eo1$vec%*%diag(eo1$val^.5)%*%t(eo1$vec)
X = t(Sigma.sqrt%*%matrix(rnorm(n*p), nrow=p, ncol=n))

## perform cross validation
k = 4:7
out2.cv = banded.sample.cv(X, bandwidth=k, folds=5)

FastBandChol documentation built on May 2, 2019, 3:41 a.m.