library(randomForest)
library(party)
source("fun.r")

gini0.05n500ntree5000<-c()
gini0.1n500ntree5000<-c()
gini0.25n500ntree5000<-c()
gini0.4n500ntree5000<-c()


for (i in 1:100)
 {
 set.seed(i)
 print(i)
 my.data<-simSNP(n.snp=200,n.obs=500,maf=rep(c(0.05,0.1,0.25,0.4),each=50),beta0=0)
 my.rf<-randomForest(x=my.data[,-1],y=my.data[,1],ntree=5000,importance=TRUE)
 my.importance<-importance(my.rf,scale=FALSE)
 gini0.05n500ntree5000<-c(gini0.05n500ntree5000,my.importance[1:50,4])
 gini0.1n500ntree5000<-c(gini0.1n500ntree5000,my.importance[51:100,4])
 gini0.25n500ntree5000<-c(gini0.25n500ntree5000,my.importance[101:150,4])
 gini0.4n500ntree5000<-c(gini0.4n500ntree5000,my.importance[151:200,4])

 rm(my.rf)
 rm(my.importance)
 
save(gini0.05n500ntree5000,file="nullcase_n500_ntree5000/gini0.05n500ntree5000.RData")
save(gini0.1n500ntree5000,file="nullcase_n500_ntree5000/gini0.1n500ntree5000.RData")
save(gini0.25n500ntree5000,file="nullcase_n500_ntree5000/gini0.25n500ntree5000.RData")
save(gini0.4n500ntree5000,file="nullcase_n500_ntree5000/gini0.4n500ntree5000.RData")


}