# NOT RUN {
set.seed(1)
nsnps <- 100
# derive joint Z score vector
Zj <- rep(0, nsnps)
iCV <- 4 # index of CV
mu <- 5 # true effect at CV
Zj[iCV] <- mu
## generate example LD matrix
library(mvtnorm)
nsamples = 1000
simx <- function(nsnps, nsamples, S, maf=0.1) {
mu <- rep(0,nsnps)
rawvars <- rmvnorm(n=nsamples, mean=mu, sigma=S)
pvars <- pnorm(rawvars)
x <- qbinom(1-pvars, 1, maf)
}
S <- (1 - (abs(outer(1:nsnps,1:nsnps,`-`))/nsnps))^4
X <- simx(nsnps,nsamples,S)
LD <- cor2(X)
res <- z_sim(Zj, Sigma = LD, nrep = 100)
res[c(1:5), c(1:5)]
# }
Run the code above in your browser using DataLab