Learn R Programming

CovTools (version 0.4.0)

PreEst.banded2: Bayesian Estimation of a Banded Precision Matrix (Lee 2017)

Description

PreEst.banded2 returns a Bayes estimator of the banded precision matrix, which is defined in subsection 3.3 of Lee and Lee (2017), using the k-BC prior. The bandwidth is set at the mode of marginal posterior for the bandwidth parameter.

Usage

PreEst.banded2(X, upperK = floor(ncol(X)/2), logpi = function(k) {    
  -k^4 })

Arguments

X

an \((n\times p)\) data matrix where each row is an observation.

upperK

upper bound of bandwidth \(k\).

logpi

log of prior distribution for bandwidth \(k\). Default is a function proportional to \(-k^4\).

Value

a named list containing:

C

a \((p\times p)\) MAP estimate for precision matrix.

References

lee_estimating_2017CovTools

Examples

Run this code
# NOT RUN {
## generate data from multivariate normal with Identity precision.
data = mvtnorm::rmvnorm(100, sigma=diag(10))

## compare different K
out1 <- PreEst.banded2(data, upperK=1)
out2 <- PreEst.banded2(data, upperK=3)
out3 <- PreEst.banded2(data, upperK=5)

## visualize
par(mfrow=c(2,2), pty="s")
image(pracma::flipud(diag(10)),main="Original Precision")
image(pracma::flipud(out1$C), main="banded2::upperK=1")
image(pracma::flipud(out2$C), main="banded2::upperK=3")
image(pracma::flipud(out3$C), main="banded2::upperK=5")

# }

Run the code above in your browser using DataLab