*=================================================================================================================================================
* Date : 2024-01-04
* Stata version : Stata 18 SE
*
* This program creates dataset with DIF for a randomized controlled trial scenario.
* 4 items
*
* ado-files needed : - simirt (version 4.3 August 29, 2019, available on OSF)
*
  * outputs : scenario_5,scenario_6,scenario_7,scenario_8,scenario_9,scenario_10,scenario_11,scenario_12 for N=300
*
*
* Warning : To obtain reproduce the data obtained in the .csv files in this repository, use 'simirt_setseed.ado' instead of 'simirt.ado'
*
*================================================================================================================================================

* Load simirt.ado
adopath+"/home/corentin/Documents/These/Recherche/Simulations/Modules/"

* Set data output folder path

local path = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N300"
local Nn = 300

*==========================
* Scenarios with : J=4
*==========================

************** Scenarios with : DIF on 1 item **************

**** Scenarios with : DIF size 0.3 ****

** Scenario 5: J = 4 items / M = 2 modalities / DIF SIZE = 0.3

* Scenario 5A : H_0 is TRUE / DIF on treatment

di "Scenario 5A - N=300"

forvalues replication = 1/1000 {
  	if mod(`replication',100)==0 {
  	di "replication = `replication'"
    }
    qui local difi = runiformint(1,4)

		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace

    mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    if `difi'==1 {
		mat E= (0.3 \ 0 \ 0 \ 0)
    }
    if `difi'==2 {
    mat E= (0 \ 0.3 \ 0 \ 0)
    }
    if `difi'==3 {
    mat E= (0 \ 0 \ 0.3 \ 0)
    }
    if `difi'==4 {
    mat E= (0 \ 0 \ 0 \ 0.3)
    }
    mat D=B-E
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_5A_300.csv", replace


  * Scenario 5B : H_1 is TRUE / Effect size 0.2 / DIF on treatment

  di "Scenario 5B - N=300"

  forvalues replication = 1/1000 {
    	if mod(`replication',100)==0 {
    	di "replication = `replication'"
      }
      qui local difi = runiformint(1,4)

  		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
      if `difi'==1 {
  		mat E= (0.3 \ 0 \ 0 \ 0)
      }
      if `difi'==2 {
      mat E= (0 \ 0.3 \ 0 \ 0)
      }
      if `difi'==3 {
      mat E= (0 \ 0 \ 0.3 \ 0)
      }
      if `difi'==4 {
      mat E= (0 \ 0 \ 0 \ 0.3)
      }
      mat D=B+E
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_5B_300.csv", replace

* Scenario 5C : H_1 is TRUE / Effect size 0.2 / DIF negative

    di "Scenario 5C - N=300"

    forvalues replication = 1/1000 {
      	if mod(`replication',100)==0 {
      	di "replication = `replication'"
        }
        qui local difi = runiformint(1,4)

        mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        if `difi'==1 {
        mat E= (0.3 \ 0 \ 0 \ 0)
        }
        if `difi'==2 {
        mat E= (0 \ 0.3 \ 0 \ 0)
        }
        if `difi'==3 {
        mat E= (0 \ 0 \ 0.3 \ 0)
        }
        if `difi'==4 {
        mat E= (0 \ 0 \ 0 \ 0.3)
        }
        mat D=B-E
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_5C_300.csv", replace


* Scenario 5D : H_1 is TRUE / Effect size 0.4 / DIF on treatment

        di "Scenario 5D - N=300"

        forvalues replication = 1/1000 {
          	if mod(`replication',100)==0 {
          	di "replication = `replication'"
            }
            qui local difi = runiformint(1,4)

        		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
            if `difi'==1 {
        		mat E= (0.3 \ 0 \ 0 \ 0)
            }
            if `difi'==2 {
            mat E= (0 \ 0.3 \ 0 \ 0)
            }
            if `difi'==3 {
            mat E= (0 \ 0 \ 0.3 \ 0)
            }
            if `difi'==4 {
            mat E= (0 \ 0 \ 0 \ 0.3)
            }
            mat D=B+E
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_5D_300.csv", replace

* Scenario 5E : H_1 is TRUE / Effect size 0.4 / DIF negative

          di "Scenario 5E - N=300"

          forvalues replication = 1/1000 {
            	if mod(`replication',100)==0 {
            	di "replication = `replication'"
              }
              qui local difi = runiformint(1,4)

              mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
              if `difi'==1 {
              mat E= (0.3 \ 0 \ 0 \ 0)
              }
              if `difi'==2 {
              mat E= (0 \ 0.3 \ 0 \ 0)
              }
              if `difi'==3 {
              mat E= (0 \ 0 \ 0.3 \ 0)
              }
              if `difi'==4 {
              mat E= (0 \ 0 \ 0 \ 0.3)
              }
              mat D=B-E
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_5E_300.csv", replace

* Scenario 5F : H_1 is TRUE / Effect size -0.2 / DIF negative

                      di "Scenario 5F - N=300"

                      forvalues replication = 1/1000 {
                        	if mod(`replication',100)==0 {
                        	di "replication = `replication'"
                          }
                          qui local difi = runiformint(1,4)

                          mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                          if `difi'==1 {
                          mat E= (0.3 \ 0 \ 0 \ 0)
                          }
                          if `difi'==2 {
                          mat E= (0 \ 0.3 \ 0 \ 0)
                          }
                          if `difi'==3 {
                          mat E= (0 \ 0 \ 0.3 \ 0)
                          }
                          if `difi'==4 {
                          mat E= (0 \ 0 \ 0 \ 0.3)
                          }
                          mat D=B-E
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_5F_300.csv", replace




* Scenario 5G : H_1 is TRUE / Effect size -0.4 / DIF negative

                                  di "Scenario 5G - N=300"

                                  forvalues replication = 1/1000 {
                                    	if mod(`replication',100)==0 {
                                    	di "replication = `replication'"
                                      }
                                      qui local difi = runiformint(1,4)

                                      mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                      if `difi'==1 {
                                      mat E= (0.3 \ 0 \ 0 \ 0)
                                      }
                                      if `difi'==2 {
                                      mat E= (0 \ 0.3 \ 0 \ 0)
                                      }
                                      if `difi'==3 {
                                      mat E= (0 \ 0 \ 0.3 \ 0)
                                      }
                                      if `difi'==4 {
                                      mat E= (0 \ 0 \ 0 \ 0.3)
                                      }
                                      mat D=B-E
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_5G_300.csv", replace








** Scenario 6: J = 4 items / M = 4 modalities / DIF SIZE = 0.3

* Scenario 6A : H_0 is TRUE / DIF on treatment

di "Scenario 6A - N=300"

forvalues replication = 1/1000 {
  	if mod(`replication',100)==0 {
  	di "replication = `replication'"
    }
    qui local difi = runiformint(1,4)

    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace

    mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    if `difi'==1 {
      mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==2 {
      mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==3 {
      mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
    }
    if `difi'==4 {
      mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
    }
    mat D=B-E
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_6A_300.csv", replace

* Scenario 6B : H_1 is TRUE / Effect size 0.2 / DIF on treatment

  di "Scenario 6B - N=300"

  forvalues replication = 1/1000 {
    	if mod(`replication',100)==0 {
    	di "replication = `replication'"
      }
      qui local difi = runiformint(1,4)

      mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      if `difi'==1 {
        mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==2 {
        mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==3 {
        mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
      }
      if `difi'==4 {
        mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
      }
      mat D=B+E
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_6B_300.csv", replace

* Scenario 6C : H_1 is TRUE / Effect size 0.2 / DIF negative

      di "Scenario 6C - N=300"

      forvalues replication = 1/1000 {
        	if mod(`replication',100)==0 {
        	di "replication = `replication'"
          }
          qui local difi = runiformint(1,4)

          mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
          qui gen TT = 0
      		tempfile grp0
      		qui save `grp0',replace


          mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          if `difi'==1 {
            mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
          }
          if `difi'==2 {
            mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
          }
          if `difi'==3 {
            mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
          }
          if `difi'==4 {
            mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
          }
          mat D=B-E
      		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
          qui gen TT = 1
      		tempfile grp1
      		qui save `grp1',replace


      		clear
      		use `grp0'
          qui append using `grp1'
      		drop id
          qui gen dif1 = `difi'
      		qui gen id = _n
      		order(id)
      		qui gen replication = `replication'
      		if `replication'==1{
      			tempfile data
      			qui save `data'
      		}
      		else{
      			qui append using `data'
      			qui save `data',replace
      		}
      	}
      	export delimited using "`path'/scenario_6C_300.csv", replace

