Simulation code ready

main
Corentin Choisy 12 months ago
parent 466c2a1277
commit c0cdde3a03

@ -0,0 +1,201 @@
id,lt1,item1,item2,item3,item4,TT,replication
1,.17644101,0,0,0,1,0,1
2,1.1119704,0,1,1,1,0,1
3,-.46370447,0,1,0,1,0,1
4,-1.0415101,1,0,1,0,0,1
5,-1.2738965,1,0,0,0,0,1
6,-.085420959,1,1,0,1,0,1
7,1.1056501,1,1,1,1,0,1
8,-.32086244,1,0,1,0,0,1
9,.54192197,1,0,0,0,0,1
10,.49705315,1,1,0,1,0,1
11,-.64607531,1,1,0,1,0,1
12,.51508766,0,1,1,0,0,1
13,.2836611,0,0,0,1,0,1
14,-.63813239,1,1,1,0,0,1
15,1.4577918,1,1,1,1,0,1
16,-.9888711,1,0,1,0,0,1
17,-1.8077854,1,0,0,0,0,1
18,-.36925948,1,0,0,0,0,1
19,.17932144,1,0,0,0,0,1
20,-.63588434,0,1,0,1,0,1
21,.86244547,0,0,0,0,0,1
22,-.44217664,1,0,0,0,0,1
23,-.38870588,1,1,1,0,0,1
24,.95358348,1,1,0,0,0,1
25,-.36753294,1,0,1,0,0,1
26,-.63655686,0,0,0,0,0,1
27,-.012073237,1,1,1,0,0,1
28,-.13124834,1,0,1,0,0,1
29,-.14458376,1,0,1,0,0,1
30,-.25078735,1,1,0,0,0,1
31,-.16138455,1,1,1,0,0,1
32,.75585234,1,0,1,1,0,1
33,-.60850286,1,0,1,0,0,1
34,.79716212,1,0,1,0,0,1
35,.45342034,1,1,1,0,0,1
36,-2.1057169,0,0,0,0,0,1
37,.79157275,1,0,0,1,0,1
38,-.66571254,0,1,0,0,0,1
39,-.097855851,1,1,0,1,0,1
40,1.0418533,1,0,1,1,0,1
41,-.46935579,0,0,0,0,0,1
42,.63163638,1,1,0,0,0,1
43,.085910544,0,1,1,1,0,1
44,.83931607,1,0,0,0,0,1
45,.50145197,1,1,1,0,0,1
46,2.5159037,0,1,1,1,0,1
47,-.29928276,1,1,0,0,0,1
48,-.52162999,1,1,0,1,0,1
49,1.7009553,1,1,1,1,0,1
50,-.44088203,1,0,1,0,0,1
51,1.5880907,1,1,0,0,0,1
52,-.47029325,0,0,0,0,0,1
53,1.2277231,1,1,0,1,0,1
54,.42639166,1,0,1,1,0,1
55,-.95310265,0,0,0,0,0,1
56,.64398259,1,0,1,1,0,1
57,.18478298,1,1,0,1,0,1
58,.82810265,1,0,1,1,0,1
59,-.33021048,1,0,0,0,0,1
60,-3.170429,0,0,0,0,0,1
61,-1.1574296,0,1,1,0,0,1
62,1.8837459,1,1,0,0,0,1
63,-1.2181894,0,0,0,0,0,1
64,1.2980061,1,1,1,1,0,1
65,-.32206535,1,1,0,0,0,1
66,-.42526674,0,0,0,0,0,1
67,1.3604238,0,1,0,1,0,1
68,-1.6900293,0,0,0,0,0,1
69,.46790454,0,0,1,1,0,1
70,.46692941,0,0,0,0,0,1
71,-1.4733744,1,0,0,0,0,1
72,-.20302044,0,1,1,1,0,1
73,-.48481002,0,0,0,0,0,1
74,.18501657,0,0,1,0,0,1
75,-1.5757569,1,0,0,0,0,1
76,.225288,0,0,0,0,0,1
77,.40944499,0,1,1,1,0,1
78,.03514893,1,1,0,1,0,1
79,-2.0809295,0,0,1,0,0,1
80,.89514649,1,1,1,0,0,1
81,-1.3915017,1,0,0,1,0,1
82,.11379968,1,1,0,0,0,1
83,1.5646211,1,1,1,1,0,1
84,-.31079024,1,0,1,0,0,1
85,1.2880181,1,1,1,1,0,1
86,-.16200012,1,0,1,0,0,1
87,-.26236823,0,1,1,0,0,1
88,-.17450906,1,1,0,0,0,1
89,-1.8440282,0,0,1,0,0,1
90,-.13284066,0,1,0,0,0,1
91,1.5515995,1,1,1,1,0,1
92,-.78718334,1,0,0,0,0,1
93,-.28649214,1,0,1,1,0,1
94,.65451664,1,1,0,0,0,1
95,.26079011,0,0,0,1,0,1
96,1.4207528,1,1,1,0,0,1
97,-.36326984,0,1,0,0,0,1
98,-.0092543131,1,1,0,1,0,1
99,.73671579,0,1,1,1,0,1
100,.078362353,1,0,0,1,0,1
101,-.24513553,1,1,0,0,1,1
102,-.85109341,1,1,1,0,1,1
103,-2.2168906,1,0,0,0,1,1
104,-.65738457,0,1,0,0,1,1
105,.00074740726,1,0,0,1,1,1
106,1.204085,1,1,1,1,1,1
107,.74587023,1,1,1,0,1,1
108,1.8170407,1,1,1,0,1,1
109,-.35072035,1,1,1,0,1,1
110,-.14632735,1,1,0,0,1,1
111,1.0549366,1,1,1,1,1,1
112,-.011479022,0,0,1,0,1,1
113,.62853611,1,0,1,1,1,1
114,-.33840579,1,0,1,0,1,1
115,-.72323412,1,0,0,1,1,1
116,2.2091029,0,1,0,0,1,1
117,.21428454,1,0,1,0,1,1
118,.66688836,1,1,0,0,1,1
119,-.73199588,1,1,1,0,1,1
120,-.30729398,1,1,0,1,1,1
121,.37092265,0,1,1,1,1,1
122,.6029672,1,1,1,1,1,1
123,.46125323,1,0,0,1,1,1
124,-1.2180696,0,0,0,0,1,1
125,-.51291251,1,1,1,0,1,1
126,-.17254806,1,0,0,0,1,1
127,.46708295,1,1,0,0,1,1
128,-1.153928,1,1,0,0,1,1
129,1.4594103,1,0,0,0,1,1
130,-.45216542,1,0,0,0,1,1
131,.090173036,1,1,0,0,1,1
132,-.25163296,1,0,0,0,1,1
133,.99079025,1,0,1,0,1,1
134,1.9550312,1,1,1,1,1,1
135,-.74238241,1,0,0,0,1,1
136,2.4380329,1,1,1,1,1,1
137,-2.5176644,0,0,0,0,1,1
138,-1.2309995,1,0,0,0,1,1
139,-.90618628,1,0,1,0,1,1
140,-1.6482364,0,0,0,0,1,1
141,-.66502756,1,0,0,0,1,1
142,1.2219602,1,0,1,1,1,1
143,.51810169,0,1,1,1,1,1
144,.33138105,1,0,1,1,1,1
145,.92467684,1,1,1,0,1,1
146,-.47461674,0,0,1,1,1,1
147,1.2050171,1,1,0,0,1,1
148,1.5156882,1,1,0,0,1,1
149,1.5499333,1,1,1,1,1,1
150,-.063660748,1,0,1,1,1,1
151,.27926692,0,0,1,1,1,1
152,1.800284,1,1,1,1,1,1
153,-2.4724929,0,0,0,0,1,1
154,1.4980674,1,1,1,1,1,1
155,1.0834401,1,0,1,0,1,1
156,-.73209035,0,1,0,0,1,1
157,.10514933,1,1,1,1,1,1
158,1.4848051,1,1,1,0,1,1
159,.48073712,0,1,0,1,1,1
160,-1.1459501,1,1,1,0,1,1
161,1.3261594,1,1,0,1,1,1
162,.45268533,0,1,0,1,1,1
163,-2.1466103,0,0,0,1,1,1
164,.036299877,1,0,1,1,1,1
165,1.132494,1,1,0,1,1,1
166,-.74459684,1,1,0,0,1,1
167,-1.3133749,0,0,1,0,1,1
168,.24529886,0,0,0,0,1,1
169,-.047662795,1,1,0,0,1,1
170,1.426119,1,1,1,1,1,1
171,-1.6673079,0,0,0,0,1,1
172,-.47215554,0,0,1,0,1,1
173,-1.1029931,0,1,0,0,1,1
174,.02064253,0,1,0,1,1,1
175,-.7602495,1,1,0,0,1,1
176,-1.225958,1,0,0,0,1,1
177,.062465422,1,1,1,0,1,1
178,-1.7623961,0,0,0,0,1,1
179,-.12828347,1,0,1,0,1,1
180,1.4514505,1,1,1,1,1,1
181,-.80989766,1,0,1,0,1,1
182,.18102278,1,1,1,1,1,1
183,-.89957333,1,1,0,1,1,1
184,1.1199794,1,1,0,1,1,1
185,-.45701504,1,0,1,1,1,1
186,.75216359,1,1,0,0,1,1
187,-1.0642035,1,1,1,0,1,1
188,-.297575,1,1,1,1,1,1
189,1.432634,1,1,1,1,1,1
190,.59969848,1,1,1,0,1,1
191,.38591364,0,0,0,1,1,1
192,-.17246659,0,1,0,0,1,1
193,.024799852,1,1,1,0,1,1
194,-.86773324,1,0,1,0,1,1
195,-1.3454363,0,0,0,0,1,1
196,.60606623,1,1,0,1,1,1
197,1.3981689,1,1,1,1,1,1
198,-.22852357,1,1,0,0,1,1
199,-1.6954113,1,0,0,0,1,1
200,-.48686084,0,1,1,0,1,1
1 id lt1 item1 item2 item3 item4 TT replication
2 1 .17644101 0 0 0 1 0 1
3 2 1.1119704 0 1 1 1 0 1
4 3 -.46370447 0 1 0 1 0 1
5 4 -1.0415101 1 0 1 0 0 1
6 5 -1.2738965 1 0 0 0 0 1
7 6 -.085420959 1 1 0 1 0 1
8 7 1.1056501 1 1 1 1 0 1
9 8 -.32086244 1 0 1 0 0 1
10 9 .54192197 1 0 0 0 0 1
11 10 .49705315 1 1 0 1 0 1
12 11 -.64607531 1 1 0 1 0 1
13 12 .51508766 0 1 1 0 0 1
14 13 .2836611 0 0 0 1 0 1
15 14 -.63813239 1 1 1 0 0 1
16 15 1.4577918 1 1 1 1 0 1
17 16 -.9888711 1 0 1 0 0 1
18 17 -1.8077854 1 0 0 0 0 1
19 18 -.36925948 1 0 0 0 0 1
20 19 .17932144 1 0 0 0 0 1
21 20 -.63588434 0 1 0 1 0 1
22 21 .86244547 0 0 0 0 0 1
23 22 -.44217664 1 0 0 0 0 1
24 23 -.38870588 1 1 1 0 0 1
25 24 .95358348 1 1 0 0 0 1
26 25 -.36753294 1 0 1 0 0 1
27 26 -.63655686 0 0 0 0 0 1
28 27 -.012073237 1 1 1 0 0 1
29 28 -.13124834 1 0 1 0 0 1
30 29 -.14458376 1 0 1 0 0 1
31 30 -.25078735 1 1 0 0 0 1
32 31 -.16138455 1 1 1 0 0 1
33 32 .75585234 1 0 1 1 0 1
34 33 -.60850286 1 0 1 0 0 1
35 34 .79716212 1 0 1 0 0 1
36 35 .45342034 1 1 1 0 0 1
37 36 -2.1057169 0 0 0 0 0 1
38 37 .79157275 1 0 0 1 0 1
39 38 -.66571254 0 1 0 0 0 1
40 39 -.097855851 1 1 0 1 0 1
41 40 1.0418533 1 0 1 1 0 1
42 41 -.46935579 0 0 0 0 0 1
43 42 .63163638 1 1 0 0 0 1
44 43 .085910544 0 1 1 1 0 1
45 44 .83931607 1 0 0 0 0 1
46 45 .50145197 1 1 1 0 0 1
47 46 2.5159037 0 1 1 1 0 1
48 47 -.29928276 1 1 0 0 0 1
49 48 -.52162999 1 1 0 1 0 1
50 49 1.7009553 1 1 1 1 0 1
51 50 -.44088203 1 0 1 0 0 1
52 51 1.5880907 1 1 0 0 0 1
53 52 -.47029325 0 0 0 0 0 1
54 53 1.2277231 1 1 0 1 0 1
55 54 .42639166 1 0 1 1 0 1
56 55 -.95310265 0 0 0 0 0 1
57 56 .64398259 1 0 1 1 0 1
58 57 .18478298 1 1 0 1 0 1
59 58 .82810265 1 0 1 1 0 1
60 59 -.33021048 1 0 0 0 0 1
61 60 -3.170429 0 0 0 0 0 1
62 61 -1.1574296 0 1 1 0 0 1
63 62 1.8837459 1 1 0 0 0 1
64 63 -1.2181894 0 0 0 0 0 1
65 64 1.2980061 1 1 1 1 0 1
66 65 -.32206535 1 1 0 0 0 1
67 66 -.42526674 0 0 0 0 0 1
68 67 1.3604238 0 1 0 1 0 1
69 68 -1.6900293 0 0 0 0 0 1
70 69 .46790454 0 0 1 1 0 1
71 70 .46692941 0 0 0 0 0 1
72 71 -1.4733744 1 0 0 0 0 1
73 72 -.20302044 0 1 1 1 0 1
74 73 -.48481002 0 0 0 0 0 1
75 74 .18501657 0 0 1 0 0 1
76 75 -1.5757569 1 0 0 0 0 1
77 76 .225288 0 0 0 0 0 1
78 77 .40944499 0 1 1 1 0 1
79 78 .03514893 1 1 0 1 0 1
80 79 -2.0809295 0 0 1 0 0 1
81 80 .89514649 1 1 1 0 0 1
82 81 -1.3915017 1 0 0 1 0 1
83 82 .11379968 1 1 0 0 0 1
84 83 1.5646211 1 1 1 1 0 1
85 84 -.31079024 1 0 1 0 0 1
86 85 1.2880181 1 1 1 1 0 1
87 86 -.16200012 1 0 1 0 0 1
88 87 -.26236823 0 1 1 0 0 1
89 88 -.17450906 1 1 0 0 0 1
90 89 -1.8440282 0 0 1 0 0 1
91 90 -.13284066 0 1 0 0 0 1
92 91 1.5515995 1 1 1 1 0 1
93 92 -.78718334 1 0 0 0 0 1
94 93 -.28649214 1 0 1 1 0 1
95 94 .65451664 1 1 0 0 0 1
96 95 .26079011 0 0 0 1 0 1
97 96 1.4207528 1 1 1 0 0 1
98 97 -.36326984 0 1 0 0 0 1
99 98 -.0092543131 1 1 0 1 0 1
100 99 .73671579 0 1 1 1 0 1
101 100 .078362353 1 0 0 1 0 1
102 101 -.24513553 1 1 0 0 1 1
103 102 -.85109341 1 1 1 0 1 1
104 103 -2.2168906 1 0 0 0 1 1
105 104 -.65738457 0 1 0 0 1 1
106 105 .00074740726 1 0 0 1 1 1
107 106 1.204085 1 1 1 1 1 1
108 107 .74587023 1 1 1 0 1 1
109 108 1.8170407 1 1 1 0 1 1
110 109 -.35072035 1 1 1 0 1 1
111 110 -.14632735 1 1 0 0 1 1
112 111 1.0549366 1 1 1 1 1 1
113 112 -.011479022 0 0 1 0 1 1
114 113 .62853611 1 0 1 1 1 1
115 114 -.33840579 1 0 1 0 1 1
116 115 -.72323412 1 0 0 1 1 1
117 116 2.2091029 0 1 0 0 1 1
118 117 .21428454 1 0 1 0 1 1
119 118 .66688836 1 1 0 0 1 1
120 119 -.73199588 1 1 1 0 1 1
121 120 -.30729398 1 1 0 1 1 1
122 121 .37092265 0 1 1 1 1 1
123 122 .6029672 1 1 1 1 1 1
124 123 .46125323 1 0 0 1 1 1
125 124 -1.2180696 0 0 0 0 1 1
126 125 -.51291251 1 1 1 0 1 1
127 126 -.17254806 1 0 0 0 1 1
128 127 .46708295 1 1 0 0 1 1
129 128 -1.153928 1 1 0 0 1 1
130 129 1.4594103 1 0 0 0 1 1
131 130 -.45216542 1 0 0 0 1 1
132 131 .090173036 1 1 0 0 1 1
133 132 -.25163296 1 0 0 0 1 1
134 133 .99079025 1 0 1 0 1 1
135 134 1.9550312 1 1 1 1 1 1
136 135 -.74238241 1 0 0 0 1 1
137 136 2.4380329 1 1 1 1 1 1
138 137 -2.5176644 0 0 0 0 1 1
139 138 -1.2309995 1 0 0 0 1 1
140 139 -.90618628 1 0 1 0 1 1
141 140 -1.6482364 0 0 0 0 1 1
142 141 -.66502756 1 0 0 0 1 1
143 142 1.2219602 1 0 1 1 1 1
144 143 .51810169 0 1 1 1 1 1
145 144 .33138105 1 0 1 1 1 1
146 145 .92467684 1 1 1 0 1 1
147 146 -.47461674 0 0 1 1 1 1
148 147 1.2050171 1 1 0 0 1 1
149 148 1.5156882 1 1 0 0 1 1
150 149 1.5499333 1 1 1 1 1 1
151 150 -.063660748 1 0 1 1 1 1
152 151 .27926692 0 0 1 1 1 1
153 152 1.800284 1 1 1 1 1 1
154 153 -2.4724929 0 0 0 0 1 1
155 154 1.4980674 1 1 1 1 1 1
156 155 1.0834401 1 0 1 0 1 1
157 156 -.73209035 0 1 0 0 1 1
158 157 .10514933 1 1 1 1 1 1
159 158 1.4848051 1 1 1 0 1 1
160 159 .48073712 0 1 0 1 1 1
161 160 -1.1459501 1 1 1 0 1 1
162 161 1.3261594 1 1 0 1 1 1
163 162 .45268533 0 1 0 1 1 1
164 163 -2.1466103 0 0 0 1 1 1
165 164 .036299877 1 0 1 1 1 1
166 165 1.132494 1 1 0 1 1 1
167 166 -.74459684 1 1 0 0 1 1
168 167 -1.3133749 0 0 1 0 1 1
169 168 .24529886 0 0 0 0 1 1
170 169 -.047662795 1 1 0 0 1 1
171 170 1.426119 1 1 1 1 1 1
172 171 -1.6673079 0 0 0 0 1 1
173 172 -.47215554 0 0 1 0 1 1
174 173 -1.1029931 0 1 0 0 1 1
175 174 .02064253 0 1 0 1 1 1
176 175 -.7602495 1 1 0 0 1 1
177 176 -1.225958 1 0 0 0 1 1
178 177 .062465422 1 1 1 0 1 1
179 178 -1.7623961 0 0 0 0 1 1
180 179 -.12828347 1 0 1 0 1 1
181 180 1.4514505 1 1 1 1 1 1
182 181 -.80989766 1 0 1 0 1 1
183 182 .18102278 1 1 1 1 1 1
184 183 -.89957333 1 1 0 1 1 1
185 184 1.1199794 1 1 0 1 1 1
186 185 -.45701504 1 0 1 1 1 1
187 186 .75216359 1 1 0 0 1 1
188 187 -1.0642035 1 1 1 0 1 1
189 188 -.297575 1 1 1 1 1 1
190 189 1.432634 1 1 1 1 1 1
191 190 .59969848 1 1 1 0 1 1
192 191 .38591364 0 0 0 1 1 1
193 192 -.17246659 0 1 0 0 1 1
194 193 .024799852 1 1 1 0 1 1
195 194 -.86773324 1 0 1 0 1 1
196 195 -1.3454363 0 0 0 0 1 1
197 196 .60606623 1 1 0 1 1 1
198 197 1.3981689 1 1 1 1 1 1
199 198 -.22852357 1 1 0 0 1 1
200 199 -1.6954113 1 0 0 0 1 1
201 200 -.48686084 0 1 1 0 1 1

