Created difficulty matrix generation R script + initial scenarios
parent
1282636552
commit
466c2a1277
@ -0,0 +1,39 @@
|
||||
###################################################
|
||||
# Function: generate_diff_irt
|
||||
# Generates item difficulty threshold matrix for
|
||||
# IRT model simulation
|
||||
###################################################
|
||||
|
||||
|
||||
generate_diff_irt <- function(J=7,M=4) {
|
||||
# if J=7, item 5. Else, item 3
|
||||
if(J==7){
|
||||
i <- 5
|
||||
}
|
||||
if(J==4){
|
||||
i <- 3
|
||||
}
|
||||
difficulties = matrix(c(0), J,M-1)
|
||||
rownames(difficulties)=paste("item",1:J)
|
||||
colnames(difficulties)=paste("Moda", 1:(M-1))
|
||||
for (j in 1:J){
|
||||
difficulties[j,1] = qnorm(j/(J+1))
|
||||
}
|
||||
for (j in 1:J){
|
||||
for (m in 2:(M-1)){
|
||||
difficulties[j,m]= difficulties[j,1]+(m-1)*2/(M-2)
|
||||
}
|
||||
}
|
||||
difficulties = difficulties-mean(difficulties)
|
||||
return(difficulties)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###################################################
|
||||
# GENERATE MATRIX FOR SIMULATION
|
||||
###################################################
|
||||
|
||||
|
@ -0,0 +1,78 @@
|
||||
*=================================================================================================================================================
|
||||
* Date : 2024-01-04
|
||||
* Stata version : Stata 18 SE
|
||||
*
|
||||
* This program creates dataset without DIF for a randomized controlled trial scenario
|
||||
*
|
||||
* ado-files needed : - simirt (version 4.3 August 29, 2019, available on OSF)
|
||||
*
|
||||
* outputs : TBA
|
||||
*
|
||||
*
|
||||
* 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/simirt.ado"
|
||||
|
||||
* Set data output folder path
|
||||
local path = "/home/corentin/Documents/These/Recherche/Simulations/Data"
|
||||
|
||||
|
||||
|
||||
* Scenarios with : n = 800
|
||||
*==========================
|
||||
|
||||
* Scenario No. 7 : J = 4 items + C1 et C2 not correlated
|
||||
|
||||
forvalues replication = 1/500 {
|
||||
di "replication = `replication'"
|
||||
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(200) mu(0) cov(1) dim(4) pcm(D) clear
|
||||
qui gen C1 = 0
|
||||
qui gen C2 = 0
|
||||
tempfile grp00
|
||||
qui save `grp00',replace
|
||||
|
||||
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(200) mu(0) cov(1) dim(4) pcm(D) clear
|
||||
qui gen C1 = 1
|
||||
qui gen C2 = 0
|
||||
tempfile grp10
|
||||
qui save `grp10',replace
|
||||
|
||||
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(200) mu(0) cov(1) dim(4) pcm(D) clear
|
||||
qui gen C1 = 0
|
||||
qui gen C2 = 1
|
||||
tempfile grp01
|
||||
qui save `grp01',replace
|
||||
|
||||
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(200) mu(0) cov(1) dim(4) pcm(D) clear
|
||||
qui gen C1 = 1
|
||||
qui gen C2 = 1
|
||||
tempfile grp11
|
||||
qui save `grp11',replace
|
||||
|
||||
clear
|
||||
use `grp00'
|
||||
qui append using `grp10'
|
||||
qui append using `grp01'
|
||||
qui append using `grp11'
|
||||
drop id
|
||||
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'\Scenario7.csv", replace
|
Loading…
Reference in New Issue