From 34fd6ea608325e60ce192b14f147fc48fd9d51af Mon Sep 17 00:00:00 2001 From: corentinchoisy Date: Tue, 5 Mar 2024 15:08:40 +0100 Subject: [PATCH] Code for the 4 rosali versions + analysis --- Modules/rosali_custom/rosali_nobf.ado | 4 +- Modules/rosali_custom/rosali_nolrt.ado | 4 +- Modules/rosali_custom/rosali_nolrt_nobf.ado | 4 +- Modules/rosali_custom/rosali_original.ado | 4 +- Scripts/ROSALI-SIM.do | 349 ++++++++++++++++++++ 5 files changed, 357 insertions(+), 8 deletions(-) create mode 100644 Scripts/ROSALI-SIM.do diff --git a/Modules/rosali_custom/rosali_nobf.ado b/Modules/rosali_custom/rosali_nobf.ado index 2eb8af2..127b0d4 100644 --- a/Modules/rosali_custom/rosali_nobf.ado +++ b/Modules/rosali_custom/rosali_nobf.ado @@ -617,7 +617,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " di _dup(49) "_ " di - di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" + *di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" ********************************* ** MODEL B ** @@ -769,7 +769,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " local diftestp=r(p) if `diftestp'<0.05{ /*If pvalue(LRtest)<0.05 then step C*/ di - di as input "PROCESSING STEP C" + *di as input "PROCESSING STEP C" di /*test DIF pour chaque item*/ diff --git a/Modules/rosali_custom/rosali_nolrt.ado b/Modules/rosali_custom/rosali_nolrt.ado index b2975ce..958f083 100644 --- a/Modules/rosali_custom/rosali_nolrt.ado +++ b/Modules/rosali_custom/rosali_nolrt.ado @@ -617,7 +617,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " di _dup(49) "_ " di - di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" + *di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" ********************************* ** MODEL B ** @@ -768,7 +768,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " local diftestp = 1 if `diftestp'<2{ /*If pvalue(LRtest)<0.05 then step C*/ di - di as input "PROCESSING STEP C" + *di as input "PROCESSING STEP C" di /*test DIF pour chaque item*/ diff --git a/Modules/rosali_custom/rosali_nolrt_nobf.ado b/Modules/rosali_custom/rosali_nolrt_nobf.ado index 8f273aa..1fe3c3d 100644 --- a/Modules/rosali_custom/rosali_nolrt_nobf.ado +++ b/Modules/rosali_custom/rosali_nolrt_nobf.ado @@ -617,7 +617,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " di _dup(49) "_ " di - di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" + *di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" ********************************* ** MODEL B ** @@ -768,7 +768,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " local diftestp = 1 if `diftestp'<2{ /*If pvalue(LRtest)<0.05 then step C*/ di - di as input "PROCESSING STEP C" + *di as input "PROCESSING STEP C" di /*test DIF pour chaque item*/ diff --git a/Modules/rosali_custom/rosali_original.ado b/Modules/rosali_custom/rosali_original.ado index 7aa7b91..0b60694 100644 --- a/Modules/rosali_custom/rosali_original.ado +++ b/Modules/rosali_custom/rosali_original.ado @@ -617,7 +617,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " di _dup(49) "_ " di - di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" + *di as input "PART 1: DETECTION OF DIFFERENCE IN ITEM DIFFICULTIES BETWEEN GROUPS AT TIME 1" ********************************* ** MODEL B ** @@ -769,7 +769,7 @@ if "`group'"!="" & "`nodif'"=="" { // PARTIE 1 = Slmt si option group & pas de " local diftestp=r(p) if `diftestp'<0.05{ /*If pvalue(LRtest)<0.05 then step C*/ di - di as input "PROCESSING STEP C" + *di as input "PROCESSING STEP C" di /*test DIF pour chaque item*/ diff --git a/Scripts/ROSALI-SIM.do b/Scripts/ROSALI-SIM.do new file mode 100644 index 0000000..530bd53 --- /dev/null +++ b/Scripts/ROSALI-SIM.do @@ -0,0 +1,349 @@ +*================================================================================================================================================= +* Date : 2024-03-04 +* Stata version : Stata 18 SE +* +* This program evaluates DIF detection performance for multiple ROSALI versions +* +* ado-files needed : - rosali_nolrt, rosali_nobf, rosali_nolrt_nobf, rosali_original +* +* +*================================================================================================================================================ + +* Load pcm.ado +adopath+"/home/corentin/Documents/These/Recherche/ROSALI-SIM/Modules/rosali_custom" + + + + + ************************************************** Version 1: original + local N = "50 300" + local ss = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" + foreach s in `ss' { + foreach Nnn in `N' { + local Nn = `Nnn' + local path_data = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Data/N`Nn'" + local path_res = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Analysis/original/N`Nn'" + local scenarios = "A B C" + foreach scen in `scenarios' { + clear + import delim "`path_data'/scenario_`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear + + if (`s'<=2) { + local nbitems=4 + } + else if (`s'<=4) { + local nbitems=7 + } + else if (`s'<=12) { + local nbitems=4 + } + else { + local nbitems=7 + } + + if (`s'<=4) { + local nbdif=0 + } + else if (`s'<=8) { + local nbdif=1 + } + else if (`s'<=12) { + local nbdif=2 + } + else { + local nbdif=3 + } + local taillemat=`nbitems'+3+`nbdif' + + mat outmat = J(1000,`taillemat',.) + di "Scenario `s'`scen' / N=`Nnn'" + forvalues k=1/1000 { + if (mod(`k',100)==0) { + di "`k'/1000" + } + preserve + qui keep if replication==`k' + qui rosali_original item1-item`nbitems' item1-item`nbitems', group(TT) + qui mat resmat=r(difitems) + forvalues jj=1/`nbitems' { + qui mat outmat[`k',`jj']=resmat[1,`jj'] + } + qui mat outmat[`k',`nbitems'+1]=`Nn' + qui mat outmat[`k',`nbitems'+2]=`nbitems' + qui mat outmat[`k',`nbitems'+3]=`nbdif' + if (`nbdif' > 0) { + qui levelsof dif1 + local ldif1 = r(levels) + local diff1: word 1 of `ldif1' + qui mat outmat[`k',`nbitems'+4]=`diff1' + if (`nbdif' > 1) { + qui levelsof dif2 + local ldif2 = r(levels) + local diff2: word 1 of `ldif2' + qui mat outmat[`k',`nbitems'+5]=`diff2' + if (`nbdif' > 2) { + qui levelsof dif3 + local ldif3 = r(levels) + local diff3: word 1 of `ldif3' + qui mat outmat[`k',`nbitems'+6]=`diff3' + } + } + } + restore + } + putexcel set "`path_res'/`s'`scen'_`Nn'_original.xls", sheet("outmat") replace + putexcel A1=matrix(outmat), colnames +} +} +} + + + + ************************************************** Version 2: noBF + local N = "50 300" + local ss = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" + foreach s in `ss' { + foreach Nnn in `N' { + local Nn = `Nnn' + local path_data = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Data/N`Nn'" + local path_res = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Analysis/noBF/N`Nn'" + local scenarios = "A B C" + foreach scen in `scenarios' { + clear + import delim "`path_data'/scenario_`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear + + if (`s'<=2) { + local nbitems=4 + } + else if (`s'<=4) { + local nbitems=7 + } + else if (`s'<=12) { + local nbitems=4 + } + else { + local nbitems=7 + } + + if (`s'<=4) { + local nbdif=0 + } + else if (`s'<=8) { + local nbdif=1 + } + else if (`s'<=12) { + local nbdif=2 + } + else { + local nbdif=3 + } + local taillemat=`nbitems'+3+`nbdif' + + mat outmat = J(1000,`taillemat',.) + di "Scenario `s'`scen' / N=`Nnn'" + forvalues k=1/1000 { + if (mod(`k',100)==0) { + di "`k'/1000" + } + preserve + qui keep if replication==`k' + qui rosali_nobf item1-item`nbitems' item1-item`nbitems', group(TT) + qui mat resmat=r(difitems) + forvalues jj=1/`nbitems' { + qui mat outmat[`k',`jj']=resmat[1,`jj'] + } + qui mat outmat[`k',`nbitems'+1]=`Nn' + qui mat outmat[`k',`nbitems'+2]=`nbitems' + qui mat outmat[`k',`nbitems'+3]=`nbdif' + if (`nbdif' > 0) { + qui levelsof dif1 + local ldif1 = r(levels) + local diff1: word 1 of `ldif1' + qui mat outmat[`k',`nbitems'+4]=`diff1' + if (`nbdif' > 1) { + qui levelsof dif2 + local ldif2 = r(levels) + local diff2: word 1 of `ldif2' + qui mat outmat[`k',`nbitems'+5]=`diff2' + if (`nbdif' > 2) { + qui levelsof dif3 + local ldif3 = r(levels) + local diff3: word 1 of `ldif3' + qui mat outmat[`k',`nbitems'+6]=`diff3' + } + } + } + restore + } + putexcel set "`path_res'/`s'`scen'_`Nn'_noBF.xls", sheet("outmat") replace + putexcel A1=matrix(outmat), colnames +} +} +} + + + + ************************************************** Version 3: noLRT + local N = "50 300" + local ss = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" + foreach s in `ss' { + foreach Nnn in `N' { + local Nn = `Nnn' + local path_data = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Data/N`Nn'" + local path_res = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Analysis/noLRT/N`Nn'" + local scenarios = "A B C" + foreach scen in `scenarios' { + clear + import delim "`path_data'/scenario_`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear + + if (`s'<=2) { + local nbitems=4 + } + else if (`s'<=4) { + local nbitems=7 + } + else if (`s'<=12) { + local nbitems=4 + } + else { + local nbitems=7 + } + + if (`s'<=4) { + local nbdif=0 + } + else if (`s'<=8) { + local nbdif=1 + } + else if (`s'<=12) { + local nbdif=2 + } + else { + local nbdif=3 + } + local taillemat=`nbitems'+3+`nbdif' + + mat outmat = J(1000,`taillemat',.) + di "Scenario `s'`scen' / N=`Nnn'" + forvalues k=1/1000 { + if (mod(`k',100)==0) { + di "`k'/1000" + } + preserve + qui keep if replication==`k' + qui rosali_nolrt item1-item`nbitems' item1-item`nbitems', group(TT) + qui mat resmat=r(difitems) + forvalues jj=1/`nbitems' { + qui mat outmat[`k',`jj']=resmat[1,`jj'] + } + qui mat outmat[`k',`nbitems'+1]=`Nn' + qui mat outmat[`k',`nbitems'+2]=`nbitems' + qui mat outmat[`k',`nbitems'+3]=`nbdif' + if (`nbdif' > 0) { + qui levelsof dif1 + local ldif1 = r(levels) + local diff1: word 1 of `ldif1' + qui mat outmat[`k',`nbitems'+4]=`diff1' + if (`nbdif' > 1) { + qui levelsof dif2 + local ldif2 = r(levels) + local diff2: word 1 of `ldif2' + qui mat outmat[`k',`nbitems'+5]=`diff2' + if (`nbdif' > 2) { + qui levelsof dif3 + local ldif3 = r(levels) + local diff3: word 1 of `ldif3' + qui mat outmat[`k',`nbitems'+6]=`diff3' + } + } + } + restore + } + putexcel set "`path_res'/`s'`scen'_`Nn'_noLRT.xls", sheet("outmat") replace + putexcel A1=matrix(outmat), colnames +} +} +} + + + ************************************************** Version 4: noLRT noBF + local N = "50 300" + local ss = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20" + foreach s in `ss' { + foreach Nnn in `N' { + local Nn = `Nnn' + local path_data = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Data/N`Nn'" + local path_res = "/home/corentin/Documents/These/Recherche/ROSALI-SIM/Analysis/noLRTnoBF/N`Nn'" + local scenarios = "A B C" + foreach scen in `scenarios' { + clear + import delim "`path_data'/scenario_`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear + + if (`s'<=2) { + local nbitems=4 + } + else if (`s'<=4) { + local nbitems=7 + } + else if (`s'<=12) { + local nbitems=4 + } + else { + local nbitems=7 + } + + if (`s'<=4) { + local nbdif=0 + } + else if (`s'<=8) { + local nbdif=1 + } + else if (`s'<=12) { + local nbdif=2 + } + else { + local nbdif=3 + } + local taillemat=`nbitems'+3+`nbdif' + + mat outmat = J(1000,`taillemat',.) + di "Scenario `s'`scen' / N=`Nnn'" + forvalues k=1/1000 { + if (mod(`k',100)==0) { + di "`k'/1000" + } + preserve + qui keep if replication==`k' + qui rosali_nolrt_nobf item1-item`nbitems' item1-item`nbitems', group(TT) + qui mat resmat=r(difitems) + forvalues jj=1/`nbitems' { + qui mat outmat[`k',`jj']=resmat[1,`jj'] + } + qui mat outmat[`k',`nbitems'+1]=`Nn' + qui mat outmat[`k',`nbitems'+2]=`nbitems' + qui mat outmat[`k',`nbitems'+3]=`nbdif' + if (`nbdif' > 0) { + qui levelsof dif1 + local ldif1 = r(levels) + local diff1: word 1 of `ldif1' + qui mat outmat[`k',`nbitems'+4]=`diff1' + if (`nbdif' > 1) { + qui levelsof dif2 + local ldif2 = r(levels) + local diff2: word 1 of `ldif2' + qui mat outmat[`k',`nbitems'+5]=`diff2' + if (`nbdif' > 2) { + qui levelsof dif3 + local ldif3 = r(levels) + local diff3: word 1 of `ldif3' + qui mat outmat[`k',`nbitems'+6]=`diff3' + } + } + } + restore + } + putexcel set "`path_res'/`s'`scen'_`Nn'_noLRT_noBF.xls", sheet("outmat") replace + putexcel A1=matrix(outmat), colnames +} +} +}