DIF results obtained + restructured some files
This commit is contained in:
@ -1,179 +1,61 @@
|
|||||||
muB=10
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
kappa=1
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
sd=10
|
eff.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'eff.size'])
|
||||||
alpha=0.05
|
dif.size <- unique(res.dat[res.dat$scenario==zz & res.dat$N==N,'dif.size'])
|
||||||
beta=0.20
|
b <- data.frame(scenario=zz,
|
||||||
(nB=(1+1/kappa)*(sd*(qnorm(1-alpha/2)+qnorm(1-beta))/(muA-muB))^2)
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
||||||
ceiling(nB) # 63
|
N=N,
|
||||||
z=(muA-muB)/(sd*sqrt((1+1/kappa)/nB))
|
J=J,
|
||||||
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-alpha/2)))
|
M=M,
|
||||||
muA=5
|
eff.size=eff.size,
|
||||||
muB=10
|
nb.dif=nb.dif,
|
||||||
kappa=1
|
dif.size=dif.size
|
||||||
sd=10
|
|
||||||
alpha=0.05
|
|
||||||
beta=0.20
|
|
||||||
(nB=(1+1/kappa)*(sd*(qnorm(1-alpha/2)+qnorm(1-beta))/(muA-muB))^2)
|
|
||||||
ceiling(nB) # 63
|
|
||||||
z=(muA-muB)/(sd*sqrt((1+1/kappa)/nB))
|
|
||||||
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-alpha/2)))
|
|
||||||
-1*(-0.49-0.47)
|
|
||||||
-1*(-1.69-0.95)+(-0.49-0.47)
|
|
||||||
-1*(-0.49-0.47)-0.49
|
|
||||||
-1*(-0.49-0.47)-1.69
|
|
||||||
-1*(-0.49-0.47)-(1.69-0.49)
|
|
||||||
3.35-1.69
|
|
||||||
library(TAM)
|
|
||||||
library(doMC)
|
|
||||||
library(parallel)
|
|
||||||
library(pbmcapply)
|
|
||||||
library(funprog)
|
|
||||||
library(dplyr)
|
|
||||||
lastChar <- function(str){
|
|
||||||
substr(str, nchar(str)-2, nchar(str))
|
|
||||||
}
|
|
||||||
pcm_analysis <- function(df=NULL,treatment='TT',irtmodel='PCM2',method='MML') {
|
|
||||||
nbitems <- sum(sapply(1:20,function(x) paste0('item',x)) %in% colnames(df))
|
|
||||||
resp <- df[,sapply(seq(1,nbitems),function(x) paste0('item',x))]
|
|
||||||
if (method=='MML') {
|
|
||||||
tam1 <- tam.mml(resp=resp,Y=df[,treatment],irtmodel = irtmodel,est.variance = T,verbose=F)
|
|
||||||
}
|
|
||||||
if (method=='JML') {
|
|
||||||
tam1 <- tam.jml(resp=resp,group=1+df[,treatment])
|
|
||||||
}
|
|
||||||
if (method!='MML' & method!='JML') {
|
|
||||||
stop('Invalid method. Please choose among MML or JML')
|
|
||||||
}
|
|
||||||
return(tam1)
|
|
||||||
}
|
|
||||||
replicate_pcm_analysis_m4 <- function(df=NULL,treatment='TT',irtmodel='PCM2',method='MML',sequence='replication',eff.size=0,difsize=NA,nbdif=0) {
|
|
||||||
nbitems <- sum(sapply(1:20,function(x) paste0('item',x)) %in% colnames(df))
|
|
||||||
resp <- df[,sapply(seq(1,nbitems),function(x) paste0('item',x))]
|
|
||||||
truebeta <- eff.size
|
|
||||||
if (method=='MML') {
|
|
||||||
n <- max(df[,sequence])
|
|
||||||
print(n)
|
|
||||||
tam1 <- lapply(seq(1,n),
|
|
||||||
function(x) pcm_analysis(df=df[df[,sequence]==x,],treatment=treatment,irtmodel=irtmodel)
|
|
||||||
)
|
)
|
||||||
|
true.value.in.ci <- eff.size > s$beta+1.96*s$se_beta | eff.size < s$beta-1.96*s$se_beta
|
||||||
|
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=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 ))
|
||||||
|
d <- cbind(b,a,z)
|
||||||
|
d$prop.
|
||||||
|
return(d)
|
||||||
}
|
}
|
||||||
listitems <- c(sapply(c('_1','_2','_3'),function(x) paste0(sapply(seq(1,nbitems),function(x) paste0('item',x)),x)))
|
#### Compiled results
|
||||||
returndat <- data.frame(matrix(nrow=max(df[,sequence]),ncol=length(listitems)))
|
res.dat.dif <- compile_simulation2('5A_100')
|
||||||
colnames(returndat) <- listitems
|
for (x in results[seq(2,length(results))]) {
|
||||||
for (s in seq(1,max(df[,sequence]))) {
|
y <- compile_simulation2(x)
|
||||||
for (k in seq(1,nbitems)) {
|
res.dat.dif <- bind_rows(res.dat.dif,y)
|
||||||
returndat[s,paste0('item',k,'_1')] <- tam1[[s]]$item[k,'AXsi_.Cat1']
|
|
||||||
returndat[s,paste0('item',k,'_2')] <- tam1[[s]]$item[k,'AXsi_.Cat2']-tam1[[s]]$item[k,'AXsi_.Cat1']
|
|
||||||
returndat[s,paste0('item',k,'_3')] <- tam1[[s]]$item[k,'AXsi_.Cat3']-tam1[[s]]$item[k,'AXsi_.Cat2']
|
|
||||||
}
|
}
|
||||||
}
|
res.dat.dif
|
||||||
returndat <- returndat[,sort_by(listitems, lastChar)]
|
#### Create data.frame
|
||||||
returndat$beta <- sapply(seq(1,max(df[,sequence])),function(k) tam1[[k]]$beta[2])
|
|
||||||
returndat$se.beta <- 1.413612*sapply(seq(1,max(df[,sequence])),function(k) tam.se(tam1[[k]])$beta$se.Dim1[2] )
|
|
||||||
returndat$low.ci.beta <- returndat$beta-1.96*returndat$se.beta
|
|
||||||
returndat$high.ci.beta <- returndat$beta+1.96*returndat$se.beta
|
|
||||||
returndat$true.value.in.ci <- 1*(truebeta>returndat$low.ci.beta & truebeta<returndat$high.ci.beta)
|
|
||||||
returndat$h0.rejected <- 1*(0<returndat$low.ci.beta | 0>returndat$high.ci.beta)
|
|
||||||
if (truebeta==0) {
|
|
||||||
returndat$beta.same.sign.truebeta <- NA
|
|
||||||
} else {
|
|
||||||
returndat$beta.same.sign.truebeta <- 1*(sign(truebeta)==sign(returndat$beta))
|
|
||||||
}
|
|
||||||
returndat2 <- data.frame(J=rep(nbitems,max(df[,sequence])),
|
|
||||||
M=1+max(df$item1),
|
|
||||||
N=nrow(df[df$replication==1,])/2,
|
|
||||||
eff.size=truebeta,
|
|
||||||
dif.size= difsize,
|
|
||||||
nb.dif= nbdif
|
|
||||||
)
|
|
||||||
returndat <- cbind(returndat2,returndat)
|
|
||||||
return(returndat)
|
|
||||||
}
|
|
||||||
replicate_pcm_analysis_m2 <- function(df=NULL,treatment='TT',irtmodel='PCM2',method='MML',sequence='replication',eff.size=0,difsize=NA,nbdif=0) {
|
|
||||||
truebeta <- eff.size
|
|
||||||
nbitems <- sum(sapply(1:20,function(x) paste0('item',x)) %in% colnames(df))
|
|
||||||
resp <- df[,sapply(seq(1,nbitems),function(x) paste0('item',x))]
|
|
||||||
if (method=='MML') {
|
|
||||||
n <- max(df[,sequence])
|
|
||||||
print(n)
|
|
||||||
tam1 <- lapply(seq(1,n),
|
|
||||||
function(x) pcm_analysis(df=df[df[,sequence]==x,],treatment=treatment,irtmodel=irtmodel)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
listitems <- sapply(seq(1,nbitems),function(x) paste0('item',x))
|
|
||||||
returndat <- data.frame(matrix(nrow=max(df[,sequence]),ncol=length(listitems)))
|
|
||||||
colnames(returndat) <- listitems
|
|
||||||
for (s in seq(1,max(df[,sequence]))) {
|
|
||||||
for (k in seq(1,nbitems)) {
|
|
||||||
returndat[s,paste0('item',k)] <- tam1[[s]]$xsi$xsi[k]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
returndat$beta <- sapply(seq(1,max(df[,sequence])),function(k) tam1[[k]]$beta[2])
|
|
||||||
returndat$se.beta <- 1.413612*sapply(seq(1,max(df[,sequence])),function(k) tam.se(tam1[[k]])$beta$se.Dim1[2] )
|
|
||||||
returndat$low.ci.beta <- returndat$beta-1.96*returndat$se.beta
|
|
||||||
returndat$high.ci.beta <- returndat$beta+1.96*returndat$se.beta
|
|
||||||
returndat$true.value.in.ci <- 1*(truebeta>returndat$low.ci.beta & truebeta<returndat$high.ci.beta)
|
|
||||||
returndat$h0.rejected <- 1*(0<returndat$low.ci.beta | 0>returndat$high.ci.beta)
|
|
||||||
if (truebeta==0) {
|
|
||||||
returndat$beta.same.sign.truebeta <- NA
|
|
||||||
} else {
|
|
||||||
returndat$beta.same.sign.truebeta <- 1*(sign(truebeta)==sign(returndat$beta))
|
|
||||||
}
|
|
||||||
returndat2 <- data.frame(J=rep(nbitems,max(df[,sequence])),
|
|
||||||
M=1+max(df$item1),
|
|
||||||
N=nrow(df[df$replication==1,])/2,
|
|
||||||
eff.size=truebeta,
|
|
||||||
dif.size= difsize,
|
|
||||||
nb.dif= nbdif
|
|
||||||
)
|
|
||||||
returndat <- cbind(returndat2,returndat)
|
|
||||||
return(returndat)
|
|
||||||
}
|
|
||||||
replicate_pcm_analysis<- function(df=NULL,treatment='TT',irtmodel='PCM2',method='MML',sequence='replication',eff.size=0,difsize=NA,nbdif=0) {
|
|
||||||
j <- max(df$item1)
|
|
||||||
if(j==1) {
|
|
||||||
return(replicate_pcm_analysis_m2(df=df,treatment=treatment,irtmodel=irtmodel,method=method,sequence=sequence,eff.size=eff.size,difsize=difsize,nbdif=nbdif))
|
|
||||||
} else {
|
|
||||||
return(replicate_pcm_analysis_m4(df=df,treatment=treatment,irtmodel=irtmodel,method=method,sequence=sequence,eff.size=eff.size,difsize=difsize,nbdif=nbdif))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
registerDoMC(4)
|
|
||||||
dat1 <- read.csv(file = '/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N100/scenario_20A_100.csv')
|
|
||||||
res_nodif <- pbmclapply(c('dat1'),function(x) replicate_pcm_analysis(get(x),nbdif = 1,difsize = 0.5))
|
|
||||||
write.csv(res_nodif[[1]],'/home/corentin/Documents/These/Recherche/Simulation/Analysis/DIF/N100/scenario_20A_100_nodif.csv')
|
|
||||||
res_nodif[[1]]
|
|
||||||
write.csv(res_nodif[[1]],'/home/corentin/Documents/These/Recherche/Simulationss/Analysis/NoDIF/N100/scenario_20A_100_nodif.csv')
|
|
||||||
write.csv(res_nodif[[1]],'/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_20A_100_nodif.csv')
|
|
||||||
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'))))
|
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'))))
|
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
||||||
results <- c(sapply(c(100,200,300),function(x) paste0(results,'_',x)))
|
results <- c(sapply(c(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
results <- sort(results)
|
results <- sort(results)
|
||||||
results2 <- sort(results2)
|
results2 <- sort(results2)
|
||||||
results <- c(results,results2)
|
results <- c(results,results2)[61:396]
|
||||||
#### Compiler function
|
#### Compiler function
|
||||||
compile_simulation <- function(scenario) {
|
compile_simulation2 <- function(scenario) {
|
||||||
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
name <- as.numeric(gsub("[^0-9.-]", "", substr(scenario,start=0,stop=2)))
|
||||||
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) {
|
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'))
|
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.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) {
|
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'))
|
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.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) {
|
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'))
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N300/',scenario,'.xls'))
|
||||||
}
|
}
|
||||||
if (unique(s$J)==4) {
|
J <- max(which(sapply(1:7,function(x) paste0('item',x) %in% colnames(s) | paste0('item',x,'_1') %in% colnames(s))))
|
||||||
if (unique(s$M)==2) {
|
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))
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
||||||
} else {
|
} 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),
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
||||||
@ -183,7 +65,7 @@ m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (unique(s$M)==2) {
|
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),
|
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))
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
||||||
} else {
|
} else {
|
||||||
@ -198,58 +80,413 @@ 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)
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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,
|
b <- data.frame(scenario=zz,
|
||||||
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
||||||
N=substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)),
|
N=N,
|
||||||
J=unique(s$J),
|
J=J,
|
||||||
M=unique(s$M),
|
M=M,
|
||||||
eff.size=unique(s$eff.size),
|
eff.size=eff.size,
|
||||||
nb.dif=unique(s$nb.dif),
|
nb.dif=nb.dif,
|
||||||
dif.size=unique(s$dif.size)
|
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
|
||||||
z <- data.frame(m.beta=mean(s$beta),
|
z <- data.frame(m.beta=mean(s$beta),
|
||||||
se.empirical.beta=sd(s$beta),
|
se.empirical.beta=sd(s$beta),
|
||||||
se.analytical.beta=mean(s$se.beta),
|
se.analytical.beta=mean(s$se_beta),
|
||||||
m.low.ci.beta=mean(s$low.ci.beta),
|
m.low.ci.beta=mean(s$beta-1.96*s$se_beta),
|
||||||
m.high.ci.beta=mean(s$high.ci.beta),
|
m.high.ci.beta=mean(s$beta+1.96*s$se_beta),
|
||||||
true.value.in.ci.p=mean(s$true.value.in.ci),
|
true.value.in.ci=mean(true.value.in.ci),
|
||||||
h0.rejected.p=mean(s$h0.rejected),
|
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(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 <- cbind(b,a,z)
|
||||||
d$prop.
|
d$prop.
|
||||||
return(d)
|
return(d)
|
||||||
}
|
}
|
||||||
#### Compiled results
|
#### Compiled results
|
||||||
res.dat <- compile_simulation('1A_100')
|
res.dat.dif <- compile_simulation2('5A_100')
|
||||||
for (x in results[seq(2,length(results))]) {
|
for (x in results[seq(2,length(results))]) {
|
||||||
y <- compile_simulation(x)
|
y <- compile_simulation2(x)
|
||||||
res.dat <- bind_rows(res.dat,y)
|
res.dat.dif <- bind_rows(res.dat.dif,y)
|
||||||
}
|
}
|
||||||
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
|
res.dat.dif
|
||||||
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
|
which((s$beta-1.96*s$se_beta)>0 | (s$beta+1.96*s$se_beta)<0)
|
||||||
res.dat[132:300,'nb.dif'] <- 2
|
#### Create data.frame
|
||||||
res.dat[300:396,'nb.dif'] <- 3
|
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'))))
|
||||||
res.dat.simple <- res.dat[,c(1:8,13,16:18)]
|
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
|
||||||
res.dat.simple$m.beta <- round(res.dat.simple$m.beta,3)
|
results <- c(sapply(c(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
res.dat.simple
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
|
results <- sort(results)
|
||||||
|
results2 <- sort(results2)
|
||||||
|
results <- c(results,results2)[61:396]
|
||||||
|
#### 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))=="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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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(eff.size==0,NA,eff.size/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.dif
|
||||||
|
ifelse(eff.size==0,NA,eff.size/s$beta>0)
|
||||||
|
ifelse(0==0,NA,0/s$beta>0)
|
||||||
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N100/',"5C_100",'.xls'))
|
||||||
|
s <- read_excel(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N100/',"5C_100",'.xls'))
|
||||||
|
s$beta
|
||||||
|
0.2/s$beta
|
||||||
|
0.2/s$beta>0
|
||||||
|
mean(0.2/s$beta>0)
|
||||||
|
#### 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(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
|
results <- sort(results)
|
||||||
|
results2 <- sort(results2)
|
||||||
|
results <- c(results,results2)[61:396]
|
||||||
|
#### 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))=="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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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(eff.size==0,NA,(eff.size/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.dif
|
||||||
|
#### 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(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
|
results <- sort(results)
|
||||||
|
results2 <- sort(results2)
|
||||||
|
results <- c(results,results2)[61:396]
|
||||||
|
#### 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))=="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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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(eff.size==0,NA,(eff.size/s$beta)>0)
|
||||||
|
print(beta.same.sign.truebeta.p)
|
||||||
|
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(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
|
results <- sort(results)
|
||||||
|
results2 <- sort(results2)
|
||||||
|
results <- c(results,results2)[61:396]
|
||||||
|
#### 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))=="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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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.dif
|
||||||
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size
|
||||||
res.null <- res.dat[res.dat$eff.size==0,]
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0,]
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,1),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,1),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
res.null0 <- res.dat[res.dat$eff.size==0 & res.dat$dif.size==0,]
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==0,]
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='gray',pch=3)
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='gray',pch=3)
|
||||||
res.null3 <- res.dat[res.dat$eff.size==0 & res.dat$dif.size==-0.3,]
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==-0.3,]
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
res.null5 <- res.dat[res.dat$eff.size==0 & res.dat$dif.size==-0.5,]
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==-0.5,]
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
par(mfrow=c(2,2))
|
par(mfrow=c(2,2))
|
||||||
# 0 item
|
# 0 item
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0,]
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==0,]
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
par(mfrow=c(2,2))
|
||||||
|
# 0 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==0,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
||||||
|
res.null
|
||||||
|
par(mfrow=c(2,2))
|
||||||
# 1 item
|
# 1 item
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==1,]
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1,]
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
@ -257,7 +494,7 @@ points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
# 2 items
|
# 2 items
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2,]
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2,]
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
@ -265,7 +502,7 @@ points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
# 3 items
|
# 3 items
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==3,]
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3,]
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
@ -273,240 +510,3 @@ points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
par(mfrow=c(1,1))
|
par(mfrow=c(1,1))
|
||||||
par(mfrow=c(2,2))
|
|
||||||
# 0 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0 & res.dat$J==4,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
|
||||||
# 1 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==1 & res.dat$J==4,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 2 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2 & res.dat$J==4,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
par(mfrow=c(1,1))
|
|
||||||
par(mfrow=c(2,2))
|
|
||||||
# 0 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0 & res.dat$J==7,]
|
|
||||||
nrow(res.null)
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
|
||||||
# 2 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2 & res.dat$J==7,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 3 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==3 & res.dat$J==7,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
par(mfrow=c(1,1))
|
|
||||||
par(mfrow=c(2,2))
|
|
||||||
# 0 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
|
||||||
# 1 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==1 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 2 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 3 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==3 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
par(mfrow=c(1,1))
|
|
||||||
####### N=200
|
|
||||||
par(mfrow=c(2,2))
|
|
||||||
# 0 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0 & res.dat$N==200,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
|
||||||
# 1 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==1 & res.dat$N==200,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 2 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2 & res.dat$N==200,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 3 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==3 & res.dat$N==200,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
par(mfrow=c(1,1))
|
|
||||||
####### N=300
|
|
||||||
par(mfrow=c(2,2))
|
|
||||||
# 0 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==0 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='No DIF',ylim=c(0,1))
|
|
||||||
points(y=res.null$h0.rejected.p,x=rep(1,nrow(res.null)),col='#590b0c',pch=3)
|
|
||||||
# 1 item
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==1 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 2 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==2 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
# 3 items
|
|
||||||
res.null <- res.dat[res.dat$eff.size==0 & res.dat$nb.dif==3 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
|
||||||
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
par(mfrow=c(1,1))
|
|
||||||
res.null <- res.dat[res.dat$eff.size>0,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
|
||||||
res.null0 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0,]
|
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.3,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.5,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
####### N=100
|
|
||||||
res.null <- res.dat[res.dat$eff.size>0 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
|
||||||
res.null0 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0 & res.dat$N==100,]
|
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.3 & res.dat$N==100,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.5 & res.dat$N==100,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.3 & res.dat$N==100,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.5 & res.dat$N==100,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
####### N=300 // DIF à 0.5 - QUELS SONT LES SCENARIOS EN HAUT
|
|
||||||
res.null <- res.dat[res.dat$eff.size>0 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
|
||||||
res.null0 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0 & res.dat$N==300,]
|
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.3 & res.dat$N==300,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==-0.5 & res.dat$N==300,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.3 & res.dat$N==300,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size>0 & res.dat$dif.size==0.5 & res.dat$N==300,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
############# By N // EFF SIZE NEGATIVE
|
|
||||||
####### N=100
|
|
||||||
res.null <- res.dat[res.dat$eff.size<0 & res.dat$N==100,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
|
||||||
res.null0 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==0 & res.dat$N==100,]
|
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==-0.3 & res.dat$N==100,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==-0.5 & res.dat$N==100,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
####### N=300 // DIF à 0.5 - QUELS SONT LES SCENARIOS EN HAUT
|
|
||||||
res.null <- res.dat[res.dat$eff.size<0 & res.dat$N==300,]
|
|
||||||
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
|
||||||
res.null0 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==0 & res.dat$N==300,]
|
|
||||||
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==-0.3 & res.dat$N==300,]
|
|
||||||
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null5 <- res.dat[res.dat$eff.size<0 & res.dat$dif.size==-0.5 & res.dat$N==300,]
|
|
||||||
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
|
||||||
boxplot(true.value.in.ci.p~dif.size,data=res.dat,col=c(2,3),xlab='DIF size',
|
|
||||||
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.5,]
|
|
||||||
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.5,]
|
|
||||||
points(y=res.null3$true.value.in.ci.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.3,]
|
|
||||||
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0,]
|
|
||||||
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
|
||||||
# Overall
|
|
||||||
boxplot(beta.same.sign.truebeta.p~dif.size,data=res.dat,col=c(2,3),xlab='DIF size',
|
|
||||||
ylab='Proportion of estimates with same sign as true value in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.5,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.5,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.3,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
|
||||||
# Overall // H0 rejected
|
|
||||||
boxplot(beta.same.sign.truebeta.signif.p~dif.size,data=res.dat,col=c(2,3),xlab='DIF size',
|
|
||||||
ylab='Proportion of estimates with same sign as true value in target scenario',main='When H0 rejected',ylim=c(0,1))
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.5,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.5,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==-0.3,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0.3,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
|
||||||
res.null3 <- res.dat[res.dat$dif.size==0,]
|
|
||||||
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
|
||||||
|
438
RProject/Scripts/desc_analysis_dif.R
Normal file
438
RProject/Scripts/desc_analysis_dif.R
Normal file
@ -0,0 +1,438 @@
|
|||||||
|
##############################################################################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
############################ BOXPLOTS H0 SCENARIOS ###########################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,1),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==0,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='gray',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 1 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 3 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size (1 item) J=4
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 1 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1 & res.dat.dif$J==4,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2 & res.dat.dif$J==4,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
|
||||||
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size (1 item) J=7
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2 & res.dat.dif$J==7,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 3 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3 & res.dat.dif$J==7,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
############# By N
|
||||||
|
|
||||||
|
####### N=100
|
||||||
|
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 1 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1 & res.dat.dif$N==100,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2 & res.dat.dif$N==100,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 3 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3 & res.dat.dif$N==100,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
|
||||||
|
####### N=200
|
||||||
|
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 1 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1 & res.dat.dif$N==200,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2 & res.dat.dif$N==200,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 3 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3 & res.dat.dif$N==200,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
|
||||||
|
####### N=300
|
||||||
|
|
||||||
|
|
||||||
|
par(mfrow=c(2,2))
|
||||||
|
|
||||||
|
# 1 item
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==1 & res.dat.dif$N==300,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 1 item',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 2 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==2 & res.dat.dif$N==300,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 2 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# 3 items
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size==0 & res.dat.dif$nb.dif==3 & res.dat.dif$N==300,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2),xlab='DIF size',
|
||||||
|
ylab='H0 rejection proportion in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.null[res.null$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.null[res.null$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
par(mfrow=c(1,1))
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
############################ BOXPLOTS H1 SCENARIOS ###########################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
#### CALCULER LA PUISSANCE THEORIQUE AVEC RASCHPOWER
|
||||||
|
|
||||||
|
## Proportion of rejected h0 per dif value in h1 scenarios by DIF size // eff.size positive
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size>0,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.3,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.5,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
############# By N // EFF SIZE POSITIVE
|
||||||
|
|
||||||
|
####### N=100
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$N==100,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.3 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.5 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.3 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.5 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
####### N=300 // DIF à 0.5 - QUELS SONT LES SCENARIOS EN HAUT
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$N==300,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.3 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==-0.5 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.3 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size>0 & res.dat.dif$dif.size==0.5 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(5,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
############# By N // EFF SIZE NEGATIVE
|
||||||
|
|
||||||
|
####### N=100
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$N==100,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==0 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==-0.3 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==-0.5 & res.dat.dif$N==100,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
####### N=300 // DIF à 0.5 - QUELS SONT LES SCENARIOS EN HAUT
|
||||||
|
|
||||||
|
res.null <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$N==300,]
|
||||||
|
boxplot(h0.rejected.p~dif.size,data=res.null,col=c(3,2,4,2,3),xlab='DIF size',ylab='H0 rejection proportion in target scenario')
|
||||||
|
res.null0 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==0 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null0$h0.rejected.p,x=rep(3,nrow(res.null0)),col='darkblue',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==-0.3 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null3$h0.rejected.p,x=rep(2,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null5 <- res.dat.dif[res.dat.dif$eff.size<0 & res.dat.dif$dif.size==-0.5 & res.dat.dif$N==300,]
|
||||||
|
points(y=res.null5$h0.rejected.p,x=rep(1,nrow(res.null5)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
########################## SYSTEMATIC ERROR BOXPLOTS #########################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Overall
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif,col=c(2,3),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
||||||
|
|
||||||
|
# J=4
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==4,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
# J=7
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==7,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
||||||
|
|
||||||
|
# J=4 / 1 DIF
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==4 & res.dat.dif$nb.dif==1,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3,3,2),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
# J=4 / 2 DIF
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==4 & res.dat.dif$nb.dif==2,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3,3,2),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
# J=7 / 2 DIF
|
||||||
|
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==7 & res.dat.dif$nb.dif==2,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3,3,2),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
# J=7 / 3 DIF
|
||||||
|
|
||||||
|
res.dat.dif.temp <- res.dat.dif[res.dat.dif$J==7 & res.dat.dif$nb.dif==3,]
|
||||||
|
|
||||||
|
boxplot(true.value.in.ci.p~dif.size,data=res.dat.dif.temp,col=c(2,3,3,2),xlab='DIF size',
|
||||||
|
ylab='Proportion of true beta value in CI in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.5,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(4,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif.temp[res.dat.dif.temp$dif.size==0.3,]
|
||||||
|
points(y=res.null3$true.value.in.ci.p,x=rep(3,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
########################## BETA SIGN CHANGE BOXPLOTS #########################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Overall
|
||||||
|
|
||||||
|
boxplot(beta.same.sign.truebeta.p~dif.size,data=res.dat.dif,col=c(2,3),xlab='DIF size',
|
||||||
|
ylab='Proportion of estimates with same sign as true value in target scenario',main='DIF on 3 items',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.5,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.3,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
||||||
|
|
||||||
|
# Overall // H0 rejected
|
||||||
|
|
||||||
|
boxplot(beta.same.sign.truebeta.signif.p~dif.size,data=res.dat.dif,col=c(2,3),xlab='DIF size',
|
||||||
|
ylab='Proportion of estimates with same sign as true value in target scenario',main='When H0 rejected',ylim=c(0,1))
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.5,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(1,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.5,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(5,nrow(res.null3)),col='#590b0c',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==-0.3,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(2,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0.3,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(4,nrow(res.null3)),col='#053305',pch=3)
|
||||||
|
res.null3 <- res.dat.dif[res.dat.dif$dif.size==0,]
|
||||||
|
points(y=res.null3$beta.same.sign.truebeta.signif.p,x=rep(3,nrow(res.null3)),col='gray',pch=3)
|
@ -2159,3 +2159,108 @@ 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$m.beta <- round(res.dat.simple$m.beta,3)
|
||||||
res.dat.simple
|
res.dat.simple
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
########################### AGGREGATION DIF MATRICES #########################
|
||||||
|
#----------------------------------------------------------------------------#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
#### 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(100,200,300),function(x) paste0(results,'_',x)))
|
||||||
|
|
||||||
|
results2 <- c(sapply(c(100,200,300),function(x) paste0(results2,'_',x)))
|
||||||
|
|
||||||
|
results <- sort(results)
|
||||||
|
|
||||||
|
results2 <- sort(results2)
|
||||||
|
|
||||||
|
results <- c(results,results2)[61:396]
|
||||||
|
|
||||||
|
|
||||||
|
#### 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))=="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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
||||||
|
N <- substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))
|
||||||
|
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)
|
||||||
|
}
|
Reference in New Issue
Block a user