* Scenario 6D : H_1 is TRUE / Effect size 0.4 / DIF on treatment

          di "Scenario 6D - N=300"

          forvalues replication = 1/1000 {
            	if mod(`replication',100)==0 {
            	di "replication = `replication'"
              }
              qui local difi = runiformint(1,4)

              mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              if `difi'==1 {
                mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==2 {
                mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==3 {
                mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
              }
              if `difi'==4 {
                mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
              }
              mat D=B+E
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_6D_300.csv", replace

* Scenario 6E : H_1 is TRUE / Effect size 0.4 / DIF negative

              di "Scenario 6E - N=300"

              forvalues replication = 1/1000 {
                	if mod(`replication',100)==0 {
                	di "replication = `replication'"
                  }
                  qui local difi = runiformint(1,4)

                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                  qui gen TT = 0
              		tempfile grp0
              		qui save `grp0',replace


                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                  if `difi'==1 {
                    mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                  }
                  if `difi'==2 {
                    mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                  }
                  if `difi'==3 {
                    mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                  }
                  if `difi'==4 {
                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                  }
                  mat D=B-E
              		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
                  qui gen TT = 1
              		tempfile grp1
              		qui save `grp1',replace


              		clear
              		use `grp0'
                  qui append using `grp1'
              		drop id
                  qui gen dif1 = `difi'
              		qui gen id = _n
              		order(id)
              		qui gen replication = `replication'
              		if `replication'==1{
              			tempfile data
              			qui save `data'
              		}
              		else{
              			qui append using `data'
              			qui save `data',replace
              		}
              	}
              	export delimited using "`path'/scenario_6E_300.csv", replace


* Scenario 6F : H_1 is TRUE / Effect size -0.2 / DIF negative

di "Scenario 6E - N=300"

                              forvalues replication = 1/1000 {
                                	if mod(`replication',100)==0 {
                                	di "replication = `replication'"
                                  }
                                  qui local difi = runiformint(1,4)

                                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                  qui gen TT = 0
                              		tempfile grp0
                              		qui save `grp0',replace


                                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                  if `difi'==1 {
                                    mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                  }
                                  if `difi'==2 {
                                    mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                                  }
                                  if `difi'==3 {
                                    mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                                  }
                                  if `difi'==4 {
                                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                                  }
                                  mat D=B-E
                              		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                                  qui gen TT = 1
                              		tempfile grp1
                              		qui save `grp1',replace


                              		clear
                              		use `grp0'
                                  qui append using `grp1'
                              		drop id
                                  qui gen dif1 = `difi'
                              		qui gen id = _n
                              		order(id)
                              		qui gen replication = `replication'
                              		if `replication'==1{
                              			tempfile data
                              			qui save `data'
                              		}
                              		else{
                              			qui append using `data'
                              			qui save `data',replace
                              		}
                              	}
                              	export delimited using "`path'/scenario_6F_300.csv", replace


* Scenario 6G : H_1 is TRUE / Effect size -0.4 / DIF negative

di "Scenario 6G - N=300"

                                              forvalues replication = 1/1000 {
                                                	if mod(`replication',100)==0 {
                                                	di "replication = `replication'"
                                                  }
                                                  qui local difi = runiformint(1,4)

                                                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                                  qui gen TT = 0
                                              		tempfile grp0
                                              		qui save `grp0',replace


                                                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                                  if `difi'==1 {
                                                    mat E= (0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                                  }
                                                  if `difi'==2 {
                                                    mat E= (0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                                                  }
                                                  if `difi'==3 {
                                                    mat E= (0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                                                  }
                                                  if `difi'==4 {
                                                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                                                  }
                                                  mat D=B-E
                                              		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                                  qui gen TT = 1
                                              		tempfile grp1
                                              		qui save `grp1',replace


                                              		clear
                                              		use `grp0'
                                                  qui append using `grp1'
                                              		drop id
                                                  qui gen dif1 = `difi'
                                              		qui gen id = _n
                                              		order(id)
                                              		qui gen replication = `replication'
                                              		if `replication'==1{
                                              			tempfile data
                                              			qui save `data'
                                              		}
                                              		else{
                                              			qui append using `data'
                                              			qui save `data',replace
                                              		}
                                              	}
                                              	export delimited using "`path'/scenario_6G_300.csv", replace



**** ---------------------------------------------------------------------------------------------------------------------------------- ****




**** Scenarios with : DIF size 0.5 ****

** Scenario 7: J = 4 items / M = 2 modalities / DIF SIZE = 0.5

* Scenario 7A : H_0 is TRUE / DIF on treatment

di "Scenario 7A - N=300"

forvalues replication = 1/1000 {
  	if mod(`replication',100)==0 {
  	di "replication = `replication'"
    }
    qui local difi = runiformint(1,4)

		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    if `difi'==1 {
		mat E= (0.5 \ 0 \ 0 \ 0)
    }
    if `difi'==2 {
    mat E= (0 \ 0.5 \ 0 \ 0)
    }
    if `difi'==3 {
    mat E= (0 \ 0 \ 0.5 \ 0)
    }
    if `difi'==4 {
    mat E= (0 \ 0 \ 0 \ 0.5)
    }
    mat D=B-E
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_7A_300.csv", replace


  * Scenario 7B : H_1 is TRUE / Effect size 0.2 / DIF on treatment

  di "Scenario 7B - N=300"

  forvalues replication = 1/1000 {
    	if mod(`replication',100)==0 {
    	di "replication = `replication'"
      }
      qui local difi = runiformint(1,4)

  		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
      if `difi'==1 {
  		mat E= (0.5 \ 0 \ 0 \ 0)
      }
      if `difi'==2 {
      mat E= (0 \ 0.5 \ 0 \ 0)
      }
      if `difi'==3 {
      mat E= (0 \ 0 \ 0.5 \ 0)
      }
      if `difi'==4 {
      mat E= (0 \ 0 \ 0 \ 0.5)
      }
      mat D=B+E
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_7B_300.csv", replace

* Scenario 7C : H_1 is TRUE / Effect size 0.2 / DIF negative

    di "Scenario 7C - N=300"

    forvalues replication = 1/1000 {
      	if mod(`replication',100)==0 {
      	di "replication = `replication'"
        }
        qui local difi = runiformint(1,4)

        mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        if `difi'==1 {
        mat E= (0.5 \ 0 \ 0 \ 0)
        }
        if `difi'==2 {
        mat E= (0 \ 0.5 \ 0 \ 0)
        }
        if `difi'==3 {
        mat E= (0 \ 0 \ 0.5 \ 0)
        }
        if `difi'==4 {
        mat E= (0 \ 0 \ 0 \ 0.5)
        }
        mat D=B-E
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_7C_300.csv", replace


* Scenario 7D : H_1 is TRUE / Effect size 0.4 / DIF on treatment

        di "Scenario 7D - N=300"

        forvalues replication = 1/1000 {
          	if mod(`replication',100)==0 {
          	di "replication = `replication'"
            }
            qui local difi = runiformint(1,4)

        		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
            if `difi'==1 {
        		mat E= (0.5 \ 0 \ 0 \ 0)
            }
            if `difi'==2 {
            mat E= (0 \ 0.5 \ 0 \ 0)
            }
            if `difi'==3 {
            mat E= (0 \ 0 \ 0.5 \ 0)
            }
            if `difi'==4 {
            mat E= (0 \ 0 \ 0 \ 0.5)
            }
            mat D=B+E
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_7D_300.csv", replace

