|
|
|
@ -432,7 +432,7 @@ forvalues k=1/1000 {
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
`mod'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
@ -616,7 +616,7 @@ forvalues k=1/1000 {
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
`mod'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
@ -686,11 +686,11 @@ putexcel A1=matrix(outmat), colnames
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 4
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 2
|
|
|
|
|
local taillemat = `nbitems'+`nbdif'+4
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "dif1" "dif2" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "item5" "item6" "item7" "dif1" "dif2" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
di "Scenario 13`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
@ -760,11 +760,11 @@ import delim "`path_data'/scenario_14`scen'_`Nn'.csv", encoding(ISO-8859-2) cas
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 4
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 2
|
|
|
|
|
local taillemat = 3*`nbitems'+6+2+`nbdif'
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "item5_1" "item5_2" "item5_3" "item6_1" "item6_2" "item6_3" "item7_1" "item7_2" "item7_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
di "Scenario 14`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
@ -808,7 +808,7 @@ forvalues k=1/1000 {
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
`mod'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
@ -870,11 +870,11 @@ putexcel A1=matrix(outmat), colnames
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 4
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 2
|
|
|
|
|
local taillemat = `nbitems'+`nbdif'+4
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "dif1" "dif2" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "item5" "item6" "item7" "dif1" "dif2" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
di "Scenario 15`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
@ -944,11 +944,11 @@ import delim "`path_data'/scenario_16`scen'_`Nn'.csv", encoding(ISO-8859-2) cas
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 4
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 2
|
|
|
|
|
local taillemat = 3*`nbitems'+6+2+`nbdif'
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "item5_1" "item5_2" "item5_3" "item6_1" "item6_2" "item6_3" "item7_1" "item7_2" "item7_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "beta" "se_beta" "dif_item_1" "dif_item_2"
|
|
|
|
|
di "Scenario 16`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
@ -992,7 +992,7 @@ forvalues k=1/1000 {
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
`mod'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
@ -1038,3 +1038,472 @@ putexcel set "`path_res'/out/16`scen'_`Nn'.xls", sheet("outmat") replace
|
|
|
|
|
putexcel A1=matrix(outmat), colnames
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
***** Scenarios with DIF on 3 items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
** Scenario 17: J = 7 items / M = 2 modalities / DIF size 0.3 x3
|
|
|
|
|
local N = "100 200 300"
|
|
|
|
|
foreach Nnn in `N' {
|
|
|
|
|
local Nn = `Nnn'
|
|
|
|
|
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N`Nn'"
|
|
|
|
|
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N`Nn'"
|
|
|
|
|
local scenarios = "A B C D E F G"
|
|
|
|
|
foreach scen in `scenarios' {
|
|
|
|
|
clear
|
|
|
|
|
import delim "`path_data'/scenario_17`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 3
|
|
|
|
|
local taillemat = `nbitems'+`nbdif'+5
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "item5" "item6" "item7" "dif1" "dif2" "dif3" "beta" "se_beta" "dif_item_1" "dif_item_2" "dif_item_3"
|
|
|
|
|
di "Scenario 17`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
|
di "`k'/1000"
|
|
|
|
|
}
|
|
|
|
|
preserve
|
|
|
|
|
qui keep if replication==`k'
|
|
|
|
|
local difitems1=dif1
|
|
|
|
|
local difitems2=dif2
|
|
|
|
|
local difitems3=dif3
|
|
|
|
|
if (`difitems1' < `difitems2') {
|
|
|
|
|
local difitemsmin= `difitems1'
|
|
|
|
|
local difitemsmax= `difitems2'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmin= `difitems2'
|
|
|
|
|
local difitemsmax= `difitems1'
|
|
|
|
|
}
|
|
|
|
|
if (`difitems3' < `difitemsmin') {
|
|
|
|
|
local difitemsmid = `difitemsmin'
|
|
|
|
|
local difitemsmin= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else if (`difitems3' > `difitemsmax') {
|
|
|
|
|
local difitemsmid = `difitemsmax'
|
|
|
|
|
local difitemsmax= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmid = `difitems3'
|
|
|
|
|
}
|
|
|
|
|
local mod "gsem "
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin' | `i'==`difitemsmax' | `i'==`difitemsmid') {
|
|
|
|
|
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local mod = "`mod'"+"(1.item`i'<-THETA@1)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent"
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
|
if (`j'<`difitemsmin') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,3*`j'] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmid') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,1+3*`j'] // items après le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmax') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,2+3*`j'] // items après le deuxieme dif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,3+3*`j'] // items après le deuxieme dif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mat outmat[`k',`nbitems'+1] = W[1,3*`difitemsmin'-1] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+2] = W[1,3*`difitemsmid'] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+3] = W[1,3*`difitemsmax'+1] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+4] = W[1,3*`nbitems'+4] // beta
|
|
|
|
|
mat outmat[`k',`nbitems'+5] = W[2,3*`nbitems'+4] // se beta
|
|
|
|
|
mat outmat[`k',`nbitems'+6] = `difitemsmin' // numéro item de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+7] = `difitemsmid' // numéro item de dif
|
|
|
|
|
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 A1=matrix(outmat), colnames
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
** Scenario 18: J = 7 items / M = 4 modalities / DIF size 0.3 x3
|
|
|
|
|
local N = "100 200 300"
|
|
|
|
|
foreach Nnn in `N' {
|
|
|
|
|
local Nn = `Nnn'
|
|
|
|
|
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N`Nn'"
|
|
|
|
|
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N`Nn'"
|
|
|
|
|
local scenarios = "A B C D E F G"
|
|
|
|
|
foreach scen in `scenarios' {
|
|
|
|
|
clear
|
|
|
|
|
import delim "`path_data'/scenario_18`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 3
|
|
|
|
|
local taillemat = 3*`nbitems'+9+2+`nbdif'
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "item5_1" "item5_2" "item5_3" "item6_1" "item6_2" "item6_3" "item7_1" "item7_2" "item7_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "dif3_1" "dif3_2" "dif3_3" "beta" "se_beta" "dif_item_1" "dif_item_2" "dif_item_3"
|
|
|
|
|
di "Scenario 18`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
|
di "`k'/1000"
|
|
|
|
|
}
|
|
|
|
|
preserve
|
|
|
|
|
qui keep if replication==`k'
|
|
|
|
|
local difitems1=dif1
|
|
|
|
|
local difitems2=dif2
|
|
|
|
|
local difitems3=dif3
|
|
|
|
|
if (`difitems1' < `difitems2') {
|
|
|
|
|
local difitemsmin= `difitems1'
|
|
|
|
|
local difitemsmax= `difitems2'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmin= `difitems2'
|
|
|
|
|
local difitemsmax= `difitems1'
|
|
|
|
|
}
|
|
|
|
|
if (`difitems3' < `difitemsmin') {
|
|
|
|
|
local difitemsmid = `difitemsmin'
|
|
|
|
|
local difitemsmin= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else if (`difitems3' > `difitemsmax') {
|
|
|
|
|
local difitemsmid = `difitemsmax'
|
|
|
|
|
local difitemsmax= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmid = `difitems3'
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin') {
|
|
|
|
|
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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmax') {
|
|
|
|
|
local constrn3 = "constraint 3 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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmid') {
|
|
|
|
|
local constrn5 = "constraint 5 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 constrnt6 = "constraint 6 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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod "gsem "
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin' | `i'==`difitemsmax' | `i'==`difitemsmid') {
|
|
|
|
|
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)(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2)"
|
|
|
|
|
qui `constrnt'
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
qui `constrnt6'
|
|
|
|
|
qui `constrnt6'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
|
if (`j'<`difitemsmin') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+3] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+5] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+7] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmin') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+4] // items du le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+7] // items du le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+10] // items du le premier dif }
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmid') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+6] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+8] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmid') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+7] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmax') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+9] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+11] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmax') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+16] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+12] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+14] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+16] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mat outmat[`k',3*`nbitems'+1] = W[1,7*(`difitemsmin'-1)+2] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+2] = W[1,7*(`difitemsmin'-1)+5] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+3] = W[1,7*(`difitemsmin'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+4] = W[1,7*(`difitemsmid'-1)+5] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+5] = W[1,7*(`difitemsmid'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+6] = W[1,7*(`difitemsmid'-1)+11] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+7] = W[1,7*(`difitemsmax'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+8] = W[1,7*(`difitemsmax'-1)+11] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+9] = W[1,7*(`difitemsmax'-1)+14] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+10] = W[1,7*`nbitems'+10] // beta
|
|
|
|
|
mat outmat[`k',3*`nbitems'+11] = W[2,7*`nbitems'+10] // se beta
|
|
|
|
|
mat outmat[`k',3*`nbitems'+12] = `difitemsmin' // numéro item de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+13] = `difitemsmid' // numéro item de dif
|
|
|
|
|
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 A1=matrix(outmat), colnames
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
** Scenario 19: J = 7 items / M = 2 modalities / DIF size 0.5 x3
|
|
|
|
|
local N = "100 200 300"
|
|
|
|
|
foreach Nnn in `N' {
|
|
|
|
|
local Nn = `Nnn'
|
|
|
|
|
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N`Nn'"
|
|
|
|
|
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N`Nn'"
|
|
|
|
|
local scenarios = "A B C D E F G"
|
|
|
|
|
foreach scen in `scenarios' {
|
|
|
|
|
clear
|
|
|
|
|
import delim "`path_data'/scenario_19`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 3
|
|
|
|
|
local taillemat = `nbitems'+`nbdif'+5
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1" "item2" "item3" "item4" "item5" "item6" "item7" "dif1" "dif2" "dif3" "beta" "se_beta" "dif_item_1" "dif_item_2" "dif_item_3"
|
|
|
|
|
di "Scenario 19`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
|
di "`k'/1000"
|
|
|
|
|
}
|
|
|
|
|
preserve
|
|
|
|
|
qui keep if replication==`k'
|
|
|
|
|
local difitems1=dif1
|
|
|
|
|
local difitems2=dif2
|
|
|
|
|
local difitems3=dif3
|
|
|
|
|
if (`difitems1' < `difitems2') {
|
|
|
|
|
local difitemsmin= `difitems1'
|
|
|
|
|
local difitemsmax= `difitems2'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmin= `difitems2'
|
|
|
|
|
local difitemsmax= `difitems1'
|
|
|
|
|
}
|
|
|
|
|
if (`difitems3' < `difitemsmin') {
|
|
|
|
|
local difitemsmid = `difitemsmin'
|
|
|
|
|
local difitemsmin= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else if (`difitems3' > `difitemsmax') {
|
|
|
|
|
local difitemsmid = `difitemsmax'
|
|
|
|
|
local difitemsmax= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmid = `difitems3'
|
|
|
|
|
}
|
|
|
|
|
local mod "gsem "
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin' | `i'==`difitemsmax' | `i'==`difitemsmid') {
|
|
|
|
|
local mod = "`mod'"+"(1.item`i'<-THETA@1 tt)"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local mod = "`mod'"+"(1.item`i'<-THETA@1)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent"
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
|
if (`j'<`difitemsmin') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,3*`j'] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmid') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,1+3*`j'] // items après le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmax') {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,2+3*`j'] // items après le deuxieme dif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mat outmat[`k',`j'] = W[1,3+3*`j'] // items après le deuxieme dif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mat outmat[`k',`nbitems'+1] = W[1,3*`difitemsmin'-1] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+2] = W[1,3*`difitemsmid'] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+3] = W[1,3*`difitemsmax'+1] // coef de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+4] = W[1,3*`nbitems'+4] // beta
|
|
|
|
|
mat outmat[`k',`nbitems'+5] = W[2,3*`nbitems'+4] // se beta
|
|
|
|
|
mat outmat[`k',`nbitems'+6] = `difitemsmin' // numéro item de dif
|
|
|
|
|
mat outmat[`k',`nbitems'+7] = `difitemsmid' // numéro item de dif
|
|
|
|
|
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 A1=matrix(outmat), colnames
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
** Scenario 20: J = 7 items / M = 4 modalities / DIF size 0.5 x3
|
|
|
|
|
local N = "100 200 300"
|
|
|
|
|
foreach Nnn in `N' {
|
|
|
|
|
local Nn = `Nnn'
|
|
|
|
|
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N`Nn'"
|
|
|
|
|
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/DIF/N`Nn'"
|
|
|
|
|
local scenarios = "A B C D E F G"
|
|
|
|
|
foreach scen in `scenarios' {
|
|
|
|
|
clear
|
|
|
|
|
import delim "`path_data'/scenario_20`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
|
|
|
|
|
rename TT tt
|
|
|
|
|
|
|
|
|
|
* Matrice de taille 1000 * 4 items + 1 DIF + beta + std beta + 1 dif
|
|
|
|
|
local nbitems = 7
|
|
|
|
|
local nbdif = 3
|
|
|
|
|
local taillemat = 3*`nbitems'+9+2+`nbdif'
|
|
|
|
|
mat outmat = J(1000,`taillemat',.)
|
|
|
|
|
mat colnames outmat = "item1_1" "item1_2" "item1_3" "item2_1" "item2_2" "item2_3" "item3_1" "item3_2" "item3_3" "item4_1" "item4_2" "item4_3" "item5_1" "item5_2" "item5_3" "item6_1" "item6_2" "item6_3" "item7_1" "item7_2" "item7_3" "dif1_1" "dif1_2" "dif1_3" "dif2_1" "dif2_2" "dif2_3" "dif3_1" "dif3_2" "dif3_3" "beta" "se_beta" "dif_item_1" "dif_item_2" "dif_item_3"
|
|
|
|
|
di "Scenario 20`scen' / N=`Nnn'"
|
|
|
|
|
forvalues k=1/1000 {
|
|
|
|
|
if (mod(`k',100)==0) {
|
|
|
|
|
di "`k'/1000"
|
|
|
|
|
}
|
|
|
|
|
preserve
|
|
|
|
|
qui keep if replication==`k'
|
|
|
|
|
local difitems1=dif1
|
|
|
|
|
local difitems2=dif2
|
|
|
|
|
local difitems3=dif3
|
|
|
|
|
if (`difitems1' < `difitems2') {
|
|
|
|
|
local difitemsmin= `difitems1'
|
|
|
|
|
local difitemsmax= `difitems2'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmin= `difitems2'
|
|
|
|
|
local difitemsmax= `difitems1'
|
|
|
|
|
}
|
|
|
|
|
if (`difitems3' < `difitemsmin') {
|
|
|
|
|
local difitemsmid = `difitemsmin'
|
|
|
|
|
local difitemsmin= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else if (`difitems3' > `difitemsmax') {
|
|
|
|
|
local difitemsmid = `difitemsmax'
|
|
|
|
|
local difitemsmax= `difitems3'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
local difitemsmid = `difitems3'
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin') {
|
|
|
|
|
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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmax') {
|
|
|
|
|
local constrn3 = "constraint 3 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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmid') {
|
|
|
|
|
local constrn5 = "constraint 5 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 constrnt6 = "constraint 6 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))"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod "gsem "
|
|
|
|
|
forvalues i=1/`nbitems' {
|
|
|
|
|
if (`i'==`difitemsmin' | `i'==`difitemsmax' | `i'==`difitemsmid') {
|
|
|
|
|
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)(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(1 2)"
|
|
|
|
|
qui `constrnt'
|
|
|
|
|
qui `constrnt2'
|
|
|
|
|
qui `constrnt3'
|
|
|
|
|
qui `constrnt4'
|
|
|
|
|
qui `constrnt6'
|
|
|
|
|
qui `constrnt6'
|
|
|
|
|
qui `mod'
|
|
|
|
|
mat V=r(table)
|
|
|
|
|
mat W=V[1..2,1...]
|
|
|
|
|
forvalues j=1/`nbitems' {
|
|
|
|
|
if (`j'<`difitemsmin') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+3] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+5] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+7] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmin') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+4] // items du le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+7] // items du le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+10] // items du le premier dif }
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmid') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+6] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+8] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmid') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+7] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'<`difitemsmax') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+9] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+11] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else if (`j'==`difitemsmax') {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+10] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+13] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+16] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mat outmat[`k',3*`j'-2] = W[1,7*(`j'-1)+12] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'-1] = W[1,7*(`j'-1)+14] // items avant le premier dif
|
|
|
|
|
mat outmat[`k',3*`j'] = W[1,7*(`j'-1)+16] // items avant le premier dif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mat outmat[`k',3*`nbitems'+1] = W[1,7*(`difitemsmin'-1)+2] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+2] = W[1,7*(`difitemsmin'-1)+5] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+3] = W[1,7*(`difitemsmin'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+4] = W[1,7*(`difitemsmid'-1)+5] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+5] = W[1,7*(`difitemsmid'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+6] = W[1,7*(`difitemsmid'-1)+11] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+7] = W[1,7*(`difitemsmax'-1)+8] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+8] = W[1,7*(`difitemsmax'-1)+11] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+9] = W[1,7*(`difitemsmax'-1)+14] // coef de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+10] = W[1,7*`nbitems'+10] // beta
|
|
|
|
|
mat outmat[`k',3*`nbitems'+11] = W[2,7*`nbitems'+10] // se beta
|
|
|
|
|
mat outmat[`k',3*`nbitems'+12] = `difitemsmin' // numéro item de dif
|
|
|
|
|
mat outmat[`k',3*`nbitems'+13] = `difitemsmid' // numéro item de dif
|
|
|
|
|
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 A1=matrix(outmat), colnames
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|