Corrected error in dif parameterization for uncomplete answers

main
Corentin Choisy 10 months ago
parent 8ea76db3f4
commit e329a3432b

@ -1,25 +1,3 @@
pch=17,col='#9b6541')
mean.A <- sapply(c(100,200,300),function(x) mean(plot.dat[plot.dat$scenario=="9A" & plot.dat$N==x,]$h0.rejected.p))
lines(unique(plot.dat[plot.dat$scenario.type=="A",]$N),mean.A,lty=4,col='#1a342b')
points(unique(plot.dat[plot.dat$scenario.type=="A",]$N),mean.A,
pch=17,col='#1a342b')
mean.A <- sapply(c(100,200,300),function(x) mean(plot.dat[plot.dat$scenario=="11A" & plot.dat$N==x,]$h0.rejected.p))
lines(unique(plot.dat[plot.dat$scenario.type=="A",]$N),mean.A,lty=4,col='#c0c23b')
points(unique(plot.dat[plot.dat$scenario.type=="A",]$N),mean.A,
pch=17,col='#c0c23b')
## Plot 1 - baseline scenarios vs theoretical power
par(mfrow=c(1,2))
# theoretical
plot.dat <- res.dat[res.dat$scenario %in% sapply(c('A','B','C','D','E'),function(x) paste0(1:4,x)),]
plot(unique(plot.dat[plot.dat$scenario.type=="A",]$N),rep(unique(plot.dat[plot.dat$scenario.type=="A",]$theoretical.power),3),
xlab='N',ylab='Theoretical power',
xaxt='n',yaxt='n',type='l',xlim=c(100,300),ylim=c(0,1),lty=4,col='#03a18a')
axis(1,c(100,200,300))
axis(2,seq(0,1,0.1))
lines(unique(plot.dat[plot.dat$scenario %in% c("1B",'1D'),]$N),
unique(plot.dat[plot.dat$scenario %in% c("1B",'1D'),]$theoretical.power),col='#c0c23b',lty=4)
lines(unique(plot.dat[plot.dat$scenario %in% c("2B",'2D'),]$N),
unique(plot.dat[plot.dat$scenario %in% c("2B",'2D'),]$theoretical.power),col='#c0c23b',lty=4)
lines(unique(plot.dat[plot.dat$scenario %in% c("3B",'3D'),]$N),
unique(plot.dat[plot.dat$scenario %in% c("3B",'3D'),]$theoretical.power),col='#a12471',lty=4)
lines(unique(plot.dat[plot.dat$scenario %in% c("4B",'4D'),]$N),
@ -510,3 +488,25 @@ legend=c("Scenario A",
"Scenario 3-4 / B-D",
"Scenario 1-2 / C-E",
"Scenario 3-4 / C-E"),cex=0.7)
library(TAM)
library(doMC)
library(parallel)
library(pbmcapply)
library(funprog)
library(dplyr)
library(readxl)
aaaa <- read_excel("/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N50/out/8A_50.xls")
aaaa
mean(aaaa$beta)
mean(aaaa$dif1_1)
mean(aaaa$dif1_2)
mean(aaaa$dif1_3)
mean(aaaa$dif1_3,na.rm = T)
mean(aaaa$item1_1,na.rm = T)
aaaa <- read_excel("/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N50/out/10A_50.xls")
mean(aaaa$beta)
mean(aaaa$dif1_3,na.rm = T)
mean(aaaa$dif2_3,na.rm = T)
mean(aaaa$dif1_3,na.rm = T)
mean(aaaa$dif1_1,na.rm = T)
aaaa

@ -382,22 +382,52 @@ local checker: word 1 of `val'
* replications avec 3 mod
if (`checker' == 1) {
local difitems1=dif1
local difcheck = 0
forvalues i=1/`nbitems' {
qui sum item`i'
local checker2 = r(max)
if (`i'==`difitems1') {
if (`checker2'==3) {
local difcheck = 1
local constrnt = "constraint 1 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
local constrnt2 = "constraint 2 3*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([3.item`i']_cons-([3.item`i']_cons+[3.item`i'] tt))"
}
else {
local constrnt = "constraint 1 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
}
}
}
local mod "gsem "
forvalues i=1/`nbitems' {
qui sum item`i'
local checker2 = r(max)
if (`i'==`difitems1') {
if (`checker2'==3) {
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)(2.item`i'<-THETA@2 tt)(3.item`i'<-THETA@3 tt)"
}
else {
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)(2.item`i'<-THETA@2 tt)"
}
}
else {
if (`checker2'==3) {
local mod = "`mod'"+"(1.item`i'<-THETA@1)(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
}
else {
local mod = "`mod'"+"(1.item`i'<-THETA@1)(2.item`i'<-THETA@2)"
}
}
}
if (`difcheck'==1) {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2)"
}
if (`difcheck'==0) {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1)"
}
qui `constrnt'
if (`difcheck'==1) {
qui `constrnt2'
}
qui `mod'
mat V=r(table)
mat W=V[1..2,1...]
@ -719,26 +749,78 @@ local checker: word 1 of `val'
if (`checker' == 1) {
local difitems1=dif1
local difitems2=dif2
local difcheck = 0
local difcheck2 = 0
forvalues i=1/`nbitems' {
qui sum item`i'
local checker2 = r(max)
if (`i'==`difitems1') {
if (`checker2'==3) {
local difcheck = 1
local constrnt = "constraint 1 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
local constrnt3 = "constraint 3 3*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([3.item`i']_cons-([3.item`i']_cons+[3.item`i'] tt))"
}
else {
local constrnt = "constraint 1 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
}
}
if (`i'==`difitems2') {
if (`checker2'==3) {
local difcheck2=1
local constrnt2 = "constraint 2 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
local constrnt4 = "constraint 4 3*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([3.item`i']_cons-([3.item`i']_cons+[3.item`i'] tt))"
}
else {
local constrnt2 = "constraint 2 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
}
}
}
local mod "gsem "
forvalues i=1/`nbitems' {
qui sum item`i'
local checker2 = r(max)
if (`i'==`difitems1'| `i'==`difitems2') {
if (`checker2'==3) {
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)(2.item`i'<-THETA@2 tt)(3.item`i'<-THETA@3 tt)"
}
else {
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)(2.item`i'<-THETA@2 tt)"
}
}
else {
if (`checker2'==3) {
local mod = "`mod'"+"(1.item`i'<-THETA@1)(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
}
else {
local mod = "`mod'"+"(1.item`i'<-THETA@1)(2.item`i'<-THETA@2)"
}
}
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2)"
}
if (`difcheck'==1) {
if (`difcheck2'==1) {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2 3 4)"
}
else {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2 3)"
}
}
else {
if (`difcheck2'==1) {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2 4)"
}
else {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2)"
}
}
qui `constrnt'
qui `constrn2'
qui `constrnt2'
if (`difcheck'==1) {
qui `constrnt3'
}
if (`difcheck2'==1) {
qui `constrnt4'
}
qui `mod'
mat V=r(table)
mat W=V[1..2,1...]

Loading…
Cancel
Save