* Scenario 7E : H_1 is TRUE / Effect size 0.4 / DIF negative

          di "Scenario 7E - N=300"

          forvalues replication = 1/1000 {
            	if mod(`replication',100)==0 {
            	di "replication = `replication'"
              }
              qui local difi = runiformint(1,4)

              mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
              if `difi'==1 {
              mat E= (0.5 \ 0 \ 0 \ 0)
              }
              if `difi'==2 {
              mat E= (0 \ 0.5 \ 0 \ 0)
              }
              if `difi'==3 {
              mat E= (0 \ 0 \ 0.5 \ 0)
              }
              if `difi'==4 {
              mat E= (0 \ 0 \ 0 \ 0.5)
              }
              mat D=B-E
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_7E_300.csv", replace

* Scenario 7F : H_1 is TRUE / Effect size -0.2 / DIF negative

di "Scenario 7F - N=300"

                      forvalues replication = 1/1000 {
                        	if mod(`replication',100)==0 {
                        	di "replication = `replication'"
                          }
                          qui local difi = runiformint(1,4)

                          mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                          if `difi'==1 {
                          mat E= (0.5 \ 0 \ 0 \ 0)
                          }
                          if `difi'==2 {
                          mat E= (0 \ 0.5 \ 0 \ 0)
                          }
                          if `difi'==3 {
                          mat E= (0 \ 0 \ 0.5 \ 0)
                          }
                          if `difi'==4 {
                          mat E= (0 \ 0 \ 0 \ 0.5)
                          }
                          mat D=B-E
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_7F_300.csv", replace

* Scenario 7G : H_1 is TRUE / Effect size -0.4 / DIF negative

di "Scenario 7G - N=300"

                                  forvalues replication = 1/1000 {
                                    	if mod(`replication',100)==0 {
                                    	di "replication = `replication'"
                                      }
                                      qui local difi = runiformint(1,4)

                                      mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                      if `difi'==1 {
                                      mat E= (0.5 \ 0 \ 0 \ 0)
                                      }
                                      if `difi'==2 {
                                      mat E= (0 \ 0.5 \ 0 \ 0)
                                      }
                                      if `difi'==3 {
                                      mat E= (0 \ 0 \ 0.5 \ 0)
                                      }
                                      if `difi'==4 {
                                      mat E= (0 \ 0 \ 0 \ 0.5)
                                      }
                                      mat D=B-E
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_7G_300.csv", replace











** Scenario 8: J = 4 items / M = 4 modalities / DIF SIZE = 0.5

* Scenario 8A : H_0 is TRUE / DIF on treatment

di "Scenario 8A - N=300"

forvalues replication = 1/1000 {
  	if mod(`replication',100)==0 {
  	di "replication = `replication'"
    }
    qui local difi = runiformint(1,4)

    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    if `difi'==1 {
      mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==2 {
      mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==3 {
      mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
    }
    if `difi'==4 {
      mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
    }
    mat D=B-E
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_8A_300.csv", replace

* Scenario 8B : H_1 is TRUE / Effect size 0.2 / DIF on treatment

  di "Scenario 8B - N=300"

  forvalues replication = 1/1000 {
    	if mod(`replication',100)==0 {
    	di "replication = `replication'"
      }
      qui local difi = runiformint(1,4)

      mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      if `difi'==1 {
        mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==2 {
        mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==3 {
        mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
      }
      if `difi'==4 {
        mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
      }
      mat D=B+E
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_8B_300.csv", replace

* Scenario 8C : H_1 is TRUE / Effect size 0.2 / DIF negative

      di "Scenario 8C - N=300"

      forvalues replication = 1/1000 {
        	if mod(`replication',100)==0 {
        	di "replication = `replication'"
          }
          qui local difi = runiformint(1,4)

          mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
          qui gen TT = 0
      		tempfile grp0
      		qui save `grp0',replace


          mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          if `difi'==1 {
            mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
          }
          if `difi'==2 {
            mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
          }
          if `difi'==3 {
            mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
          }
          if `difi'==4 {
            mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
          }
          mat D=B-E
      		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
          qui gen TT = 1
      		tempfile grp1
      		qui save `grp1',replace


      		clear
      		use `grp0'
          qui append using `grp1'
      		drop id
          qui gen dif1 = `difi'
      		qui gen id = _n
      		order(id)
      		qui gen replication = `replication'
      		if `replication'==1{
      			tempfile data
      			qui save `data'
      		}
      		else{
      			qui append using `data'
      			qui save `data',replace
      		}
      	}
      	export delimited using "`path'/scenario_8C_300.csv", replace

* Scenario 8D : H_1 is TRUE / Effect size 0.4 / DIF on treatment

          di "Scenario 8D - N=300"

          forvalues replication = 1/1000 {
            	if mod(`replication',100)==0 {
            	di "replication = `replication'"
              }
              qui local difi = runiformint(1,4)

              mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              if `difi'==1 {
                mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==2 {
                mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==3 {
                mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
              }
              if `difi'==4 {
                mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
              }
              mat D=B+E
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_8D_300.csv", replace

* Scenario 8E : H_1 is TRUE / Effect size 0.4 / DIF negative

              di "Scenario 8E - N=300"

              forvalues replication = 1/1000 {
                	if mod(`replication',100)==0 {
                	di "replication = `replication'"
                  }
                  qui local difi = runiformint(1,4)

                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                  qui gen TT = 0
              		tempfile grp0
              		qui save `grp0',replace


                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                  if `difi'==1 {
                    mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                  }
                  if `difi'==2 {
                    mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                  }
                  if `difi'==3 {
                    mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                  }
                  if `difi'==4 {
                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                  }
                  mat D=B-E
              		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
                  qui gen TT = 1
              		tempfile grp1
              		qui save `grp1',replace


              		clear
              		use `grp0'
                  qui append using `grp1'
              		drop id
                  qui gen dif1 = `difi'
              		qui gen id = _n
              		order(id)
              		qui gen replication = `replication'
              		if `replication'==1{
              			tempfile data
              			qui save `data'
              		}
              		else{
              			qui append using `data'
              			qui save `data',replace
              		}
              	}
              	export delimited using "`path'/scenario_8E_300.csv", replace


* Scenario 8F : H_1 is TRUE / Effect size -0.2 / DIF negative

di "Scenario 8F - N=300"

                              forvalues replication = 1/1000 {
                                	if mod(`replication',100)==0 {
                                	di "replication = `replication'"
                                  }
                                  qui local difi = runiformint(1,4)

                                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                  qui gen TT = 0
                              		tempfile grp0
                              		qui save `grp0',replace


                                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                  if `difi'==1 {
                                    mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                  }
                                  if `difi'==2 {
                                    mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                                  }
                                  if `difi'==3 {
                                    mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                                  }
                                  if `difi'==4 {
                                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                                  }
                                  mat D=B-E
                              		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                                  qui gen TT = 1
                              		tempfile grp1
                              		qui save `grp1',replace


                              		clear
                              		use `grp0'
                                  qui append using `grp1'
                              		drop id
                                  qui gen dif1 = `difi'
                              		qui gen id = _n
                              		order(id)
                              		qui gen replication = `replication'
                              		if `replication'==1{
                              			tempfile data
                              			qui save `data'
                              		}
                              		else{
                              			qui append using `data'
                              			qui save `data',replace
                              		}
                              	}
                              	export delimited using "`path'/scenario_8F_300.csv", replace


* Scenario 8G : H_1 is TRUE / Effect size -0.4 / DIF negative

di "Scenario 8G - N=300"

                                              forvalues replication = 1/1000 {
                                                	if mod(`replication',100)==0 {
                                                	di "replication = `replication'"
                                                  }
                                                  qui local difi = runiformint(1,4)

                                                  mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                              		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                                  qui gen TT = 0
                                              		tempfile grp0
                                              		qui save `grp0',replace


                                                  mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                                  if `difi'==1 {
                                                    mat E= (0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                                  }
                                                  if `difi'==2 {
                                                    mat E= (0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                                                  }
                                                  if `difi'==3 {
                                                    mat E= (0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                                                  }
                                                  if `difi'==4 {
                                                    mat E= (0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                                                  }
                                                  mat D=B-E
                                              		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                                  qui gen TT = 1
                                              		tempfile grp1
                                              		qui save `grp1',replace


                                              		clear
                                              		use `grp0'
                                                  qui append using `grp1'
                                              		drop id
                                                  qui gen dif1 = `difi'
                                              		qui gen id = _n
                                              		order(id)
                                              		qui gen replication = `replication'
                                              		if `replication'==1{
                                              			tempfile data
                                              			qui save `data'
                                              		}
                                              		else{
                                              			qui append using `data'
                                              			qui save `data',replace
                                              		}
                                              	}
                                              	export delimited using "`path'/scenario_8G_300.csv", replace










