|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)),
|
|
|
|
J=unique(s$J),
|
|
|
|
M=unique(s$M),
|
|
|
|
eff.size=unique(s$eff.size),
|
|
|
|
nb.dif=unique(s$nb.dif),
|
|
|
|
dif.size=unique(s$dif.size)
|
|
|
|
)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se.beta),
|
|
|
|
m.low.ci.beta=mean(s$low.ci.beta),
|
|
|
|
m.high.ci.beta=mean(s$high.ci.beta),
|
|
|
|
true.value.in.ci.p=mean(s$true.value.in.ci),
|
|
|
|
h0.rejected.p=mean(s$h0.rejected),
|
|
|
|
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(s[s$h0.rejected==1,]$beta.same.sign.truebeta,na.rm=T))
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat <- compile_simulation('1A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation(x)
|
|
|
|
res.dat <- bind_rows(res.dat,y)
|
|
|
|
}
|
|
|
|
#### Create data.frame
|
|
|
|
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)
|
|
|
|
#### Compiler function
|
|
|
|
compile_simulation <- function(scenario) {
|
|
|
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (unique(s$J)==4) {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)),
|
|
|
|
J=unique(s$J),
|
|
|
|
M=unique(s$M),
|
|
|
|
eff.size=unique(s$eff.size),
|
|
|
|
nb.dif=unique(s$nb.dif),
|
|
|
|
dif.size=unique(s$dif.size)
|
|
|
|
)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se.beta),
|
|
|
|
m.low.ci.beta=mean(s$low.ci.beta),
|
|
|
|
m.high.ci.beta=mean(s$high.ci.beta),
|
|
|
|
true.value.in.ci.p=mean(s$true.value.in.ci),
|
|
|
|
h0.rejected.p=mean(s$h0.rejected),
|
|
|
|
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(s[s$h0.rejected==1,]$beta.same.sign.truebeta,na.rm=T))
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat <- compile_simulation('1A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation(x)
|
|
|
|
res.dat <- bind_rows(res.dat,y)
|
|
|
|
}
|
|
|
|
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
|
|
|
|
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
|
|
|
|
res.dat[193:417,'nb.dif'] <- 2
|
|
|
|
res.dat[417:528,'nb.dif'] <- 3
|
|
|
|
View(res.dat)
|
|
|
|
res.dat.simple <- res.dat[,c(1:8,13,16:18)]
|
|
|
|
res.dat.simple$m.beta <- round(res.dat.simple$m.beta,3)
|
|
|
|
res.dat.simple
|
|
|
|
#### Create data.frame
|
|
|
|
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)
|
|
|
|
#### Compiler function
|
|
|
|
compile_simulation <- function(scenario) {
|
|
|
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (unique(s$J)==4) {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50",50,substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
|
|
|
|
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=N,
|
|
|
|
J=unique(s$J),
|
|
|
|
M=unique(s$M),
|
|
|
|
eff.size=unique(s$eff.size),
|
|
|
|
nb.dif=unique(s$nb.dif),
|
|
|
|
dif.size=unique(s$dif.size)
|
|
|
|
)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se.beta),
|
|
|
|
m.low.ci.beta=mean(s$low.ci.beta),
|
|
|
|
m.high.ci.beta=mean(s$high.ci.beta),
|
|
|
|
true.value.in.ci.p=mean(s$true.value.in.ci),
|
|
|
|
h0.rejected.p=mean(s$h0.rejected),
|
|
|
|
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(s[s$h0.rejected==1,]$beta.same.sign.truebeta,na.rm=T))
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat <- compile_simulation('1A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation(x)
|
|
|
|
res.dat <- bind_rows(res.dat,y)
|
|
|
|
}
|
|
|
|
#### Create data.frame
|
|
|
|
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)
|
|
|
|
#### Compiler function
|
|
|
|
compile_simulation <- function(scenario) {
|
|
|
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N50/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name<=4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'.csv'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'_nodif.csv'))
|
|
|
|
}
|
|
|
|
if (unique(s$J)==4) {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unique(s$M)==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
|
|
|
|
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=N,
|
|
|
|
J=unique(s$J),
|
|
|
|
M=unique(s$M),
|
|
|
|
eff.size=unique(s$eff.size),
|
|
|
|
nb.dif=unique(s$nb.dif),
|
|
|
|
dif.size=unique(s$dif.size)
|
|
|
|
)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se.beta),
|
|
|
|
m.low.ci.beta=mean(s$low.ci.beta),
|
|
|
|
m.high.ci.beta=mean(s$high.ci.beta),
|
|
|
|
true.value.in.ci.p=mean(s$true.value.in.ci),
|
|
|
|
h0.rejected.p=mean(s$h0.rejected),
|
|
|
|
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(s[s$h0.rejected==1,]$beta.same.sign.truebeta,na.rm=T))
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat <- compile_simulation('1A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation(x)
|
|
|
|
res.dat <- bind_rows(res.dat,y)
|
|
|
|
}
|
|
|
|
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
|
|
|
|
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
|
|
|
|
res.dat[193:417,'nb.dif'] <- 2
|
|
|
|
res.dat[417:528,'nb.dif'] <- 3
|
|
|
|
View(res.dat)
|
|
|
|
res.dat.simple <- res.dat[,c(1:8,13,16:18)]
|
|
|
|
res.dat.simple$m.beta <- round(res.dat.simple$m.beta,3)
|
|
|
|
res.dat.simple
|
|
|
|
#### Create data.frame
|
|
|
|
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)[81:528]
|
|
|
|
#### Compiler function
|
|
|
|
compile_simulation2 <- function(scenario) {
|
|
|
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="50" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N50/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N100/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N200/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N300/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
J <- max(which(sapply(1:7,function(x) paste0('item',x) %in% colnames(s) | paste0('item',x,'_1') %in% colnames(s))))
|
|
|
|
M <- 1+sum(sapply(1:3,function(x) paste0('item1_',x) %in% colnames(s) ))
|
|
|
|
if (M==1) {M <- 2}
|
|
|
|
nb.dif <- max(which(sapply(1:3,function(x) paste0('dif',x) %in% colnames(s) | paste0('dif',x,'_1') %in% colnames(s))))
|
|
|
|
if (J==4) {
|
|
|
|
if (M==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (M==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
|
|
|
|
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
|
|
|
|
eff.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'eff.size'])
|
|
|
|
dif.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'dif.size'])
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=N,
|
|
|
|
J=J,
|
|
|
|
M=M,
|
|
|
|
eff.size=eff.size,
|
|
|
|
nb.dif=nb.dif,
|
|
|
|
dif.size=dif.size
|
|
|
|
)
|
|
|
|
true.value.in.ci <- eff.size <= s$beta+1.96*s$se_beta & eff.size >= s$beta-1.96*s$se_beta
|
|
|
|
beta.same.sign.truebeta.p <- ifelse(rep(eff.size,nrow(s))==0,NA,(rep(eff.size,nrow(s))/s$beta)>0)
|
|
|
|
num.reject <- which((s$beta-1.96*s$se_beta)>0 | (s$beta+1.96*s$se_beta)<0)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se_beta),
|
|
|
|
m.low.ci.beta=mean(s$beta-1.96*s$se_beta),
|
|
|
|
m.high.ci.beta=mean(s$beta+1.96*s$se_beta),
|
|
|
|
true.value.in.ci.p=mean(true.value.in.ci),
|
|
|
|
h0.rejected.p=mean( (s$beta-1.96*s$se_beta)>0 | (s$beta+1.96*s$se_beta)<0 ),
|
|
|
|
beta.same.sign.truebeta.p=mean(beta.same.sign.truebeta.p),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(beta.same.sign.truebeta.p[num.reject])
|
|
|
|
)
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat.dif <- compile_simulation2('5A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation2(x)
|
|
|
|
res.dat.dif <- bind_rows(res.dat.dif,y)
|
|
|
|
}
|
|
|
|
#### Create data.frame
|
|
|
|
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)[81:528]
|
|
|
|
#### Compiler function
|
|
|
|
compile_simulation2 <- function(scenario) {
|
|
|
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
|
|
|
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N50/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N100/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N200/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
|
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N300/',scenario,'.xls'))
|
|
|
|
}
|
|
|
|
J <- max(which(sapply(1:7,function(x) paste0('item',x) %in% colnames(s) | paste0('item',x,'_1') %in% colnames(s))))
|
|
|
|
M <- 1+sum(sapply(1:3,function(x) paste0('item1_',x) %in% colnames(s) ))
|
|
|
|
if (M==1) {M <- 2}
|
|
|
|
nb.dif <- max(which(sapply(1:3,function(x) paste0('dif',x) %in% colnames(s) | paste0('dif',x,'_1') %in% colnames(s))))
|
|
|
|
if (J==4) {
|
|
|
|
if (M==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (M==2) {
|
|
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
|
|
} else {
|
|
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
|
|
|
|
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
|
|
|
|
eff.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'eff.size'])
|
|
|
|
dif.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'dif.size'])
|
|
|
|
b <- data.frame(scenario=zz,
|
|
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
|
|
N=N,
|
|
|
|
J=J,
|
|
|
|
M=M,
|
|
|
|
eff.size=eff.size,
|
|
|
|
nb.dif=nb.dif,
|
|
|
|
dif.size=dif.size
|
|
|
|
)
|
|
|
|
true.value.in.ci <- eff.size <= s$beta+1.96*s$se_beta & eff.size >= s$beta-1.96*s$se_beta
|
|
|
|
beta.same.sign.truebeta.p <- ifelse(rep(eff.size,nrow(s))==0,NA,(rep(eff.size,nrow(s))/s$beta)>0)
|
|
|
|
num.reject <- which((s$beta-1.96*s$se_beta)>0 | (s$beta+1.96*s$se_beta)<0)
|
|
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
|
|
se.empirical.beta=sd(s$beta),
|
|
|
|
se.analytical.beta=mean(s$se_beta),
|
|
|
|
m.low.ci.beta=mean(s$beta-1.96*s$se_beta),
|
|
|
|
m.high.ci.beta=mean(s$beta+1.96*s$se_beta),
|
|
|
|
true.value.in.ci.p=mean(true.value.in.ci),
|
|
|
|
h0.rejected.p=mean( (s$beta-1.96*s$se_beta)>0 | (s$beta+1.96*s$se_beta)<0 ),
|
|
|
|
beta.same.sign.truebeta.p=mean(beta.same.sign.truebeta.p),
|
|
|
|
beta.same.sign.truebeta.signif.p=mean(beta.same.sign.truebeta.p[num.reject])
|
|
|
|
)
|
|
|
|
d <- cbind(b,a,z)
|
|
|
|
d$prop.
|
|
|
|
return(d)
|
|
|
|
}
|
|
|
|
#### Compiled results
|
|
|
|
res.dat.dif <- compile_simulation2('5A_100')
|
|
|
|
for (x in results[seq(2,length(results))]) {
|
|
|
|
y <- compile_simulation2(x)
|
|
|
|
res.dat.dif <- bind_rows(res.dat.dif,y)
|
|
|
|
}
|
|
|
|
res.dat$bias <- res.dat$eff.size-res.dat$m.beta
|
|
|
|
res.dat.dif$bias <- res.dat.dif$eff.size-res.dat.dif$m.beta
|
|
|
|
res.dat.dif
|
|
|
|
View(res.dat.dif)
|
|
|
|
mean(res.dat.dif[res.dat.dif$N==50,]$bias)
|
|
|
|
mean(res.dat.dif[res.dat.dif$N==50,]$bias,na.rm=T)
|
|
|
|
mean(res.dat.dif$bias,na.rm=T)
|
|
|
|
mean(res.dat.dif[res.dat.dif$N!=50,]$bias,na.rm=T)
|
|
|
|
mean(res.dat[res.dat$N!=50,]$bias,na.rm=T)
|
|
|
|
mean(res.dat[res.dat$N!=50,]$bias)
|