|
|
|
## Liste des scenarios
|
|
|
|
|
|
|
|
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
|
|
|
|
|
|
|
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
|
|
|
|
|
|
|
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x)))
|
|
|
|
|
|
|
|
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x)))
|
|
|
|
|
|
|
|
results <- sort(results)
|
|
|
|
|
|
|
|
results2 <- sort(results2)
|
|
|
|
|
|
|
|
results <- c(results,results2)
|
|
|
|
|
|
|
|
## Importer l'analyse resali pour chaque scenario
|
|
|
|
|
|
|
|
for (r in results) {
|
|
|
|
cat('--------------------------------------------------------------------------\n')
|
|
|
|
cat(paste0(r,"\n"))
|
|
|
|
cat('--------------------------------------------------------------------------\n')
|
|
|
|
#### Importer les datas
|
|
|
|
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(r,0,3)))
|
|
|
|
if (substr(r,start=nchar(r)-1,stop=nchar(r))=="50") {
|
|
|
|
N <- 50
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="100") {
|
|
|
|
N <- 100
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="200") {
|
|
|
|
N <- 200
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="300") {
|
|
|
|
N <- 300
|
|
|
|
}
|
|
|
|
if (scen<5) {
|
|
|
|
datt <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/NoDIF/N',N,'/scenario_',r,'.csv'))
|
|
|
|
}
|
|
|
|
if (scen>=5) {
|
|
|
|
datt <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N',N,'/scenario_',r,'.csv'))
|
|
|
|
}
|
|
|
|
#### Importer l'analyse
|
|
|
|
analyse <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection/',r,".csv"))
|
|
|
|
#### Pour chaque replication
|
|
|
|
for (k in 1:1000) {
|
|
|
|
if (k%%100==0) {
|
|
|
|
cat(paste0("N = ",k," / 1000\n"))
|
|
|
|
}
|
|
|
|
datt[datt$replication==k,"dif.detect.1"] <- analyse[analyse$X==k,"dif.detect.1"]
|
|
|
|
datt[datt$replication==k,"dif.detect.2"] <- analyse[analyse$X==k,"dif.detect.2"]
|
|
|
|
datt[datt$replication==k,"dif.detect.3"] <- analyse[analyse$X==k,"dif.detect.3"]
|
|
|
|
datt[datt$replication==k,"dif.detect.4"] <- analyse[analyse$X==k,"dif.detect.4"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.1"] <- analyse[analyse$X==k,"dif.detect.unif.1"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.2"] <- analyse[analyse$X==k,"dif.detect.unif.2"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.3"] <- analyse[analyse$X==k,"dif.detect.unif.3"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.4"] <- analyse[analyse$X==k,"dif.detect.unif.4"]
|
|
|
|
if (scen==3 | scen==4 | scen>=13) {
|
|
|
|
datt[datt$replication==k,"dif.detect.5"] <- analyse[analyse$X==k,"dif.detect.5"]
|
|
|
|
datt[datt$replication==k,"dif.detect.6"] <- analyse[analyse$X==k,"dif.detect.6"]
|
|
|
|
datt[datt$replication==k,"dif.detect.7"] <- analyse[analyse$X==k,"dif.detect.7"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.5"] <- analyse[analyse$X==k,"dif.detect.unif.5"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.6"] <- analyse[analyse$X==k,"dif.detect.unif.6"]
|
|
|
|
datt[datt$replication==k,"dif.detect.unif.7"] <- analyse[analyse$X==k,"dif.detect.unif.7"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
datt[is.na(datt$dif.detect.1),"dif.detect.1"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.2),"dif.detect.2"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.3),"dif.detect.3"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.4),"dif.detect.4"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.1),"dif.detect.unif.1"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.2),"dif.detect.unif.2"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.3),"dif.detect.unif.3"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.4),"dif.detect.unif.4"] <- ""
|
|
|
|
if (scen==3 | scen==4 | scen>=13) {
|
|
|
|
datt[is.na(datt$dif.detect.5),"dif.detect.5"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.6),"dif.detect.6"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.7),"dif.detect.7"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.5),"dif.detect.unif.5"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.6),"dif.detect.unif.6"] <- ""
|
|
|
|
datt[is.na(datt$dif.detect.unif.7),"dif.detect.unif.7"] <- ""
|
|
|
|
}
|
|
|
|
write.csv(datt,paste0("/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection_data/",r,".csv"))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (r in results) {
|
|
|
|
cat('--------------------------------------------------------------------------\n')
|
|
|
|
cat(paste0(r,"\n"))
|
|
|
|
cat('--------------------------------------------------------------------------\n')
|
|
|
|
#### Importer les datas
|
|
|
|
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(r,0,3)))
|
|
|
|
if (substr(r,start=nchar(r)-1,stop=nchar(r))=="50") {
|
|
|
|
N <- 50
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="100") {
|
|
|
|
N <- 100
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="200") {
|
|
|
|
N <- 200
|
|
|
|
}
|
|
|
|
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="300") {
|
|
|
|
N <- 300
|
|
|
|
}
|
|
|
|
#### Importer l'analyse
|
|
|
|
analyse <- read.csv(paste0("/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection_data/",r,".csv"))
|
|
|
|
analyse[is.na(analyse)] <- ""
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.1"] <- "dif_detect_1"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.2"] <- "dif_detect_2"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.3"] <- "dif_detect_3"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.4"] <- "dif_detect_4"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.1"] <- "dif_detect_unif_1"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.2"] <- "dif_detect_unif_2"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.3"] <- "dif_detect_unif_3"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.4"] <- "dif_detect_unif_4"
|
|
|
|
|
|
|
|
|
|
|
|
if (scen==3 | scen==4 | scen>=13) {
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.5"] <- "dif_detect_5"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.6"] <- "dif_detect_6"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.7"] <- "dif_detect_7"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.5"] <- "dif_detect_unif_5"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.6"] <- "dif_detect_unif_6"
|
|
|
|
names(analyse)[names(analyse)=="dif.detect.unif.7"] <- "dif_detect_unif_7"
|
|
|
|
|
|
|
|
}
|
|
|
|
analyse <- analyse[,!names(analyse) %in% c("X","X.1","X.2")]
|
|
|
|
write.csv(analyse,paste0("/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection_data/",r,".csv"))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
################################### RESALI ###################################
|
|
|
|
#----------------------------------------------------------------------------#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
generate_resali <- function(scenario=NULL,grp=NULL) {
|
|
|
|
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(scenario,0,3)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50") {
|
|
|
|
N <- 50
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100") {
|
|
|
|
N <- 100
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200") {
|
|
|
|
N <- 200
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300") {
|
|
|
|
N <- 300
|
|
|
|
}
|
|
|
|
if (scen<5) {
|
|
|
|
dat <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/NoDIF/N',N,'/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (scen>=5) {
|
|
|
|
dat <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N',N,'/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (scen%in%c(3,4,13:20)) {
|
|
|
|
res <- resali(df=dat[dat$replication==1,],items = seq(1,7),group=grp,verbose=FALSE)
|
|
|
|
df_res <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
|
|
|
|
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
|
|
|
|
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
|
|
|
|
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
|
|
|
|
dif.detect.5=ifelse(length(res$dif.items)>=5,res$dif.items[5],NA),
|
|
|
|
dif.detect.6=ifelse(length(res$dif.items)>=6,res$dif.items[6],NA),
|
|
|
|
dif.detect.7=ifelse(length(res$dif.items)>=7,res$dif.items[7],NA),
|
|
|
|
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
|
|
|
|
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
|
|
|
|
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
|
|
|
|
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
|
|
|
|
dif.detect.unif.5=ifelse(length(res$uniform)>=5,res$uniform[5],NA),
|
|
|
|
dif.detect.unif.6=ifelse(length(res$uniform)>=6,res$uniform[6],NA),
|
|
|
|
dif.detect.unif.7=ifelse(length(res$uniform)>=7,res$uniform[7],NA),
|
|
|
|
N=N,
|
|
|
|
nbdif=ifelse(scen<=4,0,ifelse(scen<=16,2,3)),
|
|
|
|
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif1)),
|
|
|
|
true.dif.2=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif2)),
|
|
|
|
true.dif.3=ifelse(scen<=16,NA,unique(dat[dat$replication==1,]$dif3))
|
|
|
|
)
|
|
|
|
for (k in 2:1000) {
|
|
|
|
if (k%%100==0) {
|
|
|
|
cat(paste0('N=',k,'/1000\n'))
|
|
|
|
}
|
|
|
|
res <- resali(df=dat[dat$replication==k,],items = seq(1,7),group=grp,verbose=FALSE)
|
|
|
|
df_res2 <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
|
|
|
|
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
|
|
|
|
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
|
|
|
|
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
|
|
|
|
dif.detect.5=ifelse(length(res$dif.items)>=5,res$dif.items[5],NA),
|
|
|
|
dif.detect.6=ifelse(length(res$dif.items)>=6,res$dif.items[6],NA),
|
|
|
|
dif.detect.7=ifelse(length(res$dif.items)>=7,res$dif.items[7],NA),
|
|
|
|
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
|
|
|
|
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
|
|
|
|
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
|
|
|
|
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
|
|
|
|
dif.detect.unif.5=ifelse(length(res$uniform)>=5,res$uniform[5],NA),
|
|
|
|
dif.detect.unif.6=ifelse(length(res$uniform)>=6,res$uniform[6],NA),
|
|
|
|
dif.detect.unif.7=ifelse(length(res$uniform)>=7,res$uniform[7],NA),
|
|
|
|
N=N,
|
|
|
|
nbdif=ifelse(scen<=4,0,ifelse(scen<=16,2,3)),
|
|
|
|
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif1)),
|
|
|
|
true.dif.2=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif2)),
|
|
|
|
true.dif.3=ifelse(scen<=16,NA,unique(dat[dat$replication==k,]$dif3)))
|
|
|
|
df_res <- rbind(df_res,df_res2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (scen%in%c(1,2,5:12)) {
|
|
|
|
res <- resali(df=dat[dat$replication==1,],items = seq(1,4),group=grp,verbose=FALSE)
|
|
|
|
df_res <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
|
|
|
|
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
|
|
|
|
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
|
|
|
|
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
|
|
|
|
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
|
|
|
|
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
|
|
|
|
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
|
|
|
|
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
|
|
|
|
N=N,
|
|
|
|
nbdif=ifelse(scen<=4,0,ifelse(scen<=8,1,2)),
|
|
|
|
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif1)),
|
|
|
|
true.dif.2=ifelse(scen<=8,NA,unique(dat[dat$replication==1,]$dif2))
|
|
|
|
)
|
|
|
|
for (k in 2:1000) {
|
|
|
|
if (k%%100==0) {
|
|
|
|
cat(paste0('N=',k,'/1000\n'))
|
|
|
|
}
|
|
|
|
res <- resali(df=dat[dat$replication==k,],items = seq(1,4),group=grp,verbose=FALSE)
|
|
|
|
df_res2 <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
|
|
|
|
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
|
|
|
|
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
|
|
|
|
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
|
|
|
|
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
|
|
|
|
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
|
|
|
|
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
|
|
|
|
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
|
|
|
|
N=N,
|
|
|
|
nbdif=ifelse(scen<=4,0,ifelse(scen<=8,1,2)),
|
|
|
|
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif1)),
|
|
|
|
true.dif.2=ifelse(scen<=8,NA,unique(dat[dat$replication==k,]$dif2)))
|
|
|
|
df_res <- rbind(df_res,df_res2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(df_res)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
|
|
|
|
|
|
|
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
|
|
|
|
|
|
|
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x)))
|
|
|
|
|
|
|
|
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x)))
|
|
|
|
|
|
|
|
results <- sort(results)
|
|
|
|
|
|
|
|
results2 <- sort(results2)
|
|
|
|
|
|
|
|
results <- c(results,results2)
|
|
|
|
|
|
|
|
for (r in results) {
|
|
|
|
cat(paste0(r,"\n"))
|
|
|
|
cat(paste0("-------------------------------------------","\n"))
|
|
|
|
write.csv(generate_resali(r,"TT"),paste0("/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection/",r,".csv"))
|
|
|
|
cat(paste0("-------------------------------------------","\n"))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|