CROSSTABS: Add test to verify treatment of ties.
[pspp] / tests / language / stats / crosstabs.at
1 AT_BANNER([CROSSTABS procedure])
2
3 AT_SETUP([CROSSTABS integer mode crash])
4 AT_DATA([crosstabs.sps],
5   [DATA LIST LIST /A * B * X * Y * .
6 BEGIN DATA.
7 2 3 4 5
8 END DATA.
9
10 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
11 ])
12 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], 
13   [[Table: Reading free-form data from INLINE.
14 Variable,Format
15 A,F8.0
16 B,F8.0
17 X,F8.0
18 Y,F8.0
19
20 Table: Summary.
21 ,Cases,,,,,
22 ,Valid,,Missing,,Total,
23 ,N,Percent,N,Percent,N,Percent
24 X * Y,1,100.0%,0,0.0%,1,100.0%
25
26 Table: X * Y [count].
27 ,Y,,,,,,,
28 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
29 1.00,.00,.00,.00,.00,.00,.00,.00,.00
30 2.00,.00,.00,.00,.00,.00,.00,.00,.00
31 3.00,.00,.00,.00,.00,.00,.00,.00,.00
32 4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
33 5.00,.00,.00,.00,.00,.00,.00,.00,.00
34 6.00,.00,.00,.00,.00,.00,.00,.00,.00
35 7.00,.00,.00,.00,.00,.00,.00,.00,.00
36 Total,.00,.00,.00,.00,1.00,.00,.00,1.00
37 ]])
38 AT_CLEANUP
39
40 # Bug #22037.
41 AT_SETUP([CROSSTABS long string crash])
42 AT_DATA([crosstabs.sps],
43   [data list list /x * y (a18).
44
45 begin data.
46
47    1. 'zero none'
48
49 1 'one unity'
50 2 'two duality'
51 3 'three lots'
52 end data.
53
54 CROSSTABS /TABLES = x BY y.
55 ])
56 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
57   [[Table: Reading free-form data from INLINE.
58 Variable,Format
59 x,F8.0
60 y,A18
61
62 "crosstabs.sps:4: warning: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
63
64 "crosstabs.sps:6: warning: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
65
66 Table: Summary.
67 ,Cases,,,,,
68 ,Valid,,Missing,,Total,
69 ,N,Percent,N,Percent,N,Percent
70 x * y,4,66.7%,2,33.3%,6,100.0%
71
72 Table: x * y [count].
73 ,y,,,,
74 x,one unity         ,three lots        ,two duality       ,zero none         ,Total
75 1.00,1.00,.00,.00,1.00,2.00
76 2.00,.00,.00,1.00,.00,1.00
77 3.00,.00,1.00,.00,.00,1.00
78 Total,1.00,1.00,1.00,1.00,4.00
79 ]])
80 AT_CLEANUP
81
82 AT_SETUP([CROSSTABS crash])
83 AT_DATA([crosstabs.sps],
84   [[DATA LIST FIXED
85      / x   1-2
86        y   3
87        z   4.
88
89 BEGIN DATA.
90 0111 
91 0222 
92 0311 
93 0412 
94 0521 
95 0612 
96 0711 
97 0811 
98 0912 
99 END DATA.
100
101 LIST.
102
103
104 CROSSTABS TABLES  y by z.
105 ]])
106 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
107   [[Table: Reading 1 record from INLINE.
108 Variable,Record,Columns,Format
109 x,1,1-  2,F2.0
110 y,1,3-  3,F1.0
111 z,1,4-  4,F1.0
112
113 Table: Data List
114 x,y,z
115 1,1,1
116 2,2,2
117 3,1,1
118 4,1,2
119 5,2,1
120 6,1,2
121 7,1,1
122 8,1,1
123 9,1,2
124
125 Table: Summary.
126 ,Cases,,,,,
127 ,Valid,,Missing,,Total,
128 ,N,Percent,N,Percent,N,Percent
129 y * z,9,100.0%,0,0.0%,9,100.0%
130
131 Table: y * z [count].
132 ,z,,
133 y,1,2,Total
134 1,4.00,3.00,7.00
135 2,1.00,1.00,2.00
136 Total,5.00,4.00,9.00
137 ]])
138 AT_CLEANUP
139
140 # Bug #26739, which caused CROSSTABS to crash or to fail to output
141 # chi-square results.
142 AT_SETUP([CROSSTABS chi-square crash])
143 AT_DATA([crosstabs.sps],
144   [[DATA LIST LIST /x * y *.
145 BEGIN DATA.
146 2 2
147 3 1
148 4 2
149 4 1
150 END DATA.
151
152 CROSSTABS
153         /TABLES= x BY y
154         /STATISTICS=CHISQ.
155 ]])
156 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
157   [[Table: Reading free-form data from INLINE.
158 Variable,Format
159 x,F8.0
160 y,F8.0
161
162 Table: Summary.
163 ,Cases,,,,,
164 ,Valid,,Missing,,Total,
165 ,N,Percent,N,Percent,N,Percent
166 x * y,4,100.0%,0,0.0%,4,100.0%
167
168 Table: x * y [count].
169 ,y,,
170 x,1.00,2.00,Total
171 2.00,.00,1.00,1.00
172 3.00,1.00,.00,1.00
173 4.00,1.00,1.00,2.00
174 Total,2.00,2.00,4.00
175
176 Table: Chi-square tests.
177 Statistic,Value,df,Asymp. Sig. (2-tailed)
178 Pearson Chi-Square,2.00,2,.368
179 Likelihood Ratio,2.77,2,.250
180 Linear-by-Linear Association,.27,1,.602
181 N of Valid Cases,4,,
182 ]])
183 AT_CLEANUP
184
185 # Bug #27883.
186 AT_SETUP([CROSSTABS crash with SPLIT FILE])
187 AT_DATA([crosstabs.sps],
188   [data list notable / v0 to v2 1-6 (A)
189 begin data.
190 a c e
191 a c e
192 a c e
193 a d e
194 a d f
195 b d f
196 b d f
197 b c f
198 b d e
199 a c f
200 end data.
201 SORT CASES BY v0.
202 SPLIT FILE SEPARATE BY v0.
203
204 CROSSTABS
205     /TABLES= v1 BY v2
206     /FORMAT=AVALUE TABLES PIVOT
207     /STATISTICS=CHISQ
208     /CELLS=COUNT ROW COLUMN TOTAL.
209 ])
210
211 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
212   [[Variable,Value,Label
213 v0,a ,
214
215 Table: Summary.
216 ,Cases,,,,,
217 ,Valid,,Missing,,Total,
218 ,N,Percent,N,Percent,N,Percent
219 v1 * v2,6,100.0%,0,0.0%,6,100.0%
220
221 "Table: v1 * v2 [count, row %, column %, total %]."
222 ,v2,,
223 v1,e ,f ,Total
224 c ,3.00,1.00,4.00
225 ,75.00%,25.00%,100.00%
226 ,75.00%,50.00%,66.67%
227 ,50.00%,16.67%,66.67%
228 d ,1.00,1.00,2.00
229 ,50.00%,50.00%,100.00%
230 ,25.00%,50.00%,33.33%
231 ,16.67%,16.67%,33.33%
232 Total,4.00,2.00,6.00
233 ,66.67%,33.33%,100.00%
234 ,100.00%,100.00%,100.00%
235 ,66.67%,33.33%,100.00%
236
237 Table: Chi-square tests.
238 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
239 Pearson Chi-Square,.38,1,.540,,
240 Likelihood Ratio,.37,1,.545,,
241 Fisher's Exact Test,,,,1.000,.600
242 Continuity Correction,.00,1,1.000,,
243 N of Valid Cases,6,,,,
244
245 Variable,Value,Label
246 v0,b ,
247
248 Table: Summary.
249 ,Cases,,,,,
250 ,Valid,,Missing,,Total,
251 ,N,Percent,N,Percent,N,Percent
252 v1 * v2,4,100.0%,0,0.0%,4,100.0%
253
254 "Table: v1 * v2 [count, row %, column %, total %]."
255 ,v2,,
256 v1,e ,f ,Total
257 c ,.00,1.00,1.00
258 ,.00%,100.00%,100.00%
259 ,.00%,33.33%,25.00%
260 ,.00%,25.00%,25.00%
261 d ,1.00,2.00,3.00
262 ,33.33%,66.67%,100.00%
263 ,100.00%,66.67%,75.00%
264 ,25.00%,50.00%,75.00%
265 Total,1.00,3.00,4.00
266 ,25.00%,75.00%,100.00%
267 ,100.00%,100.00%,100.00%
268 ,25.00%,75.00%,100.00%
269
270 Table: Chi-square tests.
271 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
272 Pearson Chi-Square,.44,1,.505,,
273 Likelihood Ratio,.68,1,.410,,
274 Fisher's Exact Test,,,,1.000,.750
275 Continuity Correction,.00,1,1.000,,
276 N of Valid Cases,4,,,,
277 ]])
278 AT_CLEANUP
279
280 # Bug #24752.
281 AT_SETUP([3-way CROSSTABS])
282 AT_DATA([crosstabs.sps],
283   [[DATA LIST FIXED
284      / x   1-2
285        y   3
286        z   4.
287
288 BEGIN DATA.
289 0111 
290 0222 
291 0311 
292 0412 
293 0521 
294 0612 
295 0711 
296 0811 
297 0912 
298 END DATA.
299
300 LIST.
301
302
303 CROSSTABS TABLES  x BY y BY z/STATISTICS=ALL.
304 ]])
305 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
306   [[Table: Reading 1 record from INLINE.
307 Variable,Record,Columns,Format
308 x,1,1-  2,F2.0
309 y,1,3-  3,F1.0
310 z,1,4-  4,F1.0
311
312 Table: Data List
313 x,y,z
314 1,1,1
315 2,2,2
316 3,1,1
317 4,1,2
318 5,2,1
319 6,1,2
320 7,1,1
321 8,1,1
322 9,1,2
323
324 Table: Summary.
325 ,Cases,,,,,
326 ,Valid,,Missing,,Total,
327 ,N,Percent,N,Percent,N,Percent
328 x * y * z,9,100.0%,0,0.0%,9,100.0%
329
330 Table: x * y * z [count].
331 z,,y,,
332 ,x,1,2,Total
333 1,1,1.00,.00,1.00
334 ,3,1.00,.00,1.00
335 ,5,.00,1.00,1.00
336 ,7,1.00,.00,1.00
337 ,8,1.00,.00,1.00
338 Total,,4.00,1.00,5.00
339 2,2,.00,1.00,1.00
340 ,4,1.00,.00,1.00
341 ,6,1.00,.00,1.00
342 ,9,1.00,.00,1.00
343 Total,,3.00,1.00,4.00
344
345 Table: Chi-square tests.
346 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
347 1,Pearson Chi-Square,5.00,4,.287
348 ,Likelihood Ratio,5.00,4,.287
349 ,Linear-by-Linear Association,.01,1,.938
350 ,N of Valid Cases,5,,
351 2,Pearson Chi-Square,4.00,3,.261
352 ,Likelihood Ratio,4.50,3,.212
353 ,Linear-by-Linear Association,1.58,1,.209
354 ,N of Valid Cases,4,,
355
356 Table: Symmetric measures.
357 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
358 1,Nominal by Nominal,Phi,1.00,,,
359 ,,Cramer's V,1.00,,,
360 ,,Contingency Coefficient,.71,,,
361 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
362 ,,Kendall's tau-c,.00,.32,.00,
363 ,,Gamma,.00,.50,.00,
364 ,,Spearman Correlation,.00,.22,.00,
365 ,Interval by Interval,Pearson's R,.04,.22,.07,
366 ,N of Valid Cases,,5,,,
367 2,Nominal by Nominal,Phi,1.00,,,
368 ,,Cramer's V,1.00,,,
369 ,,Contingency Coefficient,.71,,,
370 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
371 ,,Kendall's tau-c,-.75,.43,-1.73,
372 ,,Gamma,-1.00,.00,-1.73,
373 ,,Spearman Correlation,-.77,.17,-1.73,
374 ,Interval by Interval,Pearson's R,-.73,.18,-1.49,
375 ,N of Valid Cases,,4,,,
376
377 Table: Directional measures.
378 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
379 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
380 ,,,x Dependent,.25,.22,1.12,.264
381 ,,,y Dependent,1.00,.00,1.12,.264
382 ,,Goodman and Kruskal tau,x Dependent,.25,,,.   @&t@
383 ,,,y Dependent,1.00,,,.   @&t@
384 ,,Uncertainty Coefficient,Symmetric,.47,.18,,.   @&t@
385 ,,,x Dependent,.31,.15,2.02,.   @&t@
386 ,,,y Dependent,1.00,.00,2.02,.   @&t@
387 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
388 ,,,x Dependent,.00,.50,.00,1.000
389 ,,,y Dependent,.00,.20,.00,1.000
390 ,Nominal by Interval,Eta,x Dependent,.04,,,.   @&t@
391 ,,,y Dependent,1.00,,,.   @&t@
392 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
393 ,,,x Dependent,.33,.27,1.15,.248
394 ,,,y Dependent,1.00,.00,1.15,.248
395 ,,Goodman and Kruskal tau,x Dependent,.33,,,.   @&t@
396 ,,,y Dependent,1.00,,,.   @&t@
397 ,,Uncertainty Coefficient,Symmetric,.58,.17,,.   @&t@
398 ,,,x Dependent,.41,.17,2.36,.   @&t@
399 ,,,y Dependent,1.00,.00,2.36,.   @&t@
400 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
401 ,,,x Dependent,-1.00,.00,-1.73,.083
402 ,,,y Dependent,-.50,.29,-1.73,.083
403 ,Nominal by Interval,Eta,x Dependent,.73,,,.   @&t@
404 ,,,y Dependent,1.00,,,.   @&t@
405 ]])
406 AT_CLEANUP
407
408
409
410 AT_SETUP([CROSSTABS descending sort order])
411 AT_DATA([crosstabs-descending.sps],
412   [[DATA LIST NOTABLE LIST /x * y *.
413 BEGIN DATA.
414 2 2
415 2 2
416 3 1
417 4 1
418 3 2
419 3 2
420 END DATA.
421
422 CROSSTABS
423         /TABLES= x BY y
424         /FORMAT = DVALUE.
425 ]])
426
427 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
428   [[Table: Summary.
429 ,Cases,,,,,
430 ,Valid,,Missing,,Total,
431 ,N,Percent,N,Percent,N,Percent
432 x * y,6,100.0%,0,0.0%,6,100.0%
433
434 Table: x * y [count].
435 ,y,,
436 x,2.00,1.00,Total
437 4.00,.00,1.00,1.00
438 3.00,2.00,1.00,3.00
439 2.00,2.00,.00,2.00
440 Total,4.00,2.00,6.00
441 ]])
442 AT_CLEANUP
443
444 # Bug #31260.
445 AT_SETUP([CROSSTABS crash when all cases missing])
446 AT_DATA([crosstabs.sps], [dnl
447 DATA LIST LIST NOTABLE /X1 X2.
448 BEGIN DATA.
449 1 1
450 END DATA.
451
452 MISSING VALUES x2 (1).
453
454 CROSSTABS /TABLES= X1 by X2.
455 ])
456 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
457 Table: Summary.
458 ,Cases,,,,,
459 ,Valid,,Missing,,Total,
460 ,N,Percent,N,Percent,N,Percent
461 X1 * X2,0,0.0%,1,100.0%,1,100.0%
462
463 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
464 ])
465 AT_CLEANUP
466
467
468
469 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
470 AT_SETUP([CROSSTABS Fisher Exact Test])
471
472 AT_DATA([fisher-exact.sps], [dnl
473 SET FORMAT F12.3.
474 SET DECIMAL DOT.
475
476 DATA LIST notable LIST  /schtyp (F9.2) female (F9.2) ses (F9.2) .
477 begin data.
478       1.00       .00      1.00 
479       1.00      1.00      2.00 
480       1.00       .00      3.00 
481       1.00       .00      3.00 
482       1.00       .00      2.00 
483       1.00       .00      2.00 
484       1.00       .00      2.00 
485       1.00       .00      2.00 
486       1.00       .00      2.00 
487       1.00       .00      2.00 
488       1.00       .00      2.00 
489       1.00       .00      2.00 
490       1.00       .00      3.00 
491       1.00       .00      3.00 
492       1.00       .00      1.00 
493       1.00       .00      1.00 
494       1.00       .00      3.00 
495       2.00       .00      2.00 
496       1.00       .00      3.00 
497       1.00       .00      2.00 
498       1.00       .00      2.00 
499       1.00       .00      2.00 
500       1.00       .00      2.00 
501       1.00       .00      3.00 
502       1.00       .00      2.00 
503       1.00       .00      2.00 
504       1.00       .00      3.00 
505       2.00       .00      2.00 
506       2.00       .00      3.00 
507       1.00       .00      1.00 
508       1.00       .00      2.00 
509       1.00       .00      3.00 
510       2.00       .00      3.00 
511       1.00       .00      2.00 
512       2.00       .00      3.00 
513       1.00       .00      3.00 
514       2.00       .00      2.00 
515       1.00       .00      3.00 
516       1.00       .00      1.00 
517       1.00       .00      2.00 
518       2.00       .00      2.00 
519       2.00       .00      2.00 
520       1.00       .00      2.00 
521       1.00       .00      1.00 
522       1.00       .00      3.00 
523       1.00       .00      1.00 
524       1.00       .00      3.00 
525       1.00       .00      2.00 
526       2.00       .00      2.00 
527       1.00       .00      2.00 
528       1.00       .00      2.00 
529       1.00       .00      3.00 
530       1.00       .00      2.00 
531       2.00       .00      2.00 
532       1.00       .00      2.00 
533       1.00       .00      3.00 
534       1.00       .00      1.00 
535       1.00       .00      2.00 
536       2.00       .00      2.00 
537       1.00       .00      2.00 
538       2.00       .00      2.00 
539       1.00       .00      3.00 
540       1.00       .00      1.00 
541       1.00       .00      2.00 
542       2.00       .00      3.00 
543       1.00       .00      2.00 
544       1.00       .00      2.00 
545       1.00       .00      1.00 
546       1.00       .00      1.00 
547       1.00       .00      2.00 
548       1.00       .00      2.00 
549       1.00       .00      3.00 
550       1.00       .00      2.00 
551       1.00       .00      2.00 
552       1.00       .00      2.00 
553       1.00       .00      1.00 
554       1.00       .00      3.00 
555       1.00       .00      3.00 
556       1.00       .00      2.00 
557       1.00       .00      3.00 
558       1.00       .00      3.00 
559       1.00       .00      1.00 
560       2.00       .00      2.00 
561       1.00       .00      1.00 
562       1.00       .00      2.00 
563       1.00       .00      3.00 
564       1.00       .00      3.00 
565       1.00       .00      3.00 
566       1.00       .00      2.00 
567       1.00       .00      3.00 
568       1.00       .00      2.00 
569       1.00       .00      1.00 
570       1.00      1.00      3.00 
571       1.00      1.00      1.00 
572       1.00      1.00      1.00 
573       1.00      1.00      1.00 
574       1.00      1.00      2.00 
575       1.00      1.00      3.00 
576       1.00      1.00      1.00 
577       2.00      1.00      3.00 
578       1.00      1.00      3.00 
579       1.00      1.00      3.00 
580       1.00      1.00      1.00 
581       1.00      1.00      3.00 
582       1.00      1.00      2.00 
583       1.00      1.00      2.00 
584       1.00      1.00      3.00 
585       1.00      1.00      1.00 
586       2.00      1.00      1.00 
587       2.00      1.00      3.00 
588       1.00      1.00      2.00 
589       1.00      1.00      1.00 
590       1.00      1.00      3.00 
591       1.00      1.00      1.00 
592       2.00      1.00      3.00 
593       1.00      1.00      2.00 
594       1.00      1.00      3.00 
595       1.00      1.00      3.00 
596       1.00      1.00      1.00 
597       1.00      1.00      1.00 
598       2.00      1.00      1.00 
599       1.00      1.00      2.00 
600       1.00      1.00      2.00 
601       1.00      1.00      2.00 
602       1.00      1.00      1.00 
603       1.00      1.00      3.00 
604       1.00      1.00      2.00 
605       1.00      1.00      2.00 
606       1.00      1.00      3.00 
607       1.00      1.00      1.00 
608       1.00      1.00      2.00 
609       1.00      1.00      1.00 
610       1.00      1.00      2.00 
611       1.00      1.00      2.00 
612       1.00      1.00      1.00 
613       1.00      1.00      3.00 
614       2.00      1.00      2.00 
615       1.00      1.00      2.00 
616       1.00      1.00      2.00 
617       2.00      1.00      2.00 
618       1.00      1.00      1.00 
619       1.00      1.00      3.00 
620       1.00      1.00      2.00 
621       1.00      1.00      2.00 
622       1.00      1.00      2.00 
623       2.00      1.00      3.00 
624       1.00      1.00      2.00 
625       2.00      1.00      2.00 
626       1.00      1.00      1.00 
627       1.00      1.00      1.00 
628       1.00      1.00      1.00 
629       1.00      1.00      3.00 
630       1.00      1.00      2.00 
631       1.00      1.00      2.00 
632       1.00      1.00      2.00 
633       1.00      1.00      2.00 
634       1.00      1.00      2.00 
635       1.00      1.00      2.00 
636       1.00      1.00      2.00 
637       1.00      1.00      3.00 
638       1.00      1.00      1.00 
639       1.00      1.00      2.00 
640       2.00      1.00      3.00 
641       1.00      1.00      1.00 
642       1.00      1.00      2.00 
643       1.00      1.00      1.00 
644       1.00      1.00      2.00 
645       1.00      1.00      1.00 
646       2.00      1.00      2.00 
647       1.00      1.00      1.00 
648       1.00      1.00      1.00 
649       1.00      1.00      2.00 
650       1.00      1.00      3.00 
651       1.00      1.00      3.00 
652       1.00      1.00      1.00 
653       1.00      1.00      1.00 
654       1.00      1.00      2.00 
655       1.00      1.00      2.00 
656       1.00      1.00      3.00 
657       1.00      1.00      1.00 
658       1.00      1.00      2.00 
659       2.00      1.00      2.00 
660       1.00      1.00      3.00 
661       1.00      1.00      2.00 
662       1.00      1.00      3.00 
663       1.00      1.00      1.00 
664       1.00      1.00      2.00 
665       1.00      1.00      2.00 
666       2.00      1.00      3.00 
667       1.00      1.00      1.00 
668       1.00      1.00      1.00 
669       2.00      1.00      3.00 
670       2.00      1.00      2.00 
671       1.00      1.00      3.00 
672       2.00      1.00      2.00 
673       2.00      1.00      2.00 
674       1.00      1.00      2.00 
675       2.00      1.00      2.00 
676       1.00      1.00      2.00 
677       1.00      1.00      3.00 
678 end data.
679
680 VARIABLE LABEL schtyp 'type of school'.
681 ADD VALUE LABELS female 0 male 1 female.
682 ADD VALUE LABELS ses 1 low 2 middle 3 high.
683 ADD VALUE LABELS schtyp 1 public 2 private.
684
685 crosstabs /tables = schtyp by female /statistic = chisq.
686 crosstabs /tables = female by ses  /statistic = chisq.
687 ])
688
689 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
690 Table: Summary.
691 ,Cases,,,,,
692 ,Valid,,Missing,,Total,
693 ,N,Percent,N,Percent,N,Percent
694 type of school * female,200,100.0%,0,0.0%,200,100.0%
695
696 Table: type of school * female [[count]].
697 ,female,,
698 type of school,male,female,Total
699 public,77.000,91.000,168.000
700 private,14.000,18.000,32.000
701 Total,91.000,109.000,200.000
702
703 Table: Chi-square tests.
704 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
705 Pearson Chi-Square,.047,1,.828,,
706 Likelihood Ratio,.047,1,.828,,
707 Fisher's Exact Test,,,,.849,.492
708 Continuity Correction,.001,1,.981,,
709 Linear-by-Linear Association,.047,1,.829,,
710 N of Valid Cases,200,,,,
711
712 Table: Summary.
713 ,Cases,,,,,
714 ,Valid,,Missing,,Total,
715 ,N,Percent,N,Percent,N,Percent
716 female * ses,200,100.0%,0,0.0%,200,100.0%
717
718 Table: female * ses [[count]].
719 ,ses,,,
720 female,low,middle,high,Total
721 male,15.000,47.000,29.000,91.000
722 female,32.000,48.000,29.000,109.000
723 Total,47.000,95.000,58.000,200.000
724
725 Table: Chi-square tests.
726 Statistic,Value,df,Asymp. Sig. (2-tailed)
727 Pearson Chi-Square,4.577,2,.101
728 Likelihood Ratio,4.679,2,.096
729 Linear-by-Linear Association,3.110,1,.078
730 N of Valid Cases,200,,
731 ])
732
733 AT_CLEANUP
734
735 AT_SETUP([CROSSTABS Pearson's R])
736 # Test 1.
737 AT_DATA([pearson.sps], [dnl
738 SET FORMAT F8.3.
739
740 * From http://www.statisticslectures.com/topics/pearsonr/.
741 DATA LIST FREE/x y.
742 BEGIN DATA.
743 1 4
744 3 6
745 5 10
746 5 12
747 6 13
748 END DATA.
749 CROSSTABS x BY y/STATISTICS=CORR.
750 ])
751 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
752 Table: Summary.
753 ,Cases,,,,,
754 ,Valid,,Missing,,Total,
755 ,N,Percent,N,Percent,N,Percent
756 x * y,5,100.0%,0,0.0%,5,100.0%
757
758 Table: x * y [[count]].
759 ,y,,,,,
760 x,4.000,6.000,10.000,12.000,13.000,Total
761 1.000,1.000,.000,.000,.000,.000,1.000
762 3.000,.000,1.000,.000,.000,.000,1.000
763 5.000,.000,.000,1.000,1.000,.000,2.000
764 6.000,.000,.000,.000,.000,1.000,1.000
765 Total,1.000,1.000,1.000,1.000,1.000,5.000
766
767 Table: Symmetric measures.
768 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
769 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550,
770 Interval by Interval,Pearson's R,.968,.017,6.708,
771 N of Valid Cases,,5,,,
772 ])
773
774 # Test 2.
775 AT_DATA([pearson2.sps], [dnl
776 SET FORMAT F8.3.
777
778 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
779 DATA LIST FREE/x y.
780 BEGIN DATA.
781 1 1.5
782 2 1.5
783 3 4
784 4 6
785 5 5
786 6 7
787 7 6.5
788 8 9
789 9 10.5
790 10 11
791 END DATA.
792 CROSSTABS x BY y/STATISTICS=CORR.
793 ])
794 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
795 Table: Summary.
796 ,Cases,,,,,
797 ,Valid,,Missing,,Total,
798 ,N,Percent,N,Percent,N,Percent
799 x * y,10,100.0%,0,0.0%,10,100.0%
800
801 Table: x * y [[count]].
802 ,y,,,,,,,,,
803 x,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,Total
804 1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
805 2.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
806 3.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
807 4.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
808 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
809 6.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
810 7.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
811 8.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
812 9.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
813 10.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
814 Total,2.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
815
816 Table: Symmetric measures.
817 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
818 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844,
819 Interval by Interval,Pearson's R,.971,.017,11.580,
820 N of Valid Cases,,10,,,
821 ])
822
823 # Test 3.
824 AT_DATA([pearson3.sps], [dnl
825 SET FORMAT F8.3.
826
827 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
828 DATA LIST FREE/x y.
829 BEGIN DATA.
830 56 87
831 56 91
832 65 85
833 65 91
834 50 75
835 25 28
836 87 122
837 44 66
838 35 58
839 END DATA.
840 CROSSTABS x BY y/STATISTICS=CORR.
841 ])
842 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
843 Table: Summary.
844 ,Cases,,,,,
845 ,Valid,,Missing,,Total,
846 ,N,Percent,N,Percent,N,Percent
847 x * y,9,100.0%,0,0.0%,9,100.0%
848
849 Table: x * y [[count]].
850 ,y,,,,,,,,
851 x,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,Total
852 25.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
853 35.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
854 44.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
855 50.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
856 56.000,.000,.000,.000,.000,.000,1.000,1.000,.000,2.000
857 65.000,.000,.000,.000,.000,1.000,.000,1.000,.000,2.000
858 87.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
859 Total,1.000,1.000,1.000,1.000,1.000,1.000,2.000,1.000,9.000
860
861 Table: Symmetric measures.
862 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
863 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860,
864 Interval by Interval,Pearson's R,.966,.017,9.915,
865 N of Valid Cases,,9,,,
866 ])
867
868 # Test 4.
869 AT_DATA([pearson4.sps], [dnl
870 SET FORMAT F8.3.
871
872 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
873 DATA LIST FREE/x y.
874 BEGIN DATA.
875 5 5
876 10 20
877 6 4
878 8 15
879 4 11
880 4 9
881 3 12
882 10 18
883 2 7
884 6 2
885 7 14
886 9 17
887 END DATA.
888 CROSSTABS x BY y/STATISTICS=CORR.
889 ])
890 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
891 Table: Summary.
892 ,Cases,,,,,
893 ,Valid,,Missing,,Total,
894 ,N,Percent,N,Percent,N,Percent
895 x * y,12,100.0%,0,0.0%,12,100.0%
896
897 Table: x * y [[count]].
898 ,y,,,,,,,,,,,,
899 x,2.000,4.000,5.000,7.000,9.000,11.000,12.000,14.000,15.000,17.000,18.000,20.000,Total
900 2.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
901 3.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
902 4.000,.000,.000,.000,.000,1.000,1.000,.000,.000,.000,.000,.000,.000,2.000
903 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
904 6.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,2.000
905 7.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
906 8.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
907 9.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
908 10.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,2.000
909 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,12.000
910
911 Table: Symmetric measures.
912 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
913 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758,
914 Interval by Interval,Pearson's R,.667,.132,2.830,
915 N of Valid Cases,,12,,,
916 ])
917
918 # Test 5.
919 AT_DATA([pearson5.sps], [dnl
920 SET FORMAT F8.3.
921
922 * From http://www.statisticslectures.com/topics/pearsonr/.
923 DATA LIST FREE/x y.
924 BEGIN DATA.
925 18 15000
926 25 29000
927 57 68000
928 45 52000
929 26 32000
930 64 80000
931 37 41000
932 40 45000
933 24 26000
934 33 33000
935 END DATA.
936 CROSSTABS x BY y/STATISTICS=CORR.
937 ])
938 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
939 Table: Summary.
940 ,Cases,,,,,
941 ,Valid,,Missing,,Total,
942 ,N,Percent,N,Percent,N,Percent
943 x * y,10,100.0%,0,0.0%,10,100.0%
944
945 Table: x * y [[count]].
946 ,y,,,,,,,,,,
947 x,15000.000,26000.000,29000.000,32000.000,33000.000,41000.000,45000.000,52000.000,68000.000,80000.000,Total
948 18.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
949 24.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
950 25.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
951 26.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
952 33.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
953 37.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
954 40.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
955 45.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
956 57.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
957 64.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
958 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
959
960 Table: Symmetric measures.
961 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
962 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinity,
963 Interval by Interval,Pearson's R,.992,.004,22.638,
964 N of Valid Cases,,10,,,
965 ])
966 AT_CLEANUP
967
968 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda])
969 AT_DATA([lambda.sps], [dnl
970 SET FORMAT F8.3.
971
972 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
973 DATA LIST LIST NOTABLE/x y w.
974 WEIGHT BY w.
975 BEGIN DATA.
976 1 1 424
977 1 2 213
978 1 3 59
979 3 1 55
980 3 2 188
981 3 3 357
982 END DATA.
983
984 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
985
986 * From http://vassarstats.net.
987 DATA LIST LIST NOTABLE/x y w.
988 WEIGHT BY w.
989 BEGIN DATA.
990 1 1 19
991 1 2 26
992 1 3 8
993 2 1 21
994 2 2 13
995 2 3 5
996 3 1 6
997 3 2 12
998 3 3 27
999 END DATA.
1000
1001 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1002
1003 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1004   cross classifications". Part I. Journal of the American Statistical
1005   Association, 49, 732-764.
1006 DATA LIST LIST NOTABLE/x y w.
1007 WEIGHT BY w.
1008 BEGIN DATA.
1009 1 1 1768
1010 1 2 807
1011 1 3 189
1012 1 4 47
1013 2 1 946
1014 2 2 1387
1015 2 3 746
1016 2 4 53
1017 3 1 115
1018 3 2 438
1019 3 3 288
1020 3 4 16
1021 END DATA.
1022 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1023 ])
1024 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1025 Table: Summary.
1026 ,Cases,,,,,
1027 ,Valid,,Missing,,Total,
1028 ,N,Percent,N,Percent,N,Percent
1029 x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
1030
1031 Table: Directional measures.
1032 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1033 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1034 ,,x Dependent,.497,.024,15.986,.000
1035 ,,y Dependent,.370,.020,16.339,.000
1036 ,Goodman and Kruskal tau,x Dependent,.382,,,.   @&t@
1037 ,,y Dependent,.198,,,.   @&t@
1038
1039 Table: Summary.
1040 ,Cases,,,,,
1041 ,Valid,,Missing,,Total,
1042 ,N,Percent,N,Percent,N,Percent
1043 x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
1044
1045 Table: Directional measures.
1046 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1047 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1048 ,,x Dependent,.250,.089,2.479,.013
1049 ,,y Dependent,.267,.085,2.766,.006
1050 ,Goodman and Kruskal tau,x Dependent,.129,,,.   @&t@
1051 ,,y Dependent,.123,,,.   @&t@
1052
1053 Table: Summary.
1054 ,Cases,,,,,
1055 ,Valid,,Missing,,Total,
1056 ,N,Percent,N,Percent,N,Percent
1057 x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
1058
1059 Table: Directional measures.
1060 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1061 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1062 ,,x Dependent,.224,.013,16.076,.000
1063 ,,y Dependent,.192,.012,14.438,.000
1064 ,Goodman and Kruskal tau,x Dependent,.089,,,.   @&t@
1065 ,,y Dependent,.081,,,.   @&t@
1066 ])
1067 AT_CLEANUP
1068
1069 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1070 AT_DATA([lambda.sps], [dnl
1071 SET FORMAT F8.3.
1072
1073 * From Douglas Bonett.
1074 DATA LIST LIST NOTABLE/x y w.
1075 WEIGHT BY w.
1076 BEGIN DATA.
1077 1 1 225
1078 1 2 43
1079 1 3 216
1080 2 1 3
1081 2 2 1
1082 2 3 12
1083 END DATA.
1084
1085 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1086 ])
1087 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1088 Table: Summary.
1089 ,Cases,,,,,
1090 ,Valid,,Missing,,Total,
1091 ,N,Percent,N,Percent,N,Percent
1092 x * y,500.000,100.0%,.000,0.0%,500.000,100.0%
1093
1094 Table: Directional measures.
1095 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1096 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1097 ,,x Dependent,.000,.000,NaN,NaN
1098 ,,y Dependent,.033,.014,2.336,.019
1099 ,Goodman and Kruskal tau,x Dependent,.012,,,.   @&t@
1100 ,,y Dependent,.009,,,.   @&t@
1101 ])
1102 AT_CLEANUP
1103
1104 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma])
1105 AT_DATA([somersd.sps], [dnl
1106 SET FORMAT F8.3.
1107
1108 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1109 DATA LIST LIST NOTABLE/x y * w (F10.6).
1110 WEIGHT BY w.
1111 BEGIN DATA.
1112 1 1 0.000025
1113 1 2 0.0001
1114 1 3 0.001
1115 1 4 0.0025
1116 1 5 0.004
1117 1 6 0.0075
1118 1 7 0.0125
1119 2 1 0.049975
1120 2 2 0.0999
1121 2 3 0.199
1122 2 4 0.2475
1123 2 5 0.196
1124 2 6 0.1425
1125 2 7 0.0375
1126 END DATA.
1127 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1128
1129 * From http://uregina.ca/~gingrich/gamma.pdf.
1130 DATA LIST LIST NOTABLE/x y w.
1131 WEIGHT BY w.
1132 BEGIN DATA.
1133 1 1 34
1134 1 2 24
1135 1 3 15
1136 2 1 42
1137 2 2 74
1138 2 3 67
1139 3 1 28
1140 3 2 111
1141 3 3 292
1142 END DATA.
1143 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1144 ])
1145 AT_CHECK([pspp -O format=csv somersd.sps], [0], [dnl
1146 Table: Summary.
1147 ,Cases,,,,,
1148 ,Valid,,Missing,,Total,
1149 ,N,Percent,N,Percent,N,Percent
1150 x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
1151
1152 Table: Directional measures.
1153 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1154 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1155 ,,x Dependent,-.045,.300,-.149,.882
1156 ,,y Dependent,-.684,2.378,-.149,.882
1157
1158 Table: Summary.
1159 ,Cases,,,,,
1160 ,Valid,,Missing,,Total,
1161 ,N,Percent,N,Percent,N,Percent
1162 x * y,687.000,100.0%,.000,0.0%,687.000,100.0%
1163
1164 Table: Symmetric measures.
1165 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1166 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669,
1167 ,Kendall's tau-c,.310,.029,10.669,
1168 ,Gamma,.591,.043,10.669,
1169 N of Valid Cases,,687.000,,,
1170
1171 Table: Directional measures.
1172 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1173 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1174 ,,x Dependent,.351,.032,10.669,.000
1175 ,,y Dependent,.394,.035,10.669,.000
1176 ])
1177
1178 AT_DATA([ordinal.sps], [dnl
1179 SET FORMAT F8.3.
1180
1181 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1182 DATA LIST LIST NOTABLE /x y w.
1183 WEIGHT BY w.
1184 BEGIN DATA.
1185 1 2 40
1186 2 3 80
1187 3 4 30
1188 END DATA.
1189 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1190
1191 * Same site, case 2.
1192 DATA LIST LIST NOTABLE /x y w.
1193 WEIGHT BY w.
1194 BEGIN DATA.
1195 1 1 40
1196 2 3 80
1197 3 4 30
1198 END DATA.
1199 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1200
1201 * Same site, case 3.
1202 DATA LIST LIST NOTABLE /x y w.
1203 WEIGHT BY w.
1204 BEGIN DATA.
1205 1 4 40
1206 2 3 80
1207 3 2 30
1208 END DATA.
1209 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1210
1211 * Same site, case 4.
1212 DATA LIST LIST NOTABLE /x y w.
1213 WEIGHT BY w.
1214 BEGIN DATA.
1215 1 1 20
1216 1 2 20
1217 2 3 80
1218 3 4 30
1219 END DATA.
1220 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1221
1222 * Same site, case 5.
1223 DATA LIST LIST NOTABLE /x y w.
1224 WEIGHT BY w.
1225 BEGIN DATA.
1226 1 2 40
1227 2 2 80
1228 3 2 29
1229 3 3 1
1230 END DATA.
1231 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1232
1233 * Same site, case 6.
1234 DATA LIST LIST NOTABLE /x y w.
1235 WEIGHT BY w.
1236 BEGIN DATA.
1237 1 1 3
1238 1 2 6
1239 1 3 28
1240 1 4 61
1241 2 1 4
1242 2 2 5
1243 2 3 21
1244 2 4 20
1245 END DATA.
1246 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1247
1248 * Same site, case 7.
1249 DATA LIST LIST NOTABLE /x y w.
1250 WEIGHT BY w.
1251 BEGIN DATA.
1252 1 1 38
1253 1 2 6
1254 1 3 3
1255 1 4 51
1256 2 1 4
1257 2 2 20
1258 2 3 21
1259 2 4 5
1260 END DATA.
1261 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1262
1263 * Same site, case 8.
1264 DATA LIST LIST NOTABLE /x y w.
1265 WEIGHT BY w.
1266 BEGIN DATA.
1267 1 1 2
1268 1 2 3
1269 1 3 5
1270 1 4 1
1271 2 1 2
1272 2 2 16
1273 2 3 3
1274 2 4 6
1275 3 1 3
1276 3 2 10
1277 3 3 35
1278 3 4 27
1279 4 1 6
1280 4 2 15
1281 4 3 33
1282 4 4 45
1283 END DATA.
1284 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1285 ])
1286 AT_CHECK([pspp -O format=csv ordinal.sps], [0], [dnl
1287 Table: Summary.
1288 ,Cases,,,,,
1289 ,Valid,,Missing,,Total,
1290 ,N,Percent,N,Percent,N,Percent
1291 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1292
1293 Table: Symmetric measures.
1294 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1295 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1296 ,Gamma,1.000,.000,24.841,
1297 N of Valid Cases,,150.000,,,
1298
1299 Table: Directional measures.
1300 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1301 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1302 ,,x Dependent,1.000,.000,24.841,.000
1303 ,,y Dependent,1.000,.000,24.841,.000
1304
1305 Table: Summary.
1306 ,Cases,,,,,
1307 ,Valid,,Missing,,Total,
1308 ,N,Percent,N,Percent,N,Percent
1309 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1310
1311 Table: Symmetric measures.
1312 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1313 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1314 ,Gamma,1.000,.000,24.841,
1315 N of Valid Cases,,150.000,,,
1316
1317 Table: Directional measures.
1318 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1319 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1320 ,,x Dependent,1.000,.000,24.841,.000
1321 ,,y Dependent,1.000,.000,24.841,.000
1322
1323 Table: Summary.
1324 ,Cases,,,,,
1325 ,Valid,,Missing,,Total,
1326 ,N,Percent,N,Percent,N,Percent
1327 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1328
1329 Table: Symmetric measures.
1330 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1331 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841,
1332 ,Gamma,-1.000,.000,-24.841,
1333 N of Valid Cases,,150.000,,,
1334
1335 Table: Directional measures.
1336 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1337 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1338 ,,x Dependent,-1.000,.000,-24.841,.000
1339 ,,y Dependent,-1.000,.000,-24.841,.000
1340
1341 Table: Summary.
1342 ,Cases,,,,,
1343 ,Valid,,Missing,,Total,
1344 ,N,Percent,N,Percent,N,Percent
1345 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1346
1347 Table: Symmetric measures.
1348 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1349 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841,
1350 ,Gamma,1.000,.000,24.841,
1351 N of Valid Cases,,150.000,,,
1352
1353 Table: Directional measures.
1354 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1355 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1356 ,,x Dependent,.944,.013,24.841,.000
1357 ,,y Dependent,1.000,.000,24.841,.000
1358
1359 Table: Summary.
1360 ,Cases,,,,,
1361 ,Valid,,Missing,,Total,
1362 ,N,Percent,N,Percent,N,Percent
1363 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1364
1365 Table: Symmetric measures.
1366 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1367 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009,
1368 ,Gamma,1.000,.000,1.009,
1369 N of Valid Cases,,150.000,,,
1370
1371 Table: Directional measures.
1372 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1373 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1374 ,,x Dependent,.805,.032,1.009,.313
1375 ,,y Dependent,.018,.017,1.009,.313
1376
1377 Table: Summary.
1378 ,Cases,,,,,
1379 ,Valid,,Missing,,Total,
1380 ,N,Percent,N,Percent,N,Percent
1381 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1382
1383 Table: Symmetric measures.
1384 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1385 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641,
1386 ,Gamma,-.381,.130,-2.641,
1387 N of Valid Cases,,148.000,,,
1388
1389 Table: Directional measures.
1390 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1391 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1392 ,,x Dependent,-.182,.069,-2.641,.008
1393 ,,y Dependent,-.237,.089,-2.641,.008
1394
1395 Table: Summary.
1396 ,Cases,,,,,
1397 ,Valid,,Missing,,Total,
1398 ,N,Percent,N,Percent,N,Percent
1399 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1400
1401 Table: Symmetric measures.
1402 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1403 Nominal by Nominal,Phi,.731,,,
1404 ,Cramer's V,.731,,,
1405 Ordinal by Ordinal,Gamma,-.110,.107,-1.022,
1406 N of Valid Cases,,148.000,,,
1407
1408 Table: Directional measures.
1409 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1410 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1411 ,,x Dependent,.640,.085,4.875,.000
1412 ,,y Dependent,.174,.050,3.248,.001
1413 ,Goodman and Kruskal tau,x Dependent,.534,,,.   @&t@
1414 ,,y Dependent,.167,,,.   @&t@
1415 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1416 ,,x Dependent,-.060,.059,-1.022,.307
1417 ,,y Dependent,-.096,.094,-1.022,.307
1418
1419 Table: Summary.
1420 ,Cases,,,,,
1421 ,Valid,,Missing,,Total,
1422 ,N,Percent,N,Percent,N,Percent
1423 x * y,212.000,100.0%,.000,0.0%,212.000,100.0%
1424
1425 Table: Symmetric measures.
1426 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1427 Nominal by Nominal,Phi,.432,,,
1428 ,Cramer's V,.249,,,
1429 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338,
1430 N of Valid Cases,,212.000,,,
1431
1432 Table: Directional measures.
1433 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1434 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1435 ,,x Dependent,.027,.087,.302,.763
1436 ,,y Dependent,.165,.065,2.349,.019
1437 ,Goodman and Kruskal tau,x Dependent,.051,,,.   @&t@
1438 ,,y Dependent,.068,,,.   @&t@
1439 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1440 ,,x Dependent,.202,.060,3.338,.001
1441 ,,y Dependent,.217,.064,3.338,.001
1442 ])
1443 AT_CLEANUP
1444
1445 AT_SETUP([CROSSTABS many statistics])
1446 AT_DATA([crosstabs.sps], [dnl
1447 SET FORMAT=F8.4.
1448
1449 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1450 DATA LIST LIST NOTABLE/x y w.
1451 WEIGHT BY w.
1452 BEGIN DATA.
1453 1 1 25
1454 1 2 25
1455 1 3 12
1456 2 2 1
1457 2 3 3
1458 END DATA.
1459 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1460 ])
1461 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
1462 Table: Summary.
1463 ,Cases,,,,,
1464 ,Valid,,Missing,,Total,
1465 ,N,Percent,N,Percent,N,Percent
1466 x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
1467
1468 Table: Chi-square tests.
1469 Statistic,Value,df,Asymp. Sig. (2-tailed)
1470 Pearson Chi-Square,6.9562,2.0000,.031
1471 Likelihood Ratio,6.6901,2.0000,.035
1472 Linear-by-Linear Association,5.8450,1.0000,.016
1473 N of Valid Cases,66.0000,,
1474
1475 Table: Symmetric measures.
1476 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1477 Nominal by Nominal,Phi,.3246,,,
1478 ,Cramer's V,.3246,,,
1479 ,Contingency Coefficient,.3088,,,
1480 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
1481 ,Kendall's tau-c,.1497,.0751,1.9920,
1482 ,Gamma,.8717,.1250,1.9920,
1483 ,Spearman Correlation,.2908,.0906,2.4311,
1484 Interval by Interval,Pearson's R,.2999,.0973,2.5147,
1485 N of Valid Cases,,66.0000,,,
1486
1487 Table: Directional measures.
1488 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1489 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1490 ,,x Dependent,.0000,.0000,NaN,NaN
1491 ,,y Dependent,.0500,.1791,.2723,.785
1492 ,Goodman and Kruskal tau,x Dependent,.1054,,,.   @&t@
1493 ,,y Dependent,.0434,,,.   @&t@
1494 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,.   @&t@
1495 ,,x Dependent,.2217,.1062,1.5373,.   @&t@
1496 ,,y Dependent,.0473,.0306,1.5373,.   @&t@
1497 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1498 ,,x Dependent,.1152,.0572,1.9920,.046
1499 ,,y Dependent,.6573,.1417,1.9920,.046
1500 ])
1501 AT_CLEANUP
1502
1503 AT_SETUP([CROSSTABS uncertainy coefficient])
1504 AT_DATA([uc.sps], [dnl
1505 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1506 SET FORMAT=F8.3.
1507
1508 DATA LIST LIST NOTABLE/x y w.
1509 WEIGHT BY w.
1510 BEGIN DATA.
1511 1 1 416
1512 1 2 121
1513 2 1 335
1514 2 2 2
1515 3 1 112
1516 3 2 1
1517 END DATA.
1518 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1519 ])
1520 AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
1521 Table: Summary.
1522 ,Cases,,,,,
1523 ,Valid,,Missing,,Total,
1524 ,N,Percent,N,Percent,N,Percent
1525 x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
1526
1527 Table: Directional measures.
1528 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1529 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1530 ,,x Dependent,.000,.000,NaN,NaN
1531 ,,y Dependent,.000,.000,NaN,NaN
1532 ,Goodman and Kruskal tau,x Dependent,.076,,,.   @&t@
1533 ,,y Dependent,.108,,,.   @&t@
1534 ,Uncertainty Coefficient,Symmetric,.105,.012,,.   @&t@
1535 ,,x Dependent,.073,.009,7.890,.   @&t@
1536 ,,y Dependent,.184,.019,7.890,.   @&t@
1537 ])
1538 AT_CLEANUP