CROSSTABS: Calculate significance for lambda and Somers' d.
[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 Somers' D, Tau-B, Tau-C, Gamma])
1070 AT_DATA([somersd.sps], [dnl
1071 SET FORMAT F8.3.
1072
1073 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1074 DATA LIST LIST NOTABLE/x y * w (F10.6).
1075 WEIGHT BY w.
1076 BEGIN DATA.
1077 1 1 0.000025
1078 1 2 0.0001
1079 1 3 0.001
1080 1 4 0.0025
1081 1 5 0.004
1082 1 6 0.0075
1083 1 7 0.0125
1084 2 1 0.049975
1085 2 2 0.0999
1086 2 3 0.199
1087 2 4 0.2475
1088 2 5 0.196
1089 2 6 0.1425
1090 2 7 0.0375
1091 END DATA.
1092 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1093
1094 * From http://uregina.ca/~gingrich/gamma.pdf.
1095 DATA LIST LIST NOTABLE/x y w.
1096 WEIGHT BY w.
1097 BEGIN DATA.
1098 1 1 34
1099 1 2 24
1100 1 3 15
1101 2 1 42
1102 2 2 74
1103 2 3 67
1104 3 1 28
1105 3 2 111
1106 3 3 292
1107 END DATA.
1108 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1109 ])
1110 AT_CHECK([pspp -O format=csv somersd.sps], [0], [dnl
1111 Table: Summary.
1112 ,Cases,,,,,
1113 ,Valid,,Missing,,Total,
1114 ,N,Percent,N,Percent,N,Percent
1115 x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
1116
1117 Table: Directional measures.
1118 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1119 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1120 ,,x Dependent,-.045,.300,-.149,.882
1121 ,,y Dependent,-.684,2.378,-.149,.882
1122
1123 Table: Summary.
1124 ,Cases,,,,,
1125 ,Valid,,Missing,,Total,
1126 ,N,Percent,N,Percent,N,Percent
1127 x * y,687.000,100.0%,.000,0.0%,687.000,100.0%
1128
1129 Table: Symmetric measures.
1130 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1131 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669,
1132 ,Kendall's tau-c,.310,.029,10.669,
1133 ,Gamma,.591,.043,10.669,
1134 N of Valid Cases,,687.000,,,
1135
1136 Table: Directional measures.
1137 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1138 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1139 ,,x Dependent,.351,.032,10.669,.000
1140 ,,y Dependent,.394,.035,10.669,.000
1141 ])
1142
1143 AT_DATA([ordinal.sps], [dnl
1144 SET FORMAT F8.3.
1145
1146 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1147 DATA LIST LIST NOTABLE /x y w.
1148 WEIGHT BY w.
1149 BEGIN DATA.
1150 1 2 40
1151 2 3 80
1152 3 4 30
1153 END DATA.
1154 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1155
1156 * Same site, case 2.
1157 DATA LIST LIST NOTABLE /x y w.
1158 WEIGHT BY w.
1159 BEGIN DATA.
1160 1 1 40
1161 2 3 80
1162 3 4 30
1163 END DATA.
1164 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1165
1166 * Same site, case 3.
1167 DATA LIST LIST NOTABLE /x y w.
1168 WEIGHT BY w.
1169 BEGIN DATA.
1170 1 4 40
1171 2 3 80
1172 3 2 30
1173 END DATA.
1174 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1175
1176 * Same site, case 4.
1177 DATA LIST LIST NOTABLE /x y w.
1178 WEIGHT BY w.
1179 BEGIN DATA.
1180 1 1 20
1181 1 2 20
1182 2 3 80
1183 3 4 30
1184 END DATA.
1185 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1186
1187 * Same site, case 5.
1188 DATA LIST LIST NOTABLE /x y w.
1189 WEIGHT BY w.
1190 BEGIN DATA.
1191 1 2 40
1192 2 2 80
1193 3 2 29
1194 3 3 1
1195 END DATA.
1196 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1197
1198 * Same site, case 6.
1199 DATA LIST LIST NOTABLE /x y w.
1200 WEIGHT BY w.
1201 BEGIN DATA.
1202 1 1 3
1203 1 2 6
1204 1 3 28
1205 1 4 61
1206 2 1 4
1207 2 2 5
1208 2 3 21
1209 2 4 20
1210 END DATA.
1211 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1212
1213 * Same site, case 7.
1214 DATA LIST LIST NOTABLE /x y w.
1215 WEIGHT BY w.
1216 BEGIN DATA.
1217 1 1 38
1218 1 2 6
1219 1 3 3
1220 1 4 51
1221 2 1 4
1222 2 2 20
1223 2 3 21
1224 2 4 5
1225 END DATA.
1226 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1227
1228 * Same site, case 8.
1229 DATA LIST LIST NOTABLE /x y w.
1230 WEIGHT BY w.
1231 BEGIN DATA.
1232 1 1 2
1233 1 2 3
1234 1 3 5
1235 1 4 1
1236 2 1 2
1237 2 2 16
1238 2 3 3
1239 2 4 6
1240 3 1 3
1241 3 2 10
1242 3 3 35
1243 3 4 27
1244 4 1 6
1245 4 2 15
1246 4 3 33
1247 4 4 45
1248 END DATA.
1249 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1250 ])
1251 AT_CHECK([pspp -O format=csv ordinal.sps], [0], [dnl
1252 Table: Summary.
1253 ,Cases,,,,,
1254 ,Valid,,Missing,,Total,
1255 ,N,Percent,N,Percent,N,Percent
1256 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1257
1258 Table: Symmetric measures.
1259 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1260 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1261 ,Gamma,1.000,.000,24.841,
1262 N of Valid Cases,,150.000,,,
1263
1264 Table: Directional measures.
1265 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1266 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1267 ,,x Dependent,1.000,.000,24.841,.000
1268 ,,y Dependent,1.000,.000,24.841,.000
1269
1270 Table: Summary.
1271 ,Cases,,,,,
1272 ,Valid,,Missing,,Total,
1273 ,N,Percent,N,Percent,N,Percent
1274 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1275
1276 Table: Symmetric measures.
1277 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1278 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1279 ,Gamma,1.000,.000,24.841,
1280 N of Valid Cases,,150.000,,,
1281
1282 Table: Directional measures.
1283 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1284 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1285 ,,x Dependent,1.000,.000,24.841,.000
1286 ,,y Dependent,1.000,.000,24.841,.000
1287
1288 Table: Summary.
1289 ,Cases,,,,,
1290 ,Valid,,Missing,,Total,
1291 ,N,Percent,N,Percent,N,Percent
1292 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1293
1294 Table: Symmetric measures.
1295 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1296 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841,
1297 ,Gamma,-1.000,.000,-24.841,
1298 N of Valid Cases,,150.000,,,
1299
1300 Table: Directional measures.
1301 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1302 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1303 ,,x Dependent,-1.000,.000,-24.841,.000
1304 ,,y Dependent,-1.000,.000,-24.841,.000
1305
1306 Table: Summary.
1307 ,Cases,,,,,
1308 ,Valid,,Missing,,Total,
1309 ,N,Percent,N,Percent,N,Percent
1310 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1311
1312 Table: Symmetric measures.
1313 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1314 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841,
1315 ,Gamma,1.000,.000,24.841,
1316 N of Valid Cases,,150.000,,,
1317
1318 Table: Directional measures.
1319 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1320 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1321 ,,x Dependent,.944,.013,24.841,.000
1322 ,,y Dependent,1.000,.000,24.841,.000
1323
1324 Table: Summary.
1325 ,Cases,,,,,
1326 ,Valid,,Missing,,Total,
1327 ,N,Percent,N,Percent,N,Percent
1328 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1329
1330 Table: Symmetric measures.
1331 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1332 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009,
1333 ,Gamma,1.000,.000,1.009,
1334 N of Valid Cases,,150.000,,,
1335
1336 Table: Directional measures.
1337 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1338 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1339 ,,x Dependent,.805,.032,1.009,.313
1340 ,,y Dependent,.018,.017,1.009,.313
1341
1342 Table: Summary.
1343 ,Cases,,,,,
1344 ,Valid,,Missing,,Total,
1345 ,N,Percent,N,Percent,N,Percent
1346 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1347
1348 Table: Symmetric measures.
1349 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1350 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641,
1351 ,Gamma,-.381,.130,-2.641,
1352 N of Valid Cases,,148.000,,,
1353
1354 Table: Directional measures.
1355 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1356 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1357 ,,x Dependent,-.182,.069,-2.641,.008
1358 ,,y Dependent,-.237,.089,-2.641,.008
1359
1360 Table: Summary.
1361 ,Cases,,,,,
1362 ,Valid,,Missing,,Total,
1363 ,N,Percent,N,Percent,N,Percent
1364 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1365
1366 Table: Symmetric measures.
1367 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1368 Nominal by Nominal,Phi,.731,,,
1369 ,Cramer's V,.731,,,
1370 Ordinal by Ordinal,Gamma,-.110,.107,-1.022,
1371 N of Valid Cases,,148.000,,,
1372
1373 Table: Directional measures.
1374 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1375 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1376 ,,x Dependent,.640,.085,4.875,.000
1377 ,,y Dependent,.174,.050,3.248,.001
1378 ,Goodman and Kruskal tau,x Dependent,.534,,,.   @&t@
1379 ,,y Dependent,.167,,,.   @&t@
1380 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1381 ,,x Dependent,-.060,.059,-1.022,.307
1382 ,,y Dependent,-.096,.094,-1.022,.307
1383
1384 Table: Summary.
1385 ,Cases,,,,,
1386 ,Valid,,Missing,,Total,
1387 ,N,Percent,N,Percent,N,Percent
1388 x * y,212.000,100.0%,.000,0.0%,212.000,100.0%
1389
1390 Table: Symmetric measures.
1391 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1392 Nominal by Nominal,Phi,.432,,,
1393 ,Cramer's V,.249,,,
1394 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338,
1395 N of Valid Cases,,212.000,,,
1396
1397 Table: Directional measures.
1398 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1399 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1400 ,,x Dependent,.027,.087,.302,.763
1401 ,,y Dependent,.165,.065,2.349,.019
1402 ,Goodman and Kruskal tau,x Dependent,.051,,,.   @&t@
1403 ,,y Dependent,.068,,,.   @&t@
1404 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1405 ,,x Dependent,.202,.060,3.338,.001
1406 ,,y Dependent,.217,.064,3.338,.001
1407 ])
1408 AT_CLEANUP
1409
1410 AT_SETUP([CROSSTABS many statistics])
1411 AT_DATA([crosstabs.sps], [dnl
1412 SET FORMAT=F8.4.
1413
1414 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1415 DATA LIST LIST NOTABLE/x y w.
1416 WEIGHT BY w.
1417 BEGIN DATA.
1418 1 1 25
1419 1 2 25
1420 1 3 12
1421 2 2 1
1422 2 3 3
1423 END DATA.
1424 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1425 ])
1426 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
1427 Table: Summary.
1428 ,Cases,,,,,
1429 ,Valid,,Missing,,Total,
1430 ,N,Percent,N,Percent,N,Percent
1431 x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
1432
1433 Table: Chi-square tests.
1434 Statistic,Value,df,Asymp. Sig. (2-tailed)
1435 Pearson Chi-Square,6.9562,2.0000,.031
1436 Likelihood Ratio,6.6901,2.0000,.035
1437 Linear-by-Linear Association,5.8450,1.0000,.016
1438 N of Valid Cases,66.0000,,
1439
1440 Table: Symmetric measures.
1441 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1442 Nominal by Nominal,Phi,.3246,,,
1443 ,Cramer's V,.3246,,,
1444 ,Contingency Coefficient,.3088,,,
1445 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
1446 ,Kendall's tau-c,.1497,.0751,1.9920,
1447 ,Gamma,.8717,.1250,1.9920,
1448 ,Spearman Correlation,.2908,.0906,2.4311,
1449 Interval by Interval,Pearson's R,.2999,.0973,2.5147,
1450 N of Valid Cases,,66.0000,,,
1451
1452 Table: Directional measures.
1453 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1454 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1455 ,,x Dependent,.0000,.0000,NaN,NaN
1456 ,,y Dependent,.0500,.1791,.2723,.785
1457 ,Goodman and Kruskal tau,x Dependent,.1054,,,.   @&t@
1458 ,,y Dependent,.0434,,,.   @&t@
1459 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,.   @&t@
1460 ,,x Dependent,.2217,.1062,1.5373,.   @&t@
1461 ,,y Dependent,.0473,.0306,1.5373,.   @&t@
1462 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1463 ,,x Dependent,.1152,.0572,1.9920,.046
1464 ,,y Dependent,.6573,.1417,1.9920,.046
1465 ])
1466 AT_CLEANUP
1467
1468 AT_SETUP([CROSSTABS uncertainy coefficient])
1469 AT_DATA([uc.sps], [dnl
1470 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1471 SET FORMAT=F8.3.
1472
1473 DATA LIST LIST NOTABLE/x y w.
1474 WEIGHT BY w.
1475 BEGIN DATA.
1476 1 1 416
1477 1 2 121
1478 2 1 335
1479 2 2 2
1480 3 1 112
1481 3 2 1
1482 END DATA.
1483 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1484 ])
1485 AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
1486 Table: Summary.
1487 ,Cases,,,,,
1488 ,Valid,,Missing,,Total,
1489 ,N,Percent,N,Percent,N,Percent
1490 x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
1491
1492 Table: Directional measures.
1493 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1494 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1495 ,,x Dependent,.000,.000,NaN,NaN
1496 ,,y Dependent,.000,.000,NaN,NaN
1497 ,Goodman and Kruskal tau,x Dependent,.076,,,.   @&t@
1498 ,,y Dependent,.108,,,.   @&t@
1499 ,Uncertainty Coefficient,Symmetric,.105,.012,,.   @&t@
1500 ,,x Dependent,.073,.009,7.890,.   @&t@
1501 ,,y Dependent,.184,.019,7.890,.   @&t@
1502 ])
1503 AT_CLEANUP