Corrected bugs + TAM dif analysis

main
Corentin Choisy 9 months ago
parent 17f44d750a
commit e8f7bd6eb9

File diff suppressed because it is too large Load Diff

@ -0,0 +1,27 @@
library(mirt)
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)
}
dff <- read.csv(file = '/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N50/scenario_5A_50.csv')
dfff <- dff[dff$replication==1,]
facets <- dfff$TT
dfff$item2_noTT <- NA
dfff$item2_TT <- NA
dfff[dfff$TT==0,]$item2_noTT <- dfff[dfff$TT==0,"item2"]
dfff[dfff$TT==1,]$item2_TT <- dfff[dfff$TT==1,"item2"]
mml.mod <- tam.mml(resp=dfff[,c('item1','item2_noTT','item2_TT',"item3","item4")],Y=dfff$TT,constraint='cases'
,irtmodel = "PCM2",est.variance = T,verbose=F)

@ -71,7 +71,7 @@
mat outmat[`k',`nbitems'+4] = `difitems1' // numéro item de dif
restore
}
putexcel set "`path_res'/out/5`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/5`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -149,7 +149,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+6] = `difitems1' // numéro item de dif
restore
}
putexcel set "`path_res'/out/6`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/6`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -208,7 +208,7 @@ putexcel A1=matrix(outmat), colnames
mat outmat[`k',`nbitems'+4] = `difitems1' // numéro item de dif
restore
}
putexcel set "`path_res'/out/7`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/7`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -286,7 +286,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+6] = `difitems1' // numéro item de dif
restore
}
putexcel set "`path_res'/out/8`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/8`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -364,7 +364,7 @@ adopath+"/home/corentin/Documents/These/Recherche/Simulations/Modules/"
mat outmat[`k',`nbitems'+6] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/9`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/9`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -474,7 +474,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+10] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/10`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/10`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -548,7 +548,7 @@ putexcel A1=matrix(outmat), colnames
mat outmat[`k',`nbitems'+6] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/11`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/11`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -658,7 +658,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+10] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/12`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/12`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -742,7 +742,7 @@ adopath+"/home/corentin/Documents/These/Recherche/Simulations/Modules/"
mat outmat[`k',`nbitems'+6] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/13`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/13`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -852,7 +852,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+10] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/14`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/14`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -926,7 +926,7 @@ putexcel A1=matrix(outmat), colnames
mat outmat[`k',`nbitems'+6] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/15`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/15`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -1036,7 +1036,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+10] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/16`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/16`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -1130,7 +1130,7 @@ adopath+"/home/corentin/Documents/These/Recherche/Simulations/Modules/"
mat outmat[`k',`nbitems'+8] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/17`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/17`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -1274,7 +1274,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+14] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/18`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/18`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -1363,7 +1363,7 @@ putexcel A1=matrix(outmat), colnames
mat outmat[`k',`nbitems'+8] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/19`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/19`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
@ -1507,7 +1507,7 @@ forvalues k=1/1000 {
mat outmat[`k',3*`nbitems'+14] = `difitemsmax' // numéro item de dif
restore
}
putexcel set "`path_res'/out/20`scen'_`Nn'.xls", sheet("outmat") replace
putexcel set "`path_res'/20`scen'_`Nn'.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}

Loading…
Cancel
Save