************** Scenarios with : DIF on 2 items **************

**** Scenarios with : DIF size 0.3 ****

** Scenario 9: J = 4 items / M = 2 modalities / DIF SIZE = 0.3

* Scenario 9A : H_0 is TRUE / DIF on treatment x 2

di "Scenario 9A - N=300"

forvalues replication = 1/1000 {
  clear
  if mod(`replication',100)==0 {
  di "replication = `replication'"
  }
  qui set obs 4
  qui gen xxx = _n
  qui sample 2 ,count
  qui valuesof xxx
  qui local ItemsDIF = r(values)
  qui local difi :  word 1 of `ItemsDIF'
  qui local difj :  word 2 of `ItemsDIF'

		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    if `difi'==1 {
      mat E=(0.3 \ 0 \ 0 \ 0)
    }
    if `difi'==2 {
      mat E=(0 \ 0.3 \ 0 \ 0)
    }
    if `difi'==3 {
      mat E=(0 \ 0 \ 0.3 \ 0)
    }
    if `difi'==4 {
      mat E=(0 \ 0 \ 0 \ 0.3)
    }
    if `difj'==1 {
      mat F=(0.3 \ 0 \ 0 \ 0)
    }
    if `difj'==2 {
      mat F=(0 \ 0.3 \ 0 \ 0)
    }
    if `difj'==3 {
      mat F=(0 \ 0 \ 0.3 \ 0)
    }
    if `difj'==4 {
      mat F=(0 \ 0 \ 0 \ 0.3)
    }
    mat D=B-E-F
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
    qui gen dif2 = `difj'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_9A_300.csv", replace


  * Scenario 9B : H_1 is TRUE / Effect size 0.2 / DIF on treatment x2

  di "Scenario 9B - N=300"

  forvalues replication = 1/1000 {
    clear
    if mod(`replication',100)==0 {
    di "replication = `replication'"
    }
    qui set obs 4
    qui gen xxx = _n
    qui sample 2 ,count
    qui valuesof xxx
    qui local ItemsDIF = r(values)
    qui local difi :  word 1 of `ItemsDIF'
    qui local difj :  word 2 of `ItemsDIF'

  		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
      if `difi'==1 {
        mat E=(0.3 \ 0 \ 0 \ 0)
      }
      if `difi'==2 {
        mat E=(0 \ 0.3 \ 0 \ 0)
      }
      if `difi'==3 {
        mat E=(0 \ 0 \ 0.3 \ 0)
      }
      if `difi'==4 {
        mat E=(0 \ 0 \ 0 \ 0.3)
      }
      if `difj'==1 {
        mat F=(0.3 \ 0 \ 0 \ 0)
      }
      if `difj'==2 {
        mat F=(0 \ 0.3 \ 0 \ 0)
      }
      if `difj'==3 {
        mat F=(0 \ 0 \ 0.3 \ 0)
      }
      if `difj'==4 {
        mat F=(0 \ 0 \ 0 \ 0.3)
      }
      mat D=B+E+F
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
      qui gen dif2 = `difj'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_9B_300.csv", replace

* Scenario 9C : H_1 is TRUE / Effect size 0.2 / DIF negative x2

    di "Scenario 9C - N=300"

    forvalues replication = 1/1000 {
      clear
      if mod(`replication',100)==0 {
      di "replication = `replication'"
      }
      qui set obs 4
      qui gen xxx = _n
      qui sample 2 ,count
      qui valuesof xxx
      qui local ItemsDIF = r(values)
      qui local difi :  word 1 of `ItemsDIF'
      qui local difj :  word 2 of `ItemsDIF'

      mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        if `difi'==1 {
          mat E=(0.3 \ 0 \ 0 \ 0)
        }
        if `difi'==2 {
          mat E=(0 \ 0.3 \ 0 \ 0)
        }
        if `difi'==3 {
          mat E=(0 \ 0 \ 0.3 \ 0)
        }
        if `difi'==4 {
          mat E=(0 \ 0 \ 0 \ 0.3)
        }
        if `difj'==1 {
          mat F=(0.3 \ 0 \ 0 \ 0)
        }
        if `difj'==2 {
          mat F=(0 \ 0.3 \ 0 \ 0)
        }
        if `difj'==3 {
          mat F=(0 \ 0 \ 0.3 \ 0)
        }
        if `difj'==4 {
          mat F=(0 \ 0 \ 0 \ 0.3)
        }
        mat D=B-E-F
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
        qui gen dif2 = `difj'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_9C_300.csv", replace


* Scenario 9D : H_1 is TRUE / Effect size 0.4 / DIF on treatment x2

        di "Scenario 9D - N=300"

        forvalues replication = 1/1000 {
          clear
          if mod(`replication',100)==0 {
          di "replication = `replication'"
          }
          qui set obs 4
          qui gen xxx = _n
          qui sample 2 ,count
          qui valuesof xxx
          qui local ItemsDIF = r(values)
          qui local difi :  word 1 of `ItemsDIF'
          qui local difj :  word 2 of `ItemsDIF'

        		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
            if `difi'==1 {
              mat E=(0.3 \ 0 \ 0 \ 0)
            }
            if `difi'==2 {
              mat E=(0 \ 0.3 \ 0 \ 0)
            }
            if `difi'==3 {
              mat E=(0 \ 0 \ 0.3 \ 0)
            }
            if `difi'==4 {
              mat E=(0 \ 0 \ 0 \ 0.3)
            }
            if `difj'==1 {
              mat F=(0.3 \ 0 \ 0 \ 0)
            }
            if `difj'==2 {
              mat F=(0 \ 0.3 \ 0 \ 0)
            }
            if `difj'==3 {
              mat F=(0 \ 0 \ 0.3 \ 0)
            }
            if `difj'==4 {
              mat F=(0 \ 0 \ 0 \ 0.3)
            }
            mat D=B+E+F
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
            qui gen dif2 = `difj'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_9D_300.csv", replace

* Scenario 9E : H_1 is TRUE / Effect size 0.4 / DIF negative x2

          di "Scenario 9E - N=300"

          forvalues replication = 1/1000 {
            clear
            if mod(`replication',100)==0 {
            di "replication = `replication'"
            }
            qui set obs 4
            qui gen xxx = _n
            qui sample 2 ,count
            qui valuesof xxx
            qui local ItemsDIF = r(values)
            qui local difi :  word 1 of `ItemsDIF'
            qui local difj :  word 2 of `ItemsDIF'

            mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
              if `difi'==1 {
                mat E=(0.3 \ 0 \ 0 \ 0)
              }
              if `difi'==2 {
                mat E=(0 \ 0.3 \ 0 \ 0)
              }
              if `difi'==3 {
                mat E=(0 \ 0 \ 0.3 \ 0)
              }
              if `difi'==4 {
                mat E=(0 \ 0 \ 0 \ 0.3)
              }
              if `difj'==1 {
                mat F=(0.3 \ 0 \ 0 \ 0)
              }
              if `difj'==2 {
                mat F=(0 \ 0.3 \ 0 \ 0)
              }
              if `difj'==3 {
                mat F=(0 \ 0 \ 0.3 \ 0)
              }
              if `difj'==4 {
                mat F=(0 \ 0 \ 0 \ 0.3)
              }
              mat D=B-E-F
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
              qui gen dif2 = `difj'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_9E_300.csv", replace



* Scenario 9F : H_1 is TRUE / Effect size -0.2 / DIF negative x2

                      di "Scenario 9F - N=300"

                      forvalues replication = 1/1000 {
                        clear
                        if mod(`replication',100)==0 {
                        di "replication = `replication'"
                        }
                        qui set obs 4
                        qui gen xxx = _n
                        qui sample 2 ,count
                        qui valuesof xxx
                        qui local ItemsDIF = r(values)
                        qui local difi :  word 1 of `ItemsDIF'
                        qui local difj :  word 2 of `ItemsDIF'

                        mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                          if `difi'==1 {
                            mat E=(0.3 \ 0 \ 0 \ 0)
                          }
                          if `difi'==2 {
                            mat E=(0 \ 0.3 \ 0 \ 0)
                          }
                          if `difi'==3 {
                            mat E=(0 \ 0 \ 0.3 \ 0)
                          }
                          if `difi'==4 {
                            mat E=(0 \ 0 \ 0 \ 0.3)
                          }
                          if `difj'==1 {
                            mat F=(0.3 \ 0 \ 0 \ 0)
                          }
                          if `difj'==2 {
                            mat F=(0 \ 0.3 \ 0 \ 0)
                          }
                          if `difj'==3 {
                            mat F=(0 \ 0 \ 0.3 \ 0)
                          }
                          if `difj'==4 {
                            mat F=(0 \ 0 \ 0 \ 0.3)
                          }
                          mat D=B-E-F
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                          qui gen dif2 = `difj'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_9F_300.csv", replace


* Scenario 9G : H_1 is TRUE / Effect size -0.4 / DIF negative x2

di "Scenario 9G - N=300"

                                  forvalues replication = 1/1000 {
                                    clear
                                    if mod(`replication',100)==0 {
                                    di "replication = `replication'"
                                    }
                                    qui set obs 4
                                    qui gen xxx = _n
                                    qui sample 2 ,count
                                    qui valuesof xxx
                                    qui local ItemsDIF = r(values)
                                    qui local difi :  word 1 of `ItemsDIF'
                                    qui local difj :  word 2 of `ItemsDIF'

                                    mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                      if `difi'==1 {
                                        mat E=(0.3 \ 0 \ 0 \ 0)
                                      }
                                      if `difi'==2 {
                                        mat E=(0 \ 0.3 \ 0 \ 0)
                                      }
                                      if `difi'==3 {
                                        mat E=(0 \ 0 \ 0.3 \ 0)
                                      }
                                      if `difi'==4 {
                                        mat E=(0 \ 0 \ 0 \ 0.3)
                                      }
                                      if `difj'==1 {
                                        mat F=(0.3 \ 0 \ 0 \ 0)
                                      }
                                      if `difj'==2 {
                                        mat F=(0 \ 0.3 \ 0 \ 0)
                                      }
                                      if `difj'==3 {
                                        mat F=(0 \ 0 \ 0.3 \ 0)
                                      }
                                      if `difj'==4 {
                                        mat F=(0 \ 0 \ 0 \ 0.3)
                                      }
                                      mat D=B-E-F
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                      qui gen dif2 = `difj'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_9G_300.csv", replace



** Scenario 10: J = 4 items / M = 4 modalities / DIF SIZE = 0.3

* Scenario 10A : H_0 is TRUE / DIF on treatment x 2

di "Scenario 10A - N=300"

forvalues replication = 1/1000 {
  clear
  if mod(`replication',100)==0 {
  di "replication = `replication'"
  }
  qui set obs 4
  qui gen xxx = _n
  qui sample 2 ,count
  qui valuesof xxx
  qui local ItemsDIF = r(values)
  qui local difi :  word 1 of `ItemsDIF'
  qui local difj :  word 2 of `ItemsDIF'

    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    if `difi'==1 {
      mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==2 {
      mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==3 {
      mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
    }
    if `difi'==4 {
      mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
    }
    if `difj'==1 {
      mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difj'==2 {
      mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
    }
    if `difj'==3 {
      mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
    }
    if `difj'==4 {
      mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
    }
    mat D=B-E-F
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
    qui gen dif2 = `difj'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_10A_300.csv", replace


  * Scenario 10B : H_1 is TRUE / Effect size 0.2 / DIF on treatment x2

  di "Scenario 10B - N=300"

  forvalues replication = 1/1000 {
    clear
    if mod(`replication',100)==0 {
    di "replication = `replication'"
    }
    qui set obs 4
    qui gen xxx = _n
    qui sample 2 ,count
    qui valuesof xxx
    qui local ItemsDIF = r(values)
    qui local difi :  word 1 of `ItemsDIF'
    qui local difj :  word 2 of `ItemsDIF'

      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      if `difi'==1 {
        mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==2 {
        mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==3 {
        mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
      }
      if `difi'==4 {
        mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
      }
      if `difj'==1 {
        mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difj'==2 {
        mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
      }
      if `difj'==3 {
        mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
      }
      if `difj'==4 {
        mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
      }
      mat D=B+E+F
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
      qui gen dif2 = `difj'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_10B_300.csv", replace

