Hi

I am using Stata/SE 14.

I have item bank of 260 questions (binary response), these items are spread across 50 bins/categories. There are 2000 candidates who gave their responses to these items already.

Now I would like to generate say 100 exams each with 50 items (one item from each bin). Then I would like to run 2pl irt model for each exam and see if these 100 exams are parallel (by checking the test information curve for example)

I assume a loop can be used to do this, but I am not sure how . I want the loop to randomly select 50 items from the bank , one item from each bin , then run irt, store estimates and curve, and repeat this process say 100 times. So then I can compare the estimates and curves generated.

This is the syntax I have in mind for an existing example:


webuse masc1
(Data from De Boeck & Wilson (2004))

generate id = _n
quietly reshape long q, i(id) j(item)
rename q y
fvset base none id item

gen bin=1 if item==1 | item==2
replace bin=2 if item==3 | item==4
replace bin=3 if item==5 | item==6
replace bin=4 if item==7 | item==8 | item==9

*****I believe I can start a loop from here, this is the part I am having difficulty with***

Randomly select one item from each bin (end up with an exam of four items in total, one from each bin)

drop bin
reshape wide y , i(id) j(item)
irt 2pl y*
estat report, byparm sort(b)
irtgraph tif
estimates store exam1 (for all 100 exams)

Repeat this process 100 times (generate 100 exams with four items, one from each bin-then run 2pl irt)
estimates table _all

End of loop

Can someone kindly help me how to do such loop or if you have a better idea

Thank you

Kind regards
Nahla Betelmal