You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
513 lines
28 KiB
R
513 lines
28 KiB
R
muB=10
|
|
kappa=1
|
|
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)))
|
|
muA=5
|
|
muB=10
|
|
kappa=1
|
|
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)
|
|
)
|
|
}
|
|
listitems <- c(sapply(c('_1','_2','_3'),function(x) paste0(sapply(seq(1,nbitems),function(x) paste0('item',x)),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,'_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']
|
|
}
|
|
}
|
|
returndat <- returndat[,sort_by(listitems, lastChar)]
|
|
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'))))
|
|
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)
|
|
#### Compiler function
|
|
compile_simulation <- 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.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'.csv'))
|
|
}
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100" & name>4) {
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N100/scenario_',scenario,'_nodif.csv'))
|
|
}
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name<=4) {
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'.csv'))
|
|
}
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200" & name>4) {
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N200/scenario_',scenario,'_nodif.csv'))
|
|
}
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name<=4) {
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'.csv'))
|
|
}
|
|
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300" & name>4) {
|
|
s <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Analysis/NoDIF/N300/scenario_',scenario,'_nodif.csv'))
|
|
}
|
|
if (unique(s$J)==4) {
|
|
if (unique(s$M)==2) {
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4))
|
|
} else {
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3)
|
|
)
|
|
}
|
|
} else {
|
|
if (unique(s$M)==2) {
|
|
a <- data.frame(m.item1=mean(s$item1),m.item2=mean(s$item2),m.item3=mean(s$item3),m.item4=mean(s$item4),
|
|
m.item5=mean(s$item5),m.item6=mean(s$item6),m.item7=mean(s$item7))
|
|
} else {
|
|
a <- data.frame(m.item1_1=mean(s$item1_1),m.item1_2=mean(s$item1_2),m.item1_3=mean(s$item1_3),
|
|
m.item2_1=mean(s$item2_1),m.item2_2=mean(s$item2_2),m.item2_3=mean(s$item2_3),
|
|
m.item3_1=mean(s$item3_1),m.item3_2=mean(s$item3_2),m.item3_3=mean(s$item3_3),
|
|
m.item4_1=mean(s$item4_1),m.item4_2=mean(s$item4_2),m.item4_3=mean(s$item4_3),
|
|
m.item5_1=mean(s$item5_1),m.item5_2=mean(s$item5_2),m.item5_3=mean(s$item5_3),
|
|
m.item6_1=mean(s$item6_1),m.item6_2=mean(s$item6_2),m.item6_3=mean(s$item6_3),
|
|
m.item7_1=mean(s$item7_1),m.item7_2=mean(s$item7_2),m.item7_3=mean(s$item7_3)
|
|
)
|
|
}
|
|
}
|
|
zz <- substr(scenario,start=0,stop=nchar(scenario)-4)
|
|
b <- data.frame(scenario=zz,
|
|
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
|
N=substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)),
|
|
J=unique(s$J),
|
|
M=unique(s$M),
|
|
eff.size=unique(s$eff.size),
|
|
nb.dif=unique(s$nb.dif),
|
|
dif.size=unique(s$dif.size)
|
|
)
|
|
z <- data.frame(m.beta=mean(s$beta),
|
|
se.empirical.beta=sd(s$beta),
|
|
se.analytical.beta=mean(s$se.beta),
|
|
m.low.ci.beta=mean(s$low.ci.beta),
|
|
m.high.ci.beta=mean(s$high.ci.beta),
|
|
true.value.in.ci.p=mean(s$true.value.in.ci),
|
|
h0.rejected.p=mean(s$h0.rejected),
|
|
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
|
beta.same.sign.truebeta.signif.p=mean(s[s$h0.rejected==1,]$beta.same.sign.truebeta,na.rm=T))
|
|
d <- cbind(b,a,z)
|
|
d$prop.
|
|
return(d)
|
|
}
|
|
#### Compiled results
|
|
res.dat <- compile_simulation('1A_100')
|
|
for (x in results[seq(2,length(results))]) {
|
|
y <- compile_simulation(x)
|
|
res.dat <- bind_rows(res.dat,y)
|
|
}
|
|
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
|
|
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
|
|
res.dat[132:300,'nb.dif'] <- 2
|
|
res.dat[300:396,'nb.dif'] <- 3
|
|
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
|
|
## Proportion of rejected h0 per dif value in h0 scenarios (A) by DIF size
|
|
res.null <- res.dat[res.dat$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[res.dat$eff.size==0 & res.dat$dif.size==0,]
|
|
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,]
|
|
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)
|
|
par(mfrow=c(2,2))
|
|
# 0 item
|
|
res.null <- res.dat[res.dat$eff.size==0 & res.dat$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))
|
|
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,]
|
|
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,]
|
|
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,]
|
|
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$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)
|