* Scenario 10C : H_1 is TRUE / Effect size 0.2 / DIF negative x2

    di "Scenario 10C - N=300"

    forvalues replication = 1/1000 {
      clear
      if mod(`replication',100)==0 {
      di "replication = `replication'"
      }
      qui set obs 4
      qui gen xxx = _n
      qui sample 2 ,count
      qui valuesof xxx
      qui local ItemsDIF = r(values)
      qui local difi :  word 1 of `ItemsDIF'
      qui local difj :  word 2 of `ItemsDIF'

      mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
        if `difi'==1 {
          mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
        }
        if `difi'==2 {
          mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
        }
        if `difi'==3 {
          mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
        }
        if `difi'==4 {
          mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
        }
        if `difj'==1 {
          mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
        }
        if `difj'==2 {
          mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
        }
        if `difj'==3 {
          mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
        }
        if `difj'==4 {
          mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
        }
        mat D=B-E-F
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
        qui gen dif2 = `difj'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_10C_300.csv", replace


* Scenario 10D : H_1 is TRUE / Effect size 0.4 / DIF on treatment x2

        di "Scenario 10D - N=300"

        forvalues replication = 1/1000 {
          clear
          if mod(`replication',100)==0 {
          di "replication = `replication'"
          }
          qui set obs 4
          qui gen xxx = _n
          qui sample 2 ,count
          qui valuesof xxx
          qui local ItemsDIF = r(values)
          qui local difi :  word 1 of `ItemsDIF'
          qui local difj :  word 2 of `ItemsDIF'

            mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
            if `difi'==1 {
              mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
            }
            if `difi'==2 {
              mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
            }
            if `difi'==3 {
              mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
            }
            if `difi'==4 {
              mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
            }
            if `difj'==1 {
              mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
            }
            if `difj'==2 {
              mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
            }
            if `difj'==3 {
              mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
            }
            if `difj'==4 {
              mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
            }
            mat D=B+E+F
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
            qui gen dif2 = `difj'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_10D_300.csv", replace

* Scenario 10E : H_1 is TRUE / Effect size 0.4 / DIF negative x2

          di "Scenario 10E - N=300"

          forvalues replication = 1/1000 {
            clear
            if mod(`replication',100)==0 {
            di "replication = `replication'"
            }
            qui set obs 4
            qui gen xxx = _n
            qui sample 2 ,count
            qui valuesof xxx
            qui local ItemsDIF = r(values)
            qui local difi :  word 1 of `ItemsDIF'
            qui local difj :  word 2 of `ItemsDIF'

            mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              if `difi'==1 {
                mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==2 {
                mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==3 {
                mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
              }
              if `difi'==4 {
                mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
              }
              if `difj'==1 {
                mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difj'==2 {
                mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
              }
              if `difj'==3 {
                mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
              }
              if `difj'==4 {
                mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
              }
              mat D=B-E-F
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
              qui gen dif2 = `difj'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_10E_300.csv", replace

