# Example 1
## Generate xt
n <- 200
p <- 10
flag_c <- 0.8
B <- 1000
burn <- 1000
z.sim <- matrix(rnorm((n+burn)*p),p,n+burn)
phi.mat <- 0.4*diag(p)
x.sim <- phi.mat %*% z.sim[,(burn+1):(burn+n)]
x <- x.sim - rowMeans(x.sim)
Q <- 4
## Generate the sets Iq and Jq
ISET <- list()
ISET[[1]] <- matrix(c(1,2),ncol=2)
ISET[[2]] <- matrix(c(1,3),ncol=2)
ISET[[3]] <- matrix(c(1,4),ncol=2)
ISET[[4]] <- matrix(c(1,5),ncol=2)
JSET <- as.list(2*pi*seq(0,3)/4 - pi)
## Calculate Q p-values
PVal <- rep(NA,Q)
for (q in 1:Q) {
cross.indices <- ISET[[q]]
J.set <- JSET[[q]]
temp.q <- SpecTest(t(x), J.set, cross.indices, B, flag_c)
PVal[q] <- temp.q$p.value
}
res <- SpecMulTest(Q, PVal)
res
Run the code above in your browser using DataLab