plot.bspcov {bspcov} | R Documentation |
Plot Diagnostics of Posterior Samples and Cross-Validation
Description
Provides a trace plot of posterior samples and a plot of a learning curve for cross-validation
Usage
## S3 method for class 'bspcov'
plot(x, ..., cols, rows)
Arguments
x |
an object from bmspcov, sbmspcov, cv.bandPPP, and cv.thresPPP. |
... |
additional arguments for ggplot2. |
cols |
a scalar or a vector including specific column indices for the trace plot. |
rows |
a scalar or a vector including specific row indices greater than or equal to columns indices for the trace plot. |
Value
plot |
a plot for diagnostics of posterior samples x. |
Author(s)
Seongil Jo
Examples
set.seed(1)
n <- 100
p <- 20
# generate a sparse covariance matrix:
True.Sigma <- matrix(0, nrow = p, ncol = p)
diag(True.Sigma) <- 1
Values <- -runif(n = p*(p-1)/2, min = 0.2, max = 0.8)
nonzeroIND <- which(rbinom(n=p*(p-1)/2,1,prob=1/p)==1)
zeroIND = (1:(p*(p-1)/2))[-nonzeroIND]
Values[zeroIND] <- 0
True.Sigma[lower.tri(True.Sigma)] <- Values
True.Sigma[upper.tri(True.Sigma)] <- t(True.Sigma)[upper.tri(True.Sigma)]
if(min(eigen(True.Sigma)$values) <= 0){
delta <- -min(eigen(True.Sigma)$values) + 1.0e-5
True.Sigma <- True.Sigma + delta*diag(p)
}
# generate a data
X <- MASS::mvrnorm(n = n, mu = rep(0, p), Sigma = True.Sigma)
# compute sparse, positive covariance estimator:
fout <- bspcov::sbmspcov(X = X, Sigma = diag(diag(cov(X))))
plot(fout, cols = c(1, 3, 4), rows = c(1, 3, 4))
plot(fout, cols = 1, rows = 1:3)
# Cross-Validation for Banded Structure
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)
[Package bspcov version 1.0.0 Index]