ss=100
nvar=100
X = as.data.frame(matrix(rnorm(ss*nvar),nrow=ss,ncol=nvar))
e = as.data.frame(matrix(rnorm(ss*nvar),nrow=ss,ncol=nvar))
Y = .1*X + e
nperm = 10
myanalysis = function(X,Y){
ntests = ncol(X)
rslts = as.data.frame(matrix(NA,nrow=ntests,ncol=2))
names(rslts) = c("ID","pvalue")
rslts[,"ID"] = 1:ntests
for(i in 1:ntests){
fit = cor.test(X[,i],Y[,i],na.action="na.exclude",
alternative="two.sided",method="pearson")
rslts[i,"pvalue"] = fit$p.value
}
return(rslts)
} # End myanalysis
# Generate observed results
obs = myanalysis(X,Y)
## Generate permuted results
perml = vector('list',nperm)
for(p_ in 1:nperm){
X1 = X[order(runif(nvar)),]
perml[[p_]] = myanalysis(X1,Y)
}
## FDR results (permutation)
fdr_od(obs$pvalue,perml,"pvalue",nvar, thres = .05)
## FDR results (parametric)
fdr_od(obs$pvalue, permp = NULL, thres = 0.05, meff = FALSE, seff = FALSE, mymat = X)
Run the code above in your browser using DataLab