GLM: remove warning
[pspp] / tests / language / stats / glm.at
1 AT_BANNER([GLM procedure])
2
3 AT_SETUP([GLM latin square design])
4
5 dnl This example comes from :
6 dnl  http://ssnds.uwo.ca/statsexamples/spssanova/latinsquareresults.html
7 AT_DATA([latin.sps], [dnl
8 set format = F20.3.
9 data list notable  fixed /a 1 b 3 c 5 y 7-10(2).
10 begin data.
11 1 1 6  3.5
12 1 2 2  8.9
13 1 3 3  9.6
14 1 4 4 10.5
15 1 5 5  3.1
16 1 6 1  5.9
17 2 1 2  4.2
18 2 2 6  1.9
19 2 3 5  3.7
20 2 4 3 10.2
21 2 5 1  7.2
22 2 6 4  7.6
23 3 1 1  6.7
24 3 2 4  5.8
25 3 3 6 -2.7
26 3 4 2  4.6
27 3 5 3  4.0
28 3 6 5 -0.7
29 4 1 4  6.6
30 4 2 1  4.5
31 4 3 2  3.7
32 4 4 5  3.7
33 4 5 6 -3.3
34 4 6 3  3.0
35 5 1 3  4.1
36 5 2 5  2.4
37 5 3 4  6.0
38 5 4 1  5.1
39 5 5 2  3.5
40 5 6 6  4.0
41 6 1 5  3.8
42 6 2 3  5.8
43 6 3 1  7.0
44 6 4 6  3.8
45 6 5 4  5.0
46 6 6 2  8.6
47 end data.
48
49 variable labels a 'Factor A' b 'Factor B' c 'Factor C' y 'Criterion'.
50
51 glm y by   b a c
52   /intercept=include
53   /criteria=alpha(.05)
54   /design = a b c
55   .
56 ])
57
58 AT_CHECK([pspp -O format=csv latin.sps | sed 's/329.62[[678]]/329.62/'], [0],
59   [dnl
60 Table: Tests of Between-Subjects Effects
61 Source,Type III Sum of Squares,df,Mean Square,F,Sig.
62 Corrected Model,263.064,15,17.538,5.269,.000
63 Intercept,815.103,1,815.103,244.910,.000
64 Factor A,78.869,5,15.774,4.739,.005
65 Factor B,28.599,5,5.720,1.719,.176
66 Factor C,155.596,5,31.119,9.350,.000
67 Error,66.563,20,3.328,,
68 Total,1144.730,36,,,
69 Corrected Total,329.62,35,,,
70 ])
71
72 AT_CLEANUP
73
74 AT_SETUP([GLM 2 by 2 factorial design])
75
76 AT_DATA([2by2.sps], [dnl
77 set format = F20.3.
78 data list notable  list /Factor0 * Factor1 * points (F10).
79 begin data.
80 1       4       332
81 1       4       380
82 1       4       371
83 1       4       366
84 1       4       354
85 1       0       259.5
86 1       0       302.5
87 1       0       296
88 1       0       349
89 1       0       309
90 2       4       354.67
91 2       4       353.5
92 2       4       304
93 2       4       365
94 2       4       339
95 2       0       306
96 2       0       339
97 2       0       353
98 2       0       351
99 2       0       333
100 end data.
101
102 glm points by Factor0 Factor1
103   /intercept=include
104   /criteria=alpha(.05)
105   .
106 ])
107
108
109 AT_CHECK([pspp -O format=csv 2by2.sps ], [0],
110   [dnl
111 Table: Tests of Between-Subjects Effects
112 Source,Type III Sum of Squares,df,Mean Square,F,Sig.
113 Corrected Model,8667.053,3,2889.018,5.043,.012
114 Intercept,2256018.640,1,2256018.640,3937.693,.000
115 Factor0,313.394,1,313.394,.547,.470
116 Factor1,5157.508,1,5157.508,9.002,.008
117 Factor0 * Factor1,3196.150,1,3196.150,5.579,.031
118 Error,9166.865,16,572.929,,
119 Total,2273852.559,20,,,
120 Corrected Total,17833.918,19,,,
121 ])
122
123 AT_CLEANUP
124
125
126 AT_SETUP([GLM Type I and II Sums of Squares])
127
128 dnl  The following example comes from 
129 dnl  http://www.uvm.edu/~dhowell/StatPages/More_Stuff/Type1-3.pdf
130 AT_DATA([data-inc.sps], [dnl
131 set decimal = dot.
132 set format=F20.3.
133 data list notable list /dv * Agrp * B0 * B1 * B2 * i0 * i1 * i2 * sss *.
134 begin data.
135 5   1  1  0  0  1  0  0 1.00
136 7   1  1  0  0  1  0  0 1.00
137 9   1  1  0  0  1  0  0 1.00
138 8   1  1  0  0  1  0  0 1.00
139 2   1  0  1  0  0  1  0 1.00
140 5   1  0  1  0  0  1  0 1.00
141 7   1  0  1  0  0  1  0 1.00
142 3   1  0  1  0  0  1  0 1.00
143 9   1  0  1  0  0  1  0 1.00
144 8   1  0  0  1  0  0  1 1.00
145 11  1  0  0  1  0  0  1 1.00
146 12  1  0  0  1  0  0  1 1.00
147 14  1  0  0  1  0  0  1 1.00
148 11  1 -1 -1 -1 -1 -1 -1 1.00
149 15  1 -1 -1 -1 -1 -1 -1 1.00
150 16  1 -1 -1 -1 -1 -1 -1 1.00
151 10  1 -1 -1 -1 -1 -1 -1 1.00
152 9   1 -1 -1 -1 -1 -1 -1 1.00
153 7  -1  1  0  0 -1  0  0 2.00
154 9  -1  1  0  0 -1  0  0 2.00
155 10 -1  1  0  0 -1  0  0 2.00
156 9  -1  1  0  0 -1  0  0 2.00
157 3  -1  0  1  0  0 -1  0 2.00
158 8  -1  0  1  0  0 -1  0 2.00
159 9  -1  0  1  0  0 -1  0 2.00
160 11 -1  0  1  0  0 -1  0 2.00
161 9  -1  0  0  1  0  0 -1 2.00
162 12 -1  0  0  1  0  0 -1 2.00
163 14 -1  0  0  1  0  0 -1 2.00
164 8  -1  0  0  1  0  0 -1 2.00
165 7  -1  0  0  1  0  0 -1 2.00
166 11 -1 -1 -1 -1  1  1  1 2.00
167 14 -1 -1 -1 -1  1  1  1 2.00
168 10 -1 -1 -1 -1  1  1  1 2.00
169 12 -1 -1 -1 -1  1  1  1 2.00
170 13 -1 -1 -1 -1  1  1  1 2.00
171 11 -1 -1 -1 -1  1  1  1 2.00
172 12 -1 -1 -1 -1  1  1  1 2.00
173 end data.
174
175 do if B0 = -1 AND B1 = -1 AND B2 = -1.
176 compute Bgrp = 4.
177 end if.
178
179 do if B0 = 0 AND B1 = 0 AND B2 = 1.
180 compute Bgrp = 3.
181 end if.
182
183 do if B0 = 0 AND B1 = 1 AND B2 = 0.
184 compute Bgrp = 2.
185 end if.
186
187 do if B0 = 1 AND B1 = 0 AND B2 = 0.
188 compute Bgrp = 1.
189 end if.
190 ])
191
192 AT_DATA([type1.sps], [dnl
193 include 'data-inc.sps'.
194
195 glm dv by Agrp Bgrp
196         /method = sstype (1)
197         .
198
199 glm dv by Agrp Bgrp
200         /method = sstype (1)
201         /design Bgrp Agrp Bgrp * Agrp
202         .
203 ])
204
205
206 AT_CHECK([pspp -O format=csv type1.sps], [0],
207   [dnl
208 Table: Tests of Between-Subjects Effects
209 Source,Type I Sum of Squares,df,Mean Square,F,Sig.
210 Corrected Model,216.017,7,30.860,5.046,.001
211 Intercept,,,,,
212 Agrp,9.579,1,9.579,1.566,.220
213 Bgrp,186.225,3,62.075,10.151,.000
214 Agrp * Bgrp,20.212,3,6.737,1.102,.364
215 Error,183.457,30,6.115,,
216 Total,3810.000,38,,,
217 Corrected Total,399.474,37,,,
218
219 Table: Tests of Between-Subjects Effects
220 Source,Type I Sum of Squares,df,Mean Square,F,Sig.
221 Corrected Model,216.017,7,30.860,5.046,.001
222 Intercept,,,,,
223 Bgrp,193.251,3,64.417,10.534,.000
224 Agrp,2.553,1,2.553,.418,.523
225 Bgrp * Agrp,20.212,3,6.737,1.102,.364
226 Error,183.457,30,6.115,,
227 Total,3810.000,38,,,
228 Corrected Total,399.474,37,,,
229 ])
230
231
232 AT_DATA([type2.sps], [dnl
233 include 'data-inc.sps'.
234
235 glm dv by Agrp Bgrp
236         /method = sstype (2)
237         .
238 ])
239
240
241 AT_CHECK([pspp -O format=csv type2.sps], [0],
242   [dnl
243 Table: Tests of Between-Subjects Effects
244 Source,Type II Sum of Squares,df,Mean Square,F,Sig.
245 Corrected Model,216.017,7,30.860,5.046,.001
246 Intercept,,,,,
247 Agrp,2.553,1,2.553,.418,.523
248 Bgrp,186.225,3,62.075,10.151,.000
249 Agrp * Bgrp,20.212,3,6.737,1.102,.364
250 Error,183.457,30,6.115,,
251 Total,3810.000,38,,,
252 Corrected Total,399.474,37,,,
253 ])
254
255 AT_CLEANUP
256
257
258
259 AT_SETUP([GLM excluded intercept])
260
261 dnl  The following example comes from 
262 dnl
263 dnl Rudolf N. Cardinal
264 dnl Graduate-level statistics for psychology and neuroscience
265 dnl ANOVA in practice, and complex ANOVA designs
266 dnl Version of 2 May 2004
267 dnl
268 dnl Downloaded from: http://egret.psychol.cam.ac.uk/psychology/graduate/Guide_to_ANOVA.pdf
269
270 AT_DATA([intercept-exclude.sps], [dnl
271 set format = F20.3.
272
273 data list notable list /depvar * A *.
274 begin data.
275 10     1
276 14     1
277 8      1
278 7      1
279 2      1
280 10     1
281 1      1
282 3      1
283 2      1
284 8.5    1
285 14.29  2
286 18.49  2
287 12.46  2
288 11.63  2
289 6.66   2
290 14.02  2
291 5.66   2
292 7.06   2
293 6.37   2
294 13.26  2
295 end data.
296
297 GLM depvar by A
298    /intercept = exclude
299   .
300
301
302 GLM depvar by A
303    /intercept = include
304   .
305
306 ])
307
308 AT_CHECK([pspp -O format=csv intercept-exclude.sps], [0],
309   [dnl
310 Table: Tests of Between-Subjects Effects
311 Source,Type III Sum of Squares,df,Mean Square,F,Sig.
312 Model,1636.826,2,818.413,43.556,.000
313 A,1636.826,2,818.413,43.556,.000
314 Error,338.216,18,18.790,,
315 Total,1975.042,20,,,
316
317 Table: Tests of Between-Subjects Effects
318 Source,Type III Sum of Squares,df,Mean Square,F,Sig.
319 Corrected Model,98.568,1,98.568,5.246,.034
320 Intercept,1538.258,1,1538.258,81.867,.000
321 A,98.568,1,98.568,5.246,.034
322 Error,338.216,18,18.790,,
323 Total,1975.042,20,,,
324 Corrected Total,436.784,19,,,
325 ])
326
327 AT_CLEANUP
328