Learn R Programming

bspcov (version 1.0.0)

cv.bandPPP: CV for Bayesian Estimation of a Banded Covariance Matrix

Description

Performs leave-one-out cross-validation (LOOCV) to calculate the predictive log-likelihood for a post-processed posterior of a banded covariance matrix and selects the optimal parameters.

Usage

cv.bandPPP(X, kvec, epsvec, prior = list(), nsample = 2000, ncores = 2)

Value

elpd

a M \(\times\) 3 dataframe having the expected log predictive density (ELPD) for each k and eps, where M = length(kvec) * length(epsvec).

Arguments

X

a n \(\times\) p data matrix with column mean zero.

kvec

a vector of natural numbers specifying the bandwidth of covariance matrix.

epsvec

a vector of small positive numbers decreasing to \(0\).

prior

a list giving the prior information. The list includes the following parameters (with default values in parentheses): A (I) giving the positive definite scale matrix for the inverse-Wishart prior, nu (p + k) giving the degree of freedom of the inverse-Wishar prior.

nsample

a scalar value giving the number of the post-processed posterior samples.

ncores

a scalar value giving the number of CPU cores.

Author

Kwangmin Lee

Details

The predictive log-likelihood for each \(k\) and \(\epsilon_n\) is estimated as follows: $$ \sum_{i=1}^n \log S^{-1} \sum_{s=1}^S p(X_i \mid B_k^{(\epsilon_n)}(\Sigma_{i,s})), $$ where \(X_i\) is the ith observation, \(\Sigma_{i,s}\) is the sth posterior sample based on \((X_1,\ldots,X_{i-1},X_{i+1},\ldots,X_n)\), and \(B_k^{(\epsilon_n)}\) represents the banding post-processing function. For more details, see (3) in Lee, Lee and Lee (2023+).

References

Lee, K., Lee, K., and Lee, J. (2023+), "Post-processes posteriors for banded covariances", Bayesian Analysis, DOI: 10.1214/22-BA1333.

Gelman, A., Hwang, J., and Vehtari, A. (2014). "Understanding predictive information criteria for Bayesian models." Statistics and computing, 24(6), 997-1016.

See Also

bandPPP

Examples

Run this code

# \donttest{
Sigma0 <- diag(1,50)
X <- mvtnorm::rmvnorm(25,sigma = Sigma0)
kvec <- 1:2
epsvec <- c(0.01,0.05)
res <- bspcov::cv.bandPPP(X,kvec,epsvec,nsample=10,ncores=4)
plot(res)# }
# \dontshow{
# R CMD check: make sure any open connections are closed afterward
if (!inherits(future::plan(), "sequential")) future::plan(future::sequential)
# }

Run the code above in your browser using DataLab