mxPBF_cov | R Documentation |
This function detects change points in the covariance structure of multivariate Gaussian data using the Maximum Pairwise Bayes Factor (mxPBF).
The function selects alpha that controls the empirical False Positive Rate (FPR), as suggested in the paper.
One can conduct a multiscale approach using the function majority_rule_mxPBF()
.
mxPBF_cov(
given_data,
nws,
alps,
a0 = 0.01,
b0 = 0.01,
FPR_want = 0.05,
n_sample = 300,
n_cores = 1
)
given_data |
An |
nws |
A set of window sizes for change point detection. |
alps |
A grid of alpha values used in the empirical False Positive Rate (FPR) method. |
a0 |
A hyperparameter |
b0 |
A hyperparameter |
FPR_want |
Desired False Positive Rate for selecting alpha, used in the empirical FPR method (default: 0.05). |
n_sample |
Number of simulated samples to estimate the empirical FPR, used in the empirical FPR method (default: 300). |
n_cores |
Number of threads for parallel execution via OpenMP (default: 1). |
A list of length equal to the number of window sizes provided. Each element in the list contains:
Locations of detected change points.
Vector of calculated Bayes Factors for each middle points.
Optimal alpha value selected based on the method that controls the empirical FPR.
Window size used for change point detection.
nws <- c(25, 60, 100)
alps <- seq(1,10,0.05)
## H0 data
mu <- rep(0,10)
sigma1 <- diag(10)
X <- mvrnorm_cpp(500, mu, sigma1)
res1 <- mxPBF_cov(X, nws, alps)
## H1 data
mu <- rep(0,10)
sigma2 <- diag(10)
for (i in 1:10) {
for (j in i:10) {
if (i == j) {
next
} else {
cov_value <- rnorm(1, 1, 1)
sigma2[i, j] <- cov_value
sigma2[j, i] <- cov_value
}
}
}
sigma2 <- sigma2 + (abs(min(eigen(sigma2)$value))+0.1)*diag(10) # Make it nonsingular
Y1 <- mvrnorm_cpp(250, mu, sigma1)
Y2 <- mvrnorm_cpp(250, mu, sigma2)
Y <- rbind(Y1, Y2)
res2 <- mxPBF_cov(Y, nws, alps)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.