* Scenario 10F : H_1 is TRUE / Effect size -0.2 / DIF negative x2

                      di "Scenario 10F - N=300"

                      forvalues replication = 1/1000 {
                        clear
                        if mod(`replication',100)==0 {
                        di "replication = `replication'"
                        }
                        qui set obs 4
                        qui gen xxx = _n
                        qui sample 2 ,count
                        qui valuesof xxx
                        qui local ItemsDIF = r(values)
                        qui local difi :  word 1 of `ItemsDIF'
                        qui local difj :  word 2 of `ItemsDIF'

                        mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                          if `difi'==1 {
                            mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                          }
                          if `difi'==2 {
                            mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                          }
                          if `difi'==3 {
                            mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                          }
                          if `difi'==4 {
                            mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                          }
                          if `difj'==1 {
                            mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                          }
                          if `difj'==2 {
                            mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                          }
                          if `difj'==3 {
                            mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                          }
                          if `difj'==4 {
                            mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                          }
                          mat D=B-E-F
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                          qui gen dif2 = `difj'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_10F_300.csv", replace


* Scenario 10G : H_1 is TRUE / Effect size -0.4 / DIF negative x2

                                  di "Scenario 10G - N=300"

                                  forvalues replication = 1/1000 {
                                    clear
                                    if mod(`replication',100)==0 {
                                    di "replication = `replication'"
                                    }
                                    qui set obs 4
                                    qui gen xxx = _n
                                    qui sample 2 ,count
                                    qui valuesof xxx
                                    qui local ItemsDIF = r(values)
                                    qui local difi :  word 1 of `ItemsDIF'
                                    qui local difj :  word 2 of `ItemsDIF'

                                    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                      if `difi'==1 {
                                        mat E=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difi'==2 {
                                        mat E=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difi'==3 {
                                        mat E=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                                      }
                                      if `difi'==4 {
                                        mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                                      }
                                      if `difj'==1 {
                                        mat F=(0.3,0.3,0.3 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difj'==2 {
                                        mat F=(0,0,0 \ 0.3,0.3,0.3 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difj'==3 {
                                        mat F=(0,0,0 \ 0,0,0 \ 0.3,0.3,0.3 \ 0,0,0)
                                      }
                                      if `difj'==4 {
                                        mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.3,0.3,0.3)
                                      }
                                      mat D=B-E-F
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                      qui gen dif2 = `difj'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_10G_300.csv", replace



**** Scenarios with : DIF size 0.5 ****

** Scenario 11: J = 4 items / M = 2 modalities / DIF SIZE = 0.5

* Scenario 11A : H_0 is TRUE / DIF on treatment x 2

di "Scenario 11A - N=300"

forvalues replication = 1/1000 {
  clear
  if mod(`replication',100)==0 {
  di "replication = `replication'"
  }
  qui set obs 4
  qui gen xxx = _n
  qui sample 2 ,count
  qui valuesof xxx
  qui local ItemsDIF = r(values)
  qui local difi :  word 1 of `ItemsDIF'
  qui local difj :  word 2 of `ItemsDIF'

		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    if `difi'==1 {
      mat E=(0.5 \ 0 \ 0 \ 0)
    }
    if `difi'==2 {
      mat E=(0 \ 0.5 \ 0 \ 0)
    }
    if `difi'==3 {
      mat E=(0 \ 0 \ 0.5 \ 0)
    }
    if `difi'==4 {
      mat E=(0 \ 0 \ 0 \ 0.5)
    }
    if `difj'==1 {
      mat F=(0.5 \ 0 \ 0 \ 0)
    }
    if `difj'==2 {
      mat F=(0 \ 0.5 \ 0 \ 0)
    }
    if `difj'==3 {
      mat F=(0 \ 0 \ 0.5 \ 0)
    }
    if `difj'==4 {
      mat F=(0 \ 0 \ 0 \ 0.5)
    }
    mat D=B-E-F
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
    qui gen dif2 = `difj'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_11A_300.csv", replace


  * Scenario 11B : H_1 is TRUE / Effect size 0.2 / DIF on treatment x2

  di "Scenario 11B - N=300"

  forvalues replication = 1/1000 {
    clear
    if mod(`replication',100)==0 {
    di "replication = `replication'"
    }
    qui set obs 4
    qui gen xxx = _n
    qui sample 2 ,count
    qui valuesof xxx
    qui local ItemsDIF = r(values)
    qui local difi :  word 1 of `ItemsDIF'
    qui local difj :  word 2 of `ItemsDIF'

  		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
      if `difi'==1 {
        mat E=(0.5 \ 0 \ 0 \ 0)
      }
      if `difi'==2 {
        mat E=(0 \ 0.5 \ 0 \ 0)
      }
      if `difi'==3 {
        mat E=(0 \ 0 \ 0.5 \ 0)
      }
      if `difi'==4 {
        mat E=(0 \ 0 \ 0 \ 0.5)
      }
      if `difj'==1 {
        mat F=(0.5 \ 0 \ 0 \ 0)
      }
      if `difj'==2 {
        mat F=(0 \ 0.5 \ 0 \ 0)
      }
      if `difj'==3 {
        mat F=(0 \ 0 \ 0.5 \ 0)
      }
      if `difj'==4 {
        mat F=(0 \ 0 \ 0 \ 0.5)
      }
      mat D=B+E+F
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
      qui gen dif2 = `difj'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_11B_300.csv", replace

* Scenario 11C : H_1 is TRUE / Effect size 0.2 / DIF negative x2

    di "Scenario 11C - N=300"

    forvalues replication = 1/1000 {
      clear
      if mod(`replication',100)==0 {
      di "replication = `replication'"
      }
      qui set obs 4
      qui gen xxx = _n
      qui sample 2 ,count
      qui valuesof xxx
      qui local ItemsDIF = r(values)
      qui local difi :  word 1 of `ItemsDIF'
      qui local difj :  word 2 of `ItemsDIF'

      mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        if `difi'==1 {
          mat E=(0.5 \ 0 \ 0 \ 0)
        }
        if `difi'==2 {
          mat E=(0 \ 0.5 \ 0 \ 0)
        }
        if `difi'==3 {
          mat E=(0 \ 0 \ 0.5 \ 0)
        }
        if `difi'==4 {
          mat E=(0 \ 0 \ 0 \ 0.5)
        }
        if `difj'==1 {
          mat F=(0.5 \ 0 \ 0 \ 0)
        }
        if `difj'==2 {
          mat F=(0 \ 0.5 \ 0 \ 0)
        }
        if `difj'==3 {
          mat F=(0 \ 0 \ 0.5 \ 0)
        }
        if `difj'==4 {
          mat F=(0 \ 0 \ 0 \ 0.5)
        }
        mat D=B-E-F
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
        qui gen dif2 = `difj'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_11C_300.csv", replace


* Scenario 11D : H_1 is TRUE / Effect size 0.4 / DIF on treatment x2

        di "Scenario 11D - N=300"

        forvalues replication = 1/1000 {
          clear
          if mod(`replication',100)==0 {
          di "replication = `replication'"
          }
          qui set obs 4
          qui gen xxx = _n
          qui sample 2 ,count
          qui valuesof xxx
          qui local ItemsDIF = r(values)
          qui local difi :  word 1 of `ItemsDIF'
          qui local difj :  word 2 of `ItemsDIF'

        		mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
            if `difi'==1 {
              mat E=(0.5 \ 0 \ 0 \ 0)
            }
            if `difi'==2 {
              mat E=(0 \ 0.5 \ 0 \ 0)
            }
            if `difi'==3 {
              mat E=(0 \ 0 \ 0.5 \ 0)
            }
            if `difi'==4 {
              mat E=(0 \ 0 \ 0 \ 0.5)
            }
            if `difj'==1 {
              mat F=(0.5 \ 0 \ 0 \ 0)
            }
            if `difj'==2 {
              mat F=(0 \ 0.5 \ 0 \ 0)
            }
            if `difj'==3 {
              mat F=(0 \ 0 \ 0.5 \ 0)
            }
            if `difj'==4 {
              mat F=(0 \ 0 \ 0 \ 0.5)
            }
            mat D=B+E+F
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
            qui gen dif2 = `difj'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_11D_300.csv", replace

* Scenario 11E : H_1 is TRUE / Effect size 0.4 / DIF negative x2

          di "Scenario 11E - N=300"

          forvalues replication = 1/1000 {
            clear
            if mod(`replication',100)==0 {
            di "replication = `replication'"
            }
            qui set obs 4
            qui gen xxx = _n
            qui sample 2 ,count
            qui valuesof xxx
            qui local ItemsDIF = r(values)
            qui local difi :  word 1 of `ItemsDIF'
            qui local difj :  word 2 of `ItemsDIF'

            mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
              if `difi'==1 {
                mat E=(0.5 \ 0 \ 0 \ 0)
              }
              if `difi'==2 {
                mat E=(0 \ 0.5 \ 0 \ 0)
              }
              if `difi'==3 {
                mat E=(0 \ 0 \ 0.5 \ 0)
              }
              if `difi'==4 {
                mat E=(0 \ 0 \ 0 \ 0.5)
              }
              if `difj'==1 {
                mat F=(0.5 \ 0 \ 0 \ 0)
              }
              if `difj'==2 {
                mat F=(0 \ 0.5 \ 0 \ 0)
              }
              if `difj'==3 {
                mat F=(0 \ 0 \ 0.5 \ 0)
              }
              if `difj'==4 {
                mat F=(0 \ 0 \ 0 \ 0.5)
              }
              mat D=B-E-F
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
              qui gen dif2 = `difj'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_11E_300.csv", replace

* Scenario 11F : H_1 is TRUE / Effect size -0.2 / DIF negative x2

                      di "Scenario 11F - N=300"

                      forvalues replication = 1/1000 {
                        clear
                        if mod(`replication',100)==0 {
                        di "replication = `replication'"
                        }
                        qui set obs 4
                        qui gen xxx = _n
                        qui sample 2 ,count
                        qui valuesof xxx
                        qui local ItemsDIF = r(values)
                        qui local difi :  word 1 of `ItemsDIF'
                        qui local difj :  word 2 of `ItemsDIF'

                        mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                          if `difi'==1 {
                            mat E=(0.5 \ 0 \ 0 \ 0)
                          }
                          if `difi'==2 {
                            mat E=(0 \ 0.5 \ 0 \ 0)
                          }
                          if `difi'==3 {
                            mat E=(0 \ 0 \ 0.5 \ 0)
                          }
                          if `difi'==4 {
                            mat E=(0 \ 0 \ 0 \ 0.5)
                          }
                          if `difj'==1 {
                            mat F=(0.5 \ 0 \ 0 \ 0)
                          }
                          if `difj'==2 {
                            mat F=(0 \ 0.5 \ 0 \ 0)
                          }
                          if `difj'==3 {
                            mat F=(0 \ 0 \ 0.5 \ 0)
                          }
                          if `difj'==4 {
                            mat F=(0 \ 0 \ 0 \ 0.5)
                          }
                          mat D=B-E-F
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                          qui gen dif2 = `difj'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_11F_300.csv", replace


* Scenario 11G : H_1 is TRUE / Effect size -0.4 / DIF negative x2

                                  di "Scenario 11G - N=300"

                                  forvalues replication = 1/1000 {
                                    clear
                                    if mod(`replication',100)==0 {
                                    di "replication = `replication'"
                                    }
                                    qui set obs 4
                                    qui gen xxx = _n
                                    qui sample 2 ,count
                                    qui valuesof xxx
                                    qui local ItemsDIF = r(values)
                                    qui local difi :  word 1 of `ItemsDIF'
                                    qui local difj :  word 2 of `ItemsDIF'

                                    mat D= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-0.84 \ -0.25 \ 0.25 \ 0.84)
                                      if `difi'==1 {
                                        mat E=(0.5 \ 0 \ 0 \ 0)
                                      }
                                      if `difi'==2 {
                                        mat E=(0 \ 0.5 \ 0 \ 0)
                                      }
                                      if `difi'==3 {
                                        mat E=(0 \ 0 \ 0.5 \ 0)
                                      }
                                      if `difi'==4 {
                                        mat E=(0 \ 0 \ 0 \ 0.5)
                                      }
                                      if `difj'==1 {
                                        mat F=(0.5 \ 0 \ 0 \ 0)
                                      }
                                      if `difj'==2 {
                                        mat F=(0 \ 0.5 \ 0 \ 0)
                                      }
                                      if `difj'==3 {
                                        mat F=(0 \ 0 \ 0.5 \ 0)
                                      }
                                      if `difj'==4 {
                                        mat F=(0 \ 0 \ 0 \ 0.5)
                                      }
                                      mat D=B-E-F
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                      qui gen dif2 = `difj'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_11G_300.csv", replace



** Scenario 12: J = 4 items / M = 4 modalities / DIF SIZE = 0.5

* Scenario 12A : H_0 is TRUE / DIF on treatment x 2

di "Scenario 12A - N=300"

forvalues replication = 1/1000 {
  clear
  if mod(`replication',100)==0 {
  di "replication = `replication'"
  }
  qui set obs 4
  qui gen xxx = _n
  qui sample 2 ,count
  qui valuesof xxx
  qui local ItemsDIF = r(values)
  qui local difi :  word 1 of `ItemsDIF'
  qui local difj :  word 2 of `ItemsDIF'

    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 0
		tempfile grp0
		qui save `grp0',replace


    mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    if `difi'==1 {
      mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==2 {
      mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
    }
    if `difi'==3 {
      mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
    }
    if `difi'==4 {
      mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
    }
    if `difj'==1 {
      mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
    }
    if `difj'==2 {
      mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
    }
    if `difj'==3 {
      mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
    }
    if `difj'==4 {
      mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
    }
    mat D=B-E-F
		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
    qui gen TT = 1
		tempfile grp1
		qui save `grp1',replace


		clear
		use `grp0'
    qui append using `grp1'
		drop id
    qui gen dif1 = `difi'
    qui gen dif2 = `difj'
		qui gen id = _n
		order(id)
		qui gen replication = `replication'
		if `replication'==1{
			tempfile data
			qui save `data'
		}
		else{
			qui append using `data'
			qui save `data',replace
		}
	}
	export delimited using "`path'/scenario_12A_300.csv", replace


  * Scenario 12B : H_1 is TRUE / Effect size 0.2 / DIF on treatment x2

  di "Scenario 12B - N=300"

  forvalues replication = 1/1000 {
    clear
    if mod(`replication',100)==0 {
    di "replication = `replication'"
    }
    qui set obs 4
    qui gen xxx = _n
    qui sample 2 ,count
    qui valuesof xxx
    qui local ItemsDIF = r(values)
    qui local difi :  word 1 of `ItemsDIF'
    qui local difj :  word 2 of `ItemsDIF'

      mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
      qui gen TT = 0
  		tempfile grp0
  		qui save `grp0',replace


      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
      if `difi'==1 {
        mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==2 {
        mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
      }
      if `difi'==3 {
        mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
      }
      if `difi'==4 {
        mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
      }
      if `difj'==1 {
        mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
      }
      if `difj'==2 {
        mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
      }
      if `difj'==3 {
        mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
      }
      if `difj'==4 {
        mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
      }
      mat D=B+E+F
  		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
      qui gen TT = 1
  		tempfile grp1
  		qui save `grp1',replace


  		clear
  		use `grp0'
      qui append using `grp1'
  		drop id
      qui gen dif1 = `difi'
      qui gen dif2 = `difj'
  		qui gen id = _n
  		order(id)
  		qui gen replication = `replication'
  		if `replication'==1{
  			tempfile data
  			qui save `data'
  		}
  		else{
  			qui append using `data'
  			qui save `data',replace
  		}
  	}
  	export delimited using "`path'/scenario_12B_300.csv", replace

