################################################################################################# ### A function to generate simulated data sets and compute the p-values using our new method #### ################################################################################################# # Input: # nrun: number of simulated data sets # n: number of observations in the data set # p: number of molecular variables # q: number of clinical covariates # muX: shift for the relevant molecular variables # muz: shift for the clinical covariates # prel: number of relevant molecular variables # nperm: number of permutation used to compute the p-value # mstop: a vector giving the values of mstop that have to be considered # XeqZ: should the relevant X variables be equal to the Z variables? # Output: # a nrun x (length(mstop)+2) matrix with the p-values obtained with different values of mstop and with the globaltest (last column) simulation<-function(nrun,n=100,p=1000,q=5,muX,muZ,prel,nperm,mstop,XeqZ=FALSE) { result<-matrix(0,nrun,length(mstop)+2) goeman<-function(X,Y,Z) { globaltest(X=t(X),Y=Y,adjust=Z) } for (i in 1:nrun) { print(paste("i=",i)) set.seed(i) Y<-as.factor(rbinom(n,1,0.5)) X<-as.data.frame(matrix(rnorm(n*p),n,p)) if (prel>0 & muX>0) { X[Y==1,1:prel]<-X[Y==1,1:prel]+muX } if (!XeqZ) { Z<-as.data.frame(matrix(rnorm(n*q),n,q)) if (muZ>0) { Z[Y==1,]<-Z[Y==1,]+muZ } } else { Z<-X[,1:prel] } my.testi<-globalboosttest(X,Y,Z,nperm=nperm,mstop=mstop,mstopAIC=TRUE,plot=TRUE,pvalueonly=TRUE) result[i,1:(length(mstop)+1)]<-my.testi$pvalue result[i,length(mstop)+2]<-p.value(goeman(X,Y,Z)) } colnames(result)<-c(paste("mstop=",mstop),"AIC","globaltest") rownames(result)<-paste("run",1:nrun,sep="") return(result) }