@ -112,12 +112,6 @@ if "`dim'"!="" {
local nbdiff:word count `diff'
}
}
else if "`dim'"==""{
if "`diff'"==""&"`pcm'"=="" {
di in red "{p 0 0 0}You must indicate the number of items to simulate with the {hi:dim}, the {hi:pcm} or the {hi:diff} option(s)."
@ -151,8 +145,6 @@ if (`group'!=0|`deltagroup'!=0)&`dim'!=1 {
exit
}
if "`prefix'"=="" {
local prefix item
}
@ -174,17 +166,6 @@ else {
local prefix`d' `prefix'`tmp'
}
}
if "`covmatrix'"=="" {
tempname covmatrix2
local nbcov:word count `cov'
@ -204,15 +185,6 @@ if "`covmatrix'"=="" {
}
matrix `covmatrix2'=(`cov')
}
else if `dim'==2 {
if `nbcov'!=3&`nbcov'>0 {
di in red "You simulate two dimensions. You must indicate exactly 3 values in the {hi:cov} option (Variance of the first simulated latent trait, Variance of the second simulated latent trait, Covariance between the two simulated latent traits)."
@ -244,13 +216,6 @@ if "`covmatrix'"=="" {
local covmatrix `covmatrix2'
}
local nbmu:word count `mu'
if `nbmu'!=`dim'&`nbmu'!=0 {
di in red "You must indicate as many values in the {hi:mu} option as the number of dimension(s) (`dim')"
@ -345,10 +310,6 @@ while $seed>2^31-1 {
qui set seed $seed
if "`typediff'"=="uniform" {
if `nbdiff'==`=`dim'*2+1' {
local min`d':word `=(`d'-1)*2+2' of `diff'
@ -369,14 +330,6 @@ if "`typediff'"=="uniform" {
}
}
}
else if "`typediff'"=="gauss" {
if `nbdiff'==`=`dim'*2+1' {
forvalues d=1/`dim' {
@ -404,12 +357,6 @@ else if "`typediff'"=="gauss" {
}
}
forvalues d=1/`dim' {
if "`rsm`d''"!="" {
local nbrsm`d':word count `rsm`d''
@ -452,21 +399,6 @@ forvalues i=1/`nbitems'{
}
}
if "`pcm'"==""|"`rsm1'"!="" {
tempname pcm
if "`rsm1'"=="" {
@ -582,7 +514,7 @@ local names
forvalues d=1/`dim' {
qui gen x`d'=invnorm(uniform())
qui compress
local names `names' lt`d' /*En R: names <- c(names,paste('lt',d)) */
local names `names' lt`d'
}
matrix Chol=cholesky(corr(`covmatrix'))

@ -19,11 +19,13 @@ generate_diff_irt <- function(J=7,M=4) {
for (j in 1:J){
difficulties[j,1] = qnorm(j/(J+1))
}
if (M>2) {
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)
}
@ -36,4 +38,9 @@ generate_diff_irt <- function(J=7,M=4) {
# GENERATE MATRIX FOR SIMULATION
###################################################
generate_diff_irt(J=4,M=2)
generate_diff_irt(J=4,M=4)
generate_diff_irt(J=7,M=2)
generate_diff_irt(J=7,M=4)

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save