* Scenario 12C : H_1 is TRUE / Effect size 0.2 / DIF negative x2

    di "Scenario 12C - N=300"

    forvalues replication = 1/1000 {
      clear
      if mod(`replication',100)==0 {
      di "replication = `replication'"
      }
      qui set obs 4
      qui gen xxx = _n
      qui sample 2 ,count
      qui valuesof xxx
      qui local ItemsDIF = r(values)
      qui local difi :  word 1 of `ItemsDIF'
      qui local difj :  word 2 of `ItemsDIF'

      mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
    		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
        qui gen TT = 0
    		tempfile grp0
    		qui save `grp0',replace


        mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
        if `difi'==1 {
          mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
        }
        if `difi'==2 {
          mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
        }
        if `difi'==3 {
          mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
        }
        if `difi'==4 {
          mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
        }
        if `difj'==1 {
          mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
        }
        if `difj'==2 {
          mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
        }
        if `difj'==3 {
          mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
        }
        if `difj'==4 {
          mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
        }
        mat D=B-E-F
    		qui simirt, nbobs(`Nn') mu(0.2) cov(1) dim(4) pcm(D) clear
        qui gen TT = 1
    		tempfile grp1
    		qui save `grp1',replace


    		clear
    		use `grp0'
        qui append using `grp1'
    		drop id
        qui gen dif1 = `difi'
        qui gen dif2 = `difj'
    		qui gen id = _n
    		order(id)
    		qui gen replication = `replication'
    		if `replication'==1{
    			tempfile data
    			qui save `data'
    		}
    		else{
    			qui append using `data'
    			qui save `data',replace
    		}
    	}
    	export delimited using "`path'/scenario_12C_300.csv", replace


* Scenario 12D : H_1 is TRUE / Effect size 0.4 / DIF on treatment x2

        di "Scenario 12D - N=300"

        forvalues replication = 1/1000 {
          clear
          if mod(`replication',100)==0 {
          di "replication = `replication'"
          }
          qui set obs 4
          qui gen xxx = _n
          qui sample 2 ,count
          qui valuesof xxx
          qui local ItemsDIF = r(values)
          qui local difi :  word 1 of `ItemsDIF'
          qui local difj :  word 2 of `ItemsDIF'

            mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
        		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
            qui gen TT = 0
        		tempfile grp0
        		qui save `grp0',replace


            mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
            if `difi'==1 {
              mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
            }
            if `difi'==2 {
              mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
            }
            if `difi'==3 {
              mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
            }
            if `difi'==4 {
              mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
            }
            if `difj'==1 {
              mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
            }
            if `difj'==2 {
              mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
            }
            if `difj'==3 {
              mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
            }
            if `difj'==4 {
              mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
            }
            mat D=B+E+F
        		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
            qui gen TT = 1
        		tempfile grp1
        		qui save `grp1',replace


        		clear
        		use `grp0'
            qui append using `grp1'
        		drop id
            qui gen dif1 = `difi'
            qui gen dif2 = `difj'
        		qui gen id = _n
        		order(id)
        		qui gen replication = `replication'
        		if `replication'==1{
        			tempfile data
        			qui save `data'
        		}
        		else{
        			qui append using `data'
        			qui save `data',replace
        		}
        	}
        	export delimited using "`path'/scenario_12D_300.csv", replace

* Scenario 12E : H_1 is TRUE / Effect size 0.4 / DIF negative x2

          di "Scenario 12E - N=300"

          forvalues replication = 1/1000 {
            clear
            if mod(`replication',100)==0 {
            di "replication = `replication'"
            }
            qui set obs 4
            qui gen xxx = _n
            qui sample 2 ,count
            qui valuesof xxx
            qui local ItemsDIF = r(values)
            qui local difi :  word 1 of `ItemsDIF'
            qui local difj :  word 2 of `ItemsDIF'

            mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
          		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
              qui gen TT = 0
          		tempfile grp0
          		qui save `grp0',replace


              mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
              if `difi'==1 {
                mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==2 {
                mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
              }
              if `difi'==3 {
                mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
              }
              if `difi'==4 {
                mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
              }
              if `difj'==1 {
                mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
              }
              if `difj'==2 {
                mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
              }
              if `difj'==3 {
                mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
              }
              if `difj'==4 {
                mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
              }
              mat D=B-E-F
          		qui simirt, nbobs(`Nn') mu(0.4) cov(1) dim(4) pcm(D) clear
              qui gen TT = 1
          		tempfile grp1
          		qui save `grp1',replace


          		clear
          		use `grp0'
              qui append using `grp1'
          		drop id
              qui gen dif1 = `difi'
              qui gen dif2 = `difj'
          		qui gen id = _n
          		order(id)
          		qui gen replication = `replication'
          		if `replication'==1{
          			tempfile data
          			qui save `data'
          		}
          		else{
          			qui append using `data'
          			qui save `data',replace
          		}
          	}
          	export delimited using "`path'/scenario_12E_300.csv", replace



* Scenario 12F : H_1 is TRUE / Effect size -0.2 / DIF negative x2

di "Scenario 12F - N=300"

                      forvalues replication = 1/1000 {
                        clear
                        if mod(`replication',100)==0 {
                        di "replication = `replication'"
                        }
                        qui set obs 4
                        qui gen xxx = _n
                        qui sample 2 ,count
                        qui valuesof xxx
                        qui local ItemsDIF = r(values)
                        qui local difi :  word 1 of `ItemsDIF'
                        qui local difj :  word 2 of `ItemsDIF'

                        mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                      		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 0
                      		tempfile grp0
                      		qui save `grp0',replace


                          mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                          if `difi'==1 {
                            mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                          }
                          if `difi'==2 {
                            mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                          }
                          if `difi'==3 {
                            mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                          }
                          if `difi'==4 {
                            mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                          }
                          if `difj'==1 {
                            mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                          }
                          if `difj'==2 {
                            mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                          }
                          if `difj'==3 {
                            mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                          }
                          if `difj'==4 {
                            mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                          }
                          mat D=B-E-F
                      		qui simirt, nbobs(`Nn') mu(-0.2) cov(1) dim(4) pcm(D) clear
                          qui gen TT = 1
                      		tempfile grp1
                      		qui save `grp1',replace


                      		clear
                      		use `grp0'
                          qui append using `grp1'
                      		drop id
                          qui gen dif1 = `difi'
                          qui gen dif2 = `difj'
                      		qui gen id = _n
                      		order(id)
                      		qui gen replication = `replication'
                      		if `replication'==1{
                      			tempfile data
                      			qui save `data'
                      		}
                      		else{
                      			qui append using `data'
                      			qui save `data',replace
                      		}
                      	}
                      	export delimited using "`path'/scenario_12F_300.csv", replace


* Scenario 12G : H_1 is TRUE / Effect size -0.4 / DIF negative x2

di "Scenario 12G - N=300"

                                  forvalues replication = 1/1000 {
                                    clear
                                    if mod(`replication',100)==0 {
                                    di "replication = `replication'"
                                    }
                                    qui set obs 4
                                    qui gen xxx = _n
                                    qui sample 2 ,count
                                    qui valuesof xxx
                                    qui local ItemsDIF = r(values)
                                    qui local difi :  word 1 of `ItemsDIF'
                                    qui local difj :  word 2 of `ItemsDIF'

                                    mat D= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                  		qui simirt, nbobs(`Nn') mu(0) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 0
                                  		tempfile grp0
                                  		qui save `grp0',replace


                                      mat B= (-1.84,-0.84,0.16 \ -1.25,-0.25,0.75 \ -0.75,0.25,1.25 \ 0.16,0.84,1.84)
                                      if `difi'==1 {
                                        mat E=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difi'==2 {
                                        mat E=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difi'==3 {
                                        mat E=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                                      }
                                      if `difi'==4 {
                                        mat E=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                                      }
                                      if `difj'==1 {
                                        mat F=(0.5,0.5,0.5 \ 0,0,0 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difj'==2 {
                                        mat F=(0,0,0 \ 0.5,0.5,0.5 \ 0,0,0 \ 0,0,0)
                                      }
                                      if `difj'==3 {
                                        mat F=(0,0,0 \ 0,0,0 \ 0.5,0.5,0.5 \ 0,0,0)
                                      }
                                      if `difj'==4 {
                                        mat F=(0,0,0 \ 0,0,0 \ 0,0,0 \ 0.5,0.5,0.5)
                                      }
                                      mat D=B-E-F
                                  		qui simirt, nbobs(`Nn') mu(-0.4) cov(1) dim(4) pcm(D) clear
                                      qui gen TT = 1
                                  		tempfile grp1
                                  		qui save `grp1',replace


                                  		clear
                                  		use `grp0'
                                      qui append using `grp1'
                                  		drop id
                                      qui gen dif1 = `difi'
                                      qui gen dif2 = `difj'
                                  		qui gen id = _n
                                  		order(id)
                                  		qui gen replication = `replication'
                                  		if `replication'==1{
                                  			tempfile data
                                  			qui save `data'
                                  		}
                                  		else{
                                  			qui append using `data'
                                  			qui save `data',replace
                                  		}
                                  	}
                                  	export delimited using "`path'/scenario_12G_300.csv", replace
