CROSSTABS: Fix computation of adjusted standardized residual.
[pspp] / tests / language / stats / crosstabs.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([CROSSTABS procedure])
18
19 dnl Based on bug #60982.
20 AT_SETUP([CROSSTABS residuals])
21 AT_DATA([crosstabs.sps],
22   [DATASET CLOSE ALL.
23 DATA LIST LIST NOTABLE/ r c n.
24 BEGIN DATA
25 1 1 26
26 1 2 31
27 2 1 12
28 2 2 32
29 3 1 27
30 3 2 18
31 4 1 8
32 4 2 7
33 END DATA.
34 WEIGHT by n.
35 CROSSTABS r by c /STATISTICS=CHISQ
36 /CELLS=COUNT EXPECTED RESID SRESID ASRESID.
37 ])
38 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
39   [Table: Summary
40 ,Cases,,,,,
41 ,Valid,,Missing,,Total,
42 ,N,Percent,N,Percent,N,Percent
43 r × c,161.00,100.0%,.00,.0%,161.00,100.0%
44
45 Table: r × c
46 ,,,c,,Total
47 ,,,1.00,2.00,
48 r,1.00,Count,26.00,31.00,57.00
49 ,,Expected,25.84,31.16,.35
50 ,,Residual,.16,-.16,
51 ,,Std. Residual,.03,-.03,
52 ,,Adjusted Residual,.05,-.05,
53 ,2.00,Count,12.00,32.00,44.00
54 ,,Expected,19.95,24.05,.27
55 ,,Residual,-7.95,7.95,
56 ,,Std. Residual,-1.78,1.62,
57 ,,Adjusted Residual,-2.82,2.82,
58 ,3.00,Count,27.00,18.00,45.00
59 ,,Expected,20.40,24.60,.28
60 ,,Residual,6.60,-6.60,
61 ,,Std. Residual,1.46,-1.33,
62 ,,Adjusted Residual,2.33,-2.33,
63 ,4.00,Count,8.00,7.00,15.00
64 ,,Expected,6.80,8.20,.09
65 ,,Residual,1.20,-1.20,
66 ,,Std. Residual,.46,-.42,
67 ,,Adjusted Residual,.65,-.65,
68 Total,,Count,73.00,88.00,161.00
69 ,,Expected,.45,.55,1.00
70
71 Table: Chi-Square Tests
72 ,Value,df,Asymptotic Sig. (2-tailed)
73 Pearson Chi-Square,10.09,3.00,.018
74 Likelihood Ratio,10.35,3.00,.016
75 Linear-by-Linear Association,1.96,1.00,.162
76 N of Valid Cases,161.00,,
77 ])
78 AT_CLEANUP
79
80 AT_SETUP([CROSSTABS integer mode crash])
81 AT_DATA([crosstabs.sps],
82   [DATA LIST LIST /A * B * X * Y * .
83 BEGIN DATA.
84 2 3 4 5
85 END DATA.
86
87 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
88 ])
89 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
90 AT_CHECK([cat pspp.csv], [0],
91   [[Table: Reading free-form data from INLINE.
92 Variable,Format
93 A,F8.0
94 B,F8.0
95 X,F8.0
96 Y,F8.0
97
98 Table: Summary
99 ,Cases,,,,,
100 ,Valid,,Missing,,Total,
101 ,N,Percent,N,Percent,N,Percent
102 X × Y,1,100.0%,0,.0%,1,100.0%
103
104 Table: X × Y
105 ,,,Y,,,,,,,Total
106 ,,,1.00,2.00,3.00,4.00,5.00,6.00,7.00,
107 X,1.00,Count,0,0,0,0,0,0,0,0
108 ,2.00,Count,0,0,0,0,0,0,0,0
109 ,3.00,Count,0,0,0,0,0,0,0,0
110 ,4.00,Count,0,0,0,0,1,0,0,1
111 ,5.00,Count,0,0,0,0,0,0,0,0
112 ,6.00,Count,0,0,0,0,0,0,0,0
113 ,7.00,Count,0,0,0,0,0,0,0,0
114 Total,,Count,0,0,0,0,1,0,0,1
115 ]])
116 AT_CLEANUP
117
118 # Bug #47600.
119 AT_SETUP([CROSSTABS integer mode crash 2])
120 AT_DATA([crosstabs.sps], [dnl
121 DATA LIST lIST /x y.
122 BEGIN DATA.
123 4 5
124 END DATA.
125
126 CROSSTABS
127         VARIABLES x (1,3) y (1,7)
128       /TABLES x BY y.
129 ])
130 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
131   [[Table: Reading free-form data from INLINE.
132 Variable,Format
133 x,F8.0
134 y,F8.0
135
136 Table: Summary
137 ,Cases,,,,,
138 ,Valid,,Missing,,Total,
139 ,N,Percent,N,Percent,N,Percent
140 x × y,0,.0%,1,100.0%,1,100.0%
141
142 Table: x × y
143 ,,,y,,,,,,,Total
144 ,,,1.00,2.00,3.00,4.00,5.00,6.00,7.00,
145 x,1.00,Count,,,,,,,,
146 ,2.00,Count,,,,,,,,
147 ,3.00,Count,,,,,,,,
148 Total,,Count,,,,,,,,
149 ]])
150 AT_CLEANUP
151
152 # Bug #22037.
153 AT_SETUP([CROSSTABS long string crash])
154 AT_DATA([crosstabs.sps],
155   [data list list /x * y (a18).
156
157 begin data.
158
159    1. 'zero none'
160
161 1 'one unity'
162 2 'two duality'
163 3 'three lots'
164 end data.
165
166 CROSSTABS /TABLES = x BY y.
167 ])
168 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
169   [[Table: Reading free-form data from INLINE.
170 Variable,Format
171 x,F8.0
172 y,A18
173
174 "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."
175
176 "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."
177
178 Table: Summary
179 ,Cases,,,,,
180 ,Valid,,Missing,,Total,
181 ,N,Percent,N,Percent,N,Percent
182 x × y,4,66.7%,2,33.3%,6,100.0%
183
184 Table: x × y
185 ,,,y,,,,Total
186 ,,,one unity,three lots,two duality,zero none,
187 x,1.00,Count,1,0,0,1,2
188 ,2.00,Count,0,0,1,0,1
189 ,3.00,Count,0,1,0,0,1
190 Total,,Count,1,1,1,1,4
191 ]])
192 AT_CLEANUP
193
194 AT_SETUP([CROSSTABS crash])
195 AT_DATA([crosstabs.sps],
196   [[DATA LIST FIXED
197      / x   1-2
198        y   3
199        z   4.
200
201 BEGIN DATA.
202 0111
203 0222
204 0311
205 0412
206 0521
207 0612
208 0711
209 0811
210 0912
211 END DATA.
212
213 LIST.
214
215
216 CROSSTABS TABLES  y by z.
217 ]])
218 AT_CHECK([pspp -o - -O format=csv -o pspp.txt crosstabs.sps], [0],
219   [Table: Reading 1 record from INLINE.
220 Variable,Record,Columns,Format
221 x,1,1-2,F2.0
222 y,1,3-3,F1.0
223 z,1,4-4,F1.0
224
225 Table: Data List
226 x,y,z
227 1,1,1
228 2,2,2
229 3,1,1
230 4,1,2
231 5,2,1
232 6,1,2
233 7,1,1
234 8,1,1
235 9,1,2
236
237 Table: Summary
238 ,Cases,,,,,
239 ,Valid,,Missing,,Total,
240 ,N,Percent,N,Percent,N,Percent
241 y × z,9,100.0%,0,.0%,9,100.0%
242
243 Table: y × z
244 ,,,z,,Total
245 ,,,1,2,
246 y,1,Count,4,3,7
247 ,2,Count,1,1,2
248 Total,,Count,5,4,9
249 ])
250 AT_CLEANUP
251
252 # Bug #26739, which caused CROSSTABS to crash or to fail to output
253 # chi-square results.
254 AT_SETUP([CROSSTABS chi-square crash])
255 AT_DATA([crosstabs.sps],
256   [[DATA LIST LIST /x * y *.
257 BEGIN DATA.
258 2 2
259 3 1
260 4 2
261 4 1
262 END DATA.
263
264 CROSSTABS
265         /TABLES= x BY y
266         /STATISTICS=CHISQ.
267 ]])
268 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
269   [[Table: Reading free-form data from INLINE.
270 Variable,Format
271 x,F8.0
272 y,F8.0
273
274 Table: Summary
275 ,Cases,,,,,
276 ,Valid,,Missing,,Total,
277 ,N,Percent,N,Percent,N,Percent
278 x × y,4,100.0%,0,.0%,4,100.0%
279
280 Table: x × y
281 ,,,y,,Total
282 ,,,1.00,2.00,
283 x,2.00,Count,0,1,1
284 ,3.00,Count,1,0,1
285 ,4.00,Count,1,1,2
286 Total,,Count,2,2,4
287
288 Table: Chi-Square Tests
289 ,Value,df,Asymptotic Sig. (2-tailed)
290 Pearson Chi-Square,2.00,2,.368
291 Likelihood Ratio,2.77,2,.250
292 Linear-by-Linear Association,.27,1,.602
293 N of Valid Cases,4,,
294 ]])
295 AT_CLEANUP
296
297 # Bug #27883.
298 AT_SETUP([CROSSTABS crash with SPLIT FILE])
299 AT_DATA([crosstabs.sps],
300   [data list notable / v0 to v2 1-6 (A)
301 begin data.
302 a c e
303 a c e
304 a c e
305 a d e
306 a d f
307 b d f
308 b d f
309 b c f
310 b d e
311 a c f
312 end data.
313 SORT CASES BY v0.
314 SPLIT FILE SEPARATE BY v0.
315
316 CROSSTABS
317     /TABLES= v1 BY v2
318     /FORMAT=AVALUE TABLES
319     /STATISTICS=CHISQ
320     /CELLS=COUNT ROW COLUMN TOTAL.
321 ])
322
323 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
324 AT_CHECK([cat pspp.csv], [0], [dnl
325 Table: Split Values
326 Variable,Value
327 v0,a
328
329 Table: Summary
330 ,Cases,,,,,
331 ,Valid,,Missing,,Total,
332 ,N,Percent,N,Percent,N,Percent
333 v1 × v2,6,100.0%,0,.0%,6,100.0%
334
335 Table: v1 × v2
336 ,,,v2,,Total
337 ,,,e,f,
338 v1,c,Count,3,1,4
339 ,,Row %,75.0%,25.0%,100.0%
340 ,,Column %,75.0%,50.0%,66.7%
341 ,,Total %,50.0%,16.7%,66.7%
342 ,d,Count,1,1,2
343 ,,Row %,50.0%,50.0%,100.0%
344 ,,Column %,25.0%,50.0%,33.3%
345 ,,Total %,16.7%,16.7%,33.3%
346 Total,,Count,4,2,6
347 ,,Row %,66.7%,33.3%,100.0%
348 ,,Column %,100.0%,100.0%,100.0%
349 ,,Total %,66.7%,33.3%,100.0%
350
351 Table: Chi-Square Tests
352 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
353 Pearson Chi-Square,.38,1,.540,,
354 Likelihood Ratio,.37,1,.545,,
355 Fisher's Exact Test,,,,1.000,.600
356 Continuity Correction,.00,1,1.000,,
357 N of Valid Cases,6,,,,
358
359 Table: Split Values
360 Variable,Value
361 v0,b
362
363 Table: Summary
364 ,Cases,,,,,
365 ,Valid,,Missing,,Total,
366 ,N,Percent,N,Percent,N,Percent
367 v1 × v2,4,100.0%,0,.0%,4,100.0%
368
369 Table: v1 × v2
370 ,,,v2,,Total
371 ,,,e,f,
372 v1,c,Count,0,1,1
373 ,,Row %,.0%,100.0%,100.0%
374 ,,Column %,.0%,33.3%,25.0%
375 ,,Total %,.0%,25.0%,25.0%
376 ,d,Count,1,2,3
377 ,,Row %,33.3%,66.7%,100.0%
378 ,,Column %,100.0%,66.7%,75.0%
379 ,,Total %,25.0%,50.0%,75.0%
380 Total,,Count,1,3,4
381 ,,Row %,25.0%,75.0%,100.0%
382 ,,Column %,100.0%,100.0%,100.0%
383 ,,Total %,25.0%,75.0%,100.0%
384
385 Table: Chi-Square Tests
386 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
387 Pearson Chi-Square,.44,1,.505,,
388 Likelihood Ratio,.68,1,.410,,
389 Fisher's Exact Test,,,,1.000,.750
390 Continuity Correction,.00,1,1.000,,
391 N of Valid Cases,4,,,,
392 ])
393 AT_CLEANUP
394
395 # Bug #24752.
396 AT_SETUP([3-way CROSSTABS])
397 AT_DATA([crosstabs.sps],
398   [[DATA LIST FIXED
399      / x   1-2
400        y   3
401        z   4.
402
403 BEGIN DATA.
404 0111
405 0222
406 0311
407 0412
408 0521
409 0612
410 0711
411 0811
412 0912
413 END DATA.
414
415 LIST.
416
417
418 CROSSTABS TABLES  x BY y BY z/STATISTICS=ALL.
419 ]])
420 AT_CHECK([pspp -o - -O format=csv -o pspp.csv -o pspp.txt crosstabs.sps], [0],
421   [Table: Reading 1 record from INLINE.
422 Variable,Record,Columns,Format
423 x,1,1-2,F2.0
424 y,1,3-3,F1.0
425 z,1,4-4,F1.0
426
427 Table: Data List
428 x,y,z
429 1,1,1
430 2,2,2
431 3,1,1
432 4,1,2
433 5,2,1
434 6,1,2
435 7,1,1
436 8,1,1
437 9,1,2
438
439 Table: Summary
440 ,Cases,,,,,
441 ,Valid,,Missing,,Total,
442 ,N,Percent,N,Percent,N,Percent
443 x × y × z,9,100.0%,0,.0%,9,100.0%
444
445 Table: x × y × z
446 ,,,,,y,,Total
447 ,,,,,1,2,
448 z,1,x,1,Count,1,0,1
449 ,,,3,Count,0,0,1
450 ,,,5,Count,1,0,1
451 ,,,7,Count,0,0,1
452 ,,,8,Count,0,1,1
453 ,,Total,,Count,4,1,5
454 ,2,x,2,Count,0,0,1
455 ,,,4,Count,0,1,1
456 ,,,6,Count,0,0,1
457 ,,,9,Count,1,0,1
458 ,,Total,,Count,3,1,4
459
460 Table: Chi-Square Tests
461 ,,,Value,df,Asymptotic Sig. (2-tailed)
462 z,1,Pearson Chi-Square,5.00,4,.287
463 ,,Likelihood Ratio,5.00,4,.287
464 ,,Linear-by-Linear Association,.01,1,.938
465 ,,N of Valid Cases,5,,
466 ,2,Pearson Chi-Square,4.00,3,.261
467 ,,Likelihood Ratio,4.50,3,.212
468 ,,Linear-by-Linear Association,1.58,1,.209
469 ,,N of Valid Cases,4,,
470
471 Table: Symmetric Measures
472 ,,,,Value,Asymp. Std. Error,Approx. T
473 z,1,Nominal by Nominal,Phi,1.00,,
474 ,,,Cramer's V,1.00,,
475 ,,,Contingency Coefficient,.71,,
476 ,,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00
477 ,,,Kendall's tau-c,.00,.32,.00
478 ,,,Gamma,.00,.50,.00
479 ,,,Spearman Correlation,.00,.22,.00
480 ,,Interval by Interval,Pearson's R,.04,.22,.07
481 ,,N of Valid Cases,,5,,
482 ,2,Nominal by Nominal,Phi,1.00,,
483 ,,,Cramer's V,1.00,,
484 ,,,Contingency Coefficient,.71,,
485 ,,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73
486 ,,,Kendall's tau-c,-.75,.43,-1.73
487 ,,,Gamma,-1.00,.00,-1.73
488 ,,,Spearman Correlation,-.77,.17,-1.73
489 ,,Interval by Interval,Pearson's R,-.73,.18,-1.49
490 ,,N of Valid Cases,,4,,
491
492 Table: Directional Measures
493 ,,,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
494 z,1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
495 ,,,,x Dependent,.25,.22,1.12,.264
496 ,,,,y Dependent,1.00,.00,1.12,.264
497 ,,,Goodman and Kruskal tau,x Dependent,.25,,,
498 ,,,,y Dependent,1.00,,,
499 ,,,Uncertainty Coefficient,Symmetric,.47,.18,,
500 ,,,,x Dependent,.31,.15,2.02,
501 ,,,,y Dependent,1.00,.00,2.02,
502 ,,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
503 ,,,,x Dependent,.00,.50,.00,1.000
504 ,,,,y Dependent,.00,.20,.00,1.000
505 ,,Nominal by Interval,Eta,x Dependent,.04,,,
506 ,,,,y Dependent,1.00,,,
507 ,2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
508 ,,,,x Dependent,.33,.27,1.15,.248
509 ,,,,y Dependent,1.00,.00,1.15,.248
510 ,,,Goodman and Kruskal tau,x Dependent,.33,,,
511 ,,,,y Dependent,1.00,,,
512 ,,,Uncertainty Coefficient,Symmetric,.58,.17,,
513 ,,,,x Dependent,.41,.17,2.36,
514 ,,,,y Dependent,1.00,.00,2.36,
515 ,,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
516 ,,,,x Dependent,-1.00,.00,-1.73,.083
517 ,,,,y Dependent,-.50,.29,-1.73,.083
518 ,,Nominal by Interval,Eta,x Dependent,.73,,,
519 ,,,,y Dependent,1.00,,,
520 ])
521 AT_CLEANUP
522
523 AT_SETUP([CROSSTABS rounding weights with COUNT])
524 AT_DATA([crosstabs.sps],
525   [[DATA LIST NOTABLE LIST /x y w.
526 BEGIN DATA.
527 1 1 1.4
528 1 1 1.4
529 1 2 1.6
530 1 2 1.6
531 2 1 1
532 2 2 2
533 END DATA.
534 WEIGHT BY w.
535
536 * These should have the same effect (no rounding).
537 CROSSTABS /TABLES x BY y.
538 CROSSTABS /TABLES x BY y /COUNT ASIS.
539
540 * Round input weights.
541 CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
542 CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
543
544 * Round cell weights.
545 CROSSTABS /TABLES x BY y /COUNT.
546 CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
547 ]])
548
549 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
550 AT_CHECK([cat pspp.csv], [0],
551   [Table: Summary
552 ,Cases,,,,,
553 ,Valid,,Missing,,Total,
554 ,N,Percent,N,Percent,N,Percent
555 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
556
557 Table: x × y
558 ,,,y,,Total
559 ,,,1.00,2.00,
560 x,1.00,Count,2.80,3.20,6.00
561 ,2.00,Count,1.00,2.00,3.00
562 Total,,Count,3.80,5.20,9.00
563
564 Table: Summary
565 ,Cases,,,,,
566 ,Valid,,Missing,,Total,
567 ,N,Percent,N,Percent,N,Percent
568 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
569
570 Table: x × y
571 ,,,y,,Total
572 ,,,1.00,2.00,
573 x,1.00,Count,2.80,3.20,6.00
574 ,2.00,Count,1.00,2.00,3.00
575 Total,,Count,3.80,5.20,9.00
576
577 Table: Summary
578 ,Cases,,,,,
579 ,Valid,,Missing,,Total,
580 ,N,Percent,N,Percent,N,Percent
581 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
582
583 Table: x × y
584 ,,,y,,Total
585 ,,,1.00,2.00,
586 x,1.00,Count,2.00,4.00,6.00
587 ,2.00,Count,1.00,2.00,3.00
588 Total,,Count,3.00,6.00,9.00
589
590 Table: Summary
591 ,Cases,,,,,
592 ,Valid,,Missing,,Total,
593 ,N,Percent,N,Percent,N,Percent
594 x × y,7.00,100.0%,.00,.0%,7.00,100.0%
595
596 Table: x × y
597 ,,,y,,Total
598 ,,,1.00,2.00,
599 x,1.00,Count,2.00,2.00,4.00
600 ,2.00,Count,1.00,2.00,3.00
601 Total,,Count,3.00,4.00,7.00
602
603 Table: Summary
604 ,Cases,,,,,
605 ,Valid,,Missing,,Total,
606 ,N,Percent,N,Percent,N,Percent
607 x × y,9.00,100.0%,.00,.0%,9.00,100.0%
608
609 Table: x × y
610 ,,,y,,Total
611 ,,,1.00,2.00,
612 x,1.00,Count,3.00,3.00,6.00
613 ,2.00,Count,1.00,2.00,3.00
614 Total,,Count,4.00,5.00,9.00
615
616 Table: Summary
617 ,Cases,,,,,
618 ,Valid,,Missing,,Total,
619 ,N,Percent,N,Percent,N,Percent
620 x × y,8.00,100.0%,.00,.0%,8.00,100.0%
621
622 Table: x × y
623 ,,,y,,Total
624 ,,,1.00,2.00,
625 x,1.00,Count,2.00,3.00,5.00
626 ,2.00,Count,1.00,2.00,3.00
627 Total,,Count,3.00,5.00,8.00
628 ])
629 AT_CLEANUP
630
631 AT_SETUP([CROSSTABS descending sort order])
632 AT_DATA([crosstabs-descending.sps],
633   [[DATA LIST NOTABLE LIST /x * y *.
634 BEGIN DATA.
635 2 2
636 2 2
637 3 1
638 4 1
639 3 2
640 3 2
641 END DATA.
642
643 CROSSTABS
644         /TABLES= x BY y
645         /FORMAT = DVALUE.
646 ]])
647
648 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs-descending.sps])
649 AT_CHECK([cat pspp.csv], [0],
650   [Table: Summary
651 ,Cases,,,,,
652 ,Valid,,Missing,,Total,
653 ,N,Percent,N,Percent,N,Percent
654 x × y,6,100.0%,0,.0%,6,100.0%
655
656 Table: x × y
657 ,,,y,,Total
658 ,,,2.00,1.00,
659 x,4.00,Count,0,1,1
660 ,3.00,Count,2,1,3
661 ,2.00,Count,2,0,2
662 Total,,Count,4,2,6
663 ])
664 AT_CLEANUP
665
666 # Bug #31260.
667 AT_SETUP([CROSSTABS crash when all cases missing])
668 AT_DATA([crosstabs.sps], [dnl
669 DATA LIST LIST NOTABLE /X1 X2.
670 BEGIN DATA.
671 1 1
672 END DATA.
673
674 MISSING VALUES x2 (1).
675
676 CROSSTABS /TABLES= X1 by X2.
677 ])
678 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
679 Table: Summary
680 ,Cases,,,,,
681 ,Valid,,Missing,,Total,
682 ,N,Percent,N,Percent,N,Percent
683 X1 × X2,0,.0%,1,100.0%,1,100.0%
684
685 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 × X2 contained no non-missing cases.
686 ])
687 AT_CLEANUP
688
689
690
691 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
692 AT_SETUP([CROSSTABS Fisher Exact Test])
693
694 AT_DATA([fisher-exact.sps], [dnl
695 SET FORMAT F12.3.
696 SET DECIMAL DOT.
697
698 DATA LIST notable LIST  /schtyp (F9.2) female (F9.2) ses (F9.2) .
699 begin data.
700       1.00       .00      1.00
701       1.00      1.00      2.00
702       1.00       .00      3.00
703       1.00       .00      3.00
704       1.00       .00      2.00
705       1.00       .00      2.00
706       1.00       .00      2.00
707       1.00       .00      2.00
708       1.00       .00      2.00
709       1.00       .00      2.00
710       1.00       .00      2.00
711       1.00       .00      2.00
712       1.00       .00      3.00
713       1.00       .00      3.00
714       1.00       .00      1.00
715       1.00       .00      1.00
716       1.00       .00      3.00
717       2.00       .00      2.00
718       1.00       .00      3.00
719       1.00       .00      2.00
720       1.00       .00      2.00
721       1.00       .00      2.00
722       1.00       .00      2.00
723       1.00       .00      3.00
724       1.00       .00      2.00
725       1.00       .00      2.00
726       1.00       .00      3.00
727       2.00       .00      2.00
728       2.00       .00      3.00
729       1.00       .00      1.00
730       1.00       .00      2.00
731       1.00       .00      3.00
732       2.00       .00      3.00
733       1.00       .00      2.00
734       2.00       .00      3.00
735       1.00       .00      3.00
736       2.00       .00      2.00
737       1.00       .00      3.00
738       1.00       .00      1.00
739       1.00       .00      2.00
740       2.00       .00      2.00
741       2.00       .00      2.00
742       1.00       .00      2.00
743       1.00       .00      1.00
744       1.00       .00      3.00
745       1.00       .00      1.00
746       1.00       .00      3.00
747       1.00       .00      2.00
748       2.00       .00      2.00
749       1.00       .00      2.00
750       1.00       .00      2.00
751       1.00       .00      3.00
752       1.00       .00      2.00
753       2.00       .00      2.00
754       1.00       .00      2.00
755       1.00       .00      3.00
756       1.00       .00      1.00
757       1.00       .00      2.00
758       2.00       .00      2.00
759       1.00       .00      2.00
760       2.00       .00      2.00
761       1.00       .00      3.00
762       1.00       .00      1.00
763       1.00       .00      2.00
764       2.00       .00      3.00
765       1.00       .00      2.00
766       1.00       .00      2.00
767       1.00       .00      1.00
768       1.00       .00      1.00
769       1.00       .00      2.00
770       1.00       .00      2.00
771       1.00       .00      3.00
772       1.00       .00      2.00
773       1.00       .00      2.00
774       1.00       .00      2.00
775       1.00       .00      1.00
776       1.00       .00      3.00
777       1.00       .00      3.00
778       1.00       .00      2.00
779       1.00       .00      3.00
780       1.00       .00      3.00
781       1.00       .00      1.00
782       2.00       .00      2.00
783       1.00       .00      1.00
784       1.00       .00      2.00
785       1.00       .00      3.00
786       1.00       .00      3.00
787       1.00       .00      3.00
788       1.00       .00      2.00
789       1.00       .00      3.00
790       1.00       .00      2.00
791       1.00       .00      1.00
792       1.00      1.00      3.00
793       1.00      1.00      1.00
794       1.00      1.00      1.00
795       1.00      1.00      1.00
796       1.00      1.00      2.00
797       1.00      1.00      3.00
798       1.00      1.00      1.00
799       2.00      1.00      3.00
800       1.00      1.00      3.00
801       1.00      1.00      3.00
802       1.00      1.00      1.00
803       1.00      1.00      3.00
804       1.00      1.00      2.00
805       1.00      1.00      2.00
806       1.00      1.00      3.00
807       1.00      1.00      1.00
808       2.00      1.00      1.00
809       2.00      1.00      3.00
810       1.00      1.00      2.00
811       1.00      1.00      1.00
812       1.00      1.00      3.00
813       1.00      1.00      1.00
814       2.00      1.00      3.00
815       1.00      1.00      2.00
816       1.00      1.00      3.00
817       1.00      1.00      3.00
818       1.00      1.00      1.00
819       1.00      1.00      1.00
820       2.00      1.00      1.00
821       1.00      1.00      2.00
822       1.00      1.00      2.00
823       1.00      1.00      2.00
824       1.00      1.00      1.00
825       1.00      1.00      3.00
826       1.00      1.00      2.00
827       1.00      1.00      2.00
828       1.00      1.00      3.00
829       1.00      1.00      1.00
830       1.00      1.00      2.00
831       1.00      1.00      1.00
832       1.00      1.00      2.00
833       1.00      1.00      2.00
834       1.00      1.00      1.00
835       1.00      1.00      3.00
836       2.00      1.00      2.00
837       1.00      1.00      2.00
838       1.00      1.00      2.00
839       2.00      1.00      2.00
840       1.00      1.00      1.00
841       1.00      1.00      3.00
842       1.00      1.00      2.00
843       1.00      1.00      2.00
844       1.00      1.00      2.00
845       2.00      1.00      3.00
846       1.00      1.00      2.00
847       2.00      1.00      2.00
848       1.00      1.00      1.00
849       1.00      1.00      1.00
850       1.00      1.00      1.00
851       1.00      1.00      3.00
852       1.00      1.00      2.00
853       1.00      1.00      2.00
854       1.00      1.00      2.00
855       1.00      1.00      2.00
856       1.00      1.00      2.00
857       1.00      1.00      2.00
858       1.00      1.00      2.00
859       1.00      1.00      3.00
860       1.00      1.00      1.00
861       1.00      1.00      2.00
862       2.00      1.00      3.00
863       1.00      1.00      1.00
864       1.00      1.00      2.00
865       1.00      1.00      1.00
866       1.00      1.00      2.00
867       1.00      1.00      1.00
868       2.00      1.00      2.00
869       1.00      1.00      1.00
870       1.00      1.00      1.00
871       1.00      1.00      2.00
872       1.00      1.00      3.00
873       1.00      1.00      3.00
874       1.00      1.00      1.00
875       1.00      1.00      1.00
876       1.00      1.00      2.00
877       1.00      1.00      2.00
878       1.00      1.00      3.00
879       1.00      1.00      1.00
880       1.00      1.00      2.00
881       2.00      1.00      2.00
882       1.00      1.00      3.00
883       1.00      1.00      2.00
884       1.00      1.00      3.00
885       1.00      1.00      1.00
886       1.00      1.00      2.00
887       1.00      1.00      2.00
888       2.00      1.00      3.00
889       1.00      1.00      1.00
890       1.00      1.00      1.00
891       2.00      1.00      3.00
892       2.00      1.00      2.00
893       1.00      1.00      3.00
894       2.00      1.00      2.00
895       2.00      1.00      2.00
896       1.00      1.00      2.00
897       2.00      1.00      2.00
898       1.00      1.00      2.00
899       1.00      1.00      3.00
900 end data.
901
902 VARIABLE LABEL schtyp 'type of school'.
903 ADD VALUE LABELS female 0 male 1 female.
904 ADD VALUE LABELS ses 1 low 2 middle 3 high.
905 ADD VALUE LABELS schtyp 1 public 2 private.
906
907 crosstabs /tables = schtyp by female /statistic = chisq.
908 crosstabs /tables = female by ses  /statistic = chisq.
909 ])
910
911 AT_CHECK([pspp -o pspp.csv -o pspp.txt fisher-exact.sps])
912 AT_CHECK([cat pspp.csv], [0], [Table: Summary
913 ,Cases,,,,,
914 ,Valid,,Missing,,Total,
915 ,N,Percent,N,Percent,N,Percent
916 type of school × female,200,100.0%,0,.0%,200,100.0%
917
918 Table: type of school × female
919 ,,,female,,Total
920 ,,,male,female,
921 type of school,public,Count,77,91,168
922 ,private,Count,14,18,32
923 Total,,Count,91,109,200
924
925 Table: Chi-Square Tests
926 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
927 Pearson Chi-Square,.047,1,.828,,
928 Likelihood Ratio,.047,1,.828,,
929 Fisher's Exact Test,,,,.849,.492
930 Continuity Correction,.001,1,.981,,
931 Linear-by-Linear Association,.047,1,.829,,
932 N of Valid Cases,200,,,,
933
934 Table: Summary
935 ,Cases,,,,,
936 ,Valid,,Missing,,Total,
937 ,N,Percent,N,Percent,N,Percent
938 female × ses,200,100.0%,0,.0%,200,100.0%
939
940 Table: female × ses
941 ,,,ses,,,Total
942 ,,,low,middle,high,
943 female,male,Count,15,47,29,91
944 ,female,Count,32,48,29,109
945 Total,,Count,47,95,58,200
946
947 Table: Chi-Square Tests
948 ,Value,df,Asymptotic Sig. (2-tailed)
949 Pearson Chi-Square,4.577,2,.101
950 Likelihood Ratio,4.679,2,.096
951 Linear-by-Linear Association,3.110,1,.078
952 N of Valid Cases,200,,
953 ])
954
955 AT_CLEANUP
956
957 AT_SETUP([CROSSTABS Pearson's R - 1])
958 AT_DATA([pearson.sps], [dnl
959 SET FORMAT F8.3.
960
961 * From http://www.statisticslectures.com/topics/pearsonr/.
962 DATA LIST FREE/x y.
963 BEGIN DATA.
964 1 4
965 3 6
966 5 10
967 5 12
968 6 13
969 END DATA.
970 CROSSTABS x BY y/STATISTICS=CORR.
971 ])
972 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson.sps])
973 AT_CHECK([cat pspp.csv], [0], [dnl
974 Table: Summary
975 ,Cases,,,,,
976 ,Valid,,Missing,,Total,
977 ,N,Percent,N,Percent,N,Percent
978 x × y,5,100.0%,0,.0%,5,100.0%
979
980 Table: x × y
981 ,,,y,,,,,Total
982 ,,,4.000,6.000,10.000,12.000,13.000,
983 x,1.000,Count,1,0,0,0,0,1
984 ,3.000,Count,0,1,0,0,0,1
985 ,5.000,Count,0,0,1,1,0,2
986 ,6.000,Count,0,0,0,0,1,1
987 Total,,Count,1,1,1,1,1,5
988
989 Table: Symmetric Measures
990 ,,Value,Asymp. Std. Error,Approx. T
991 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550
992 Interval by Interval,Pearson's R,.968,.017,6.708
993 N of Valid Cases,,5,,
994 ])
995 AT_CLEANUP
996
997 AT_SETUP([CROSSTABS Pearson's R - 2])
998 AT_DATA([pearson2.sps], [dnl
999 SET FORMAT F8.3.
1000
1001 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
1002 DATA LIST FREE/x y.
1003 BEGIN DATA.
1004 1 1.5
1005 2 1.5
1006 3 4
1007 4 6
1008 5 5
1009 6 7
1010 7 6.5
1011 8 9
1012 9 10.5
1013 10 11
1014 END DATA.
1015 CROSSTABS x BY y/STATISTICS=CORR.
1016 ])
1017 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson2.sps])
1018 AT_CHECK([cat pspp.csv], [0], [dnl
1019 Table: Summary
1020 ,Cases,,,,,
1021 ,Valid,,Missing,,Total,
1022 ,N,Percent,N,Percent,N,Percent
1023 x × y,10,100.0%,0,.0%,10,100.0%
1024
1025 Table: x × y
1026 ,,,y,,,,,,,,,Total
1027 ,,,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,
1028 x,1.000,Count,1,0,0,0,0,0,0,0,0,1
1029 ,2.000,Count,1,0,0,0,0,0,0,0,0,1
1030 ,3.000,Count,0,1,0,0,0,0,0,0,0,1
1031 ,4.000,Count,0,0,0,1,0,0,0,0,0,1
1032 ,5.000,Count,0,0,1,0,0,0,0,0,0,1
1033 ,6.000,Count,0,0,0,0,0,1,0,0,0,1
1034 ,7.000,Count,0,0,0,0,1,0,0,0,0,1
1035 ,8.000,Count,0,0,0,0,0,0,1,0,0,1
1036 ,9.000,Count,0,0,0,0,0,0,0,1,0,1
1037 ,10.000,Count,0,0,0,0,0,0,0,0,1,1
1038 Total,,Count,2,1,1,1,1,1,1,1,1,10
1039
1040 Table: Symmetric Measures
1041 ,,Value,Asymp. Std. Error,Approx. T
1042 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844
1043 Interval by Interval,Pearson's R,.971,.017,11.580
1044 N of Valid Cases,,10,,
1045 ])
1046 AT_CLEANUP
1047
1048 AT_SETUP([CROSSTABS Pearson's R - 3])
1049 AT_DATA([pearson3.sps], [dnl
1050 SET FORMAT F8.3.
1051
1052 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
1053 DATA LIST FREE/x y.
1054 BEGIN DATA.
1055 56 87
1056 56 91
1057 65 85
1058 65 91
1059 50 75
1060 25 28
1061 87 122
1062 44 66
1063 35 58
1064 END DATA.
1065 CROSSTABS x BY y/STATISTICS=CORR.
1066 ])
1067 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson3.sps])
1068 AT_CHECK([cat pspp.csv], [0], [dnl
1069 Table: Summary
1070 ,Cases,,,,,
1071 ,Valid,,Missing,,Total,
1072 ,N,Percent,N,Percent,N,Percent
1073 x × y,9,100.0%,0,.0%,9,100.0%
1074
1075 Table: x × y
1076 ,,,y,,,,,,,,Total
1077 ,,,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,
1078 x,25.000,Count,1,0,0,0,0,0,0,0,1
1079 ,35.000,Count,0,1,0,0,0,0,0,0,1
1080 ,44.000,Count,0,0,1,0,0,0,0,0,1
1081 ,50.000,Count,0,0,0,1,0,0,0,0,1
1082 ,56.000,Count,0,0,0,0,0,1,1,0,2
1083 ,65.000,Count,0,0,0,0,1,0,1,0,2
1084 ,87.000,Count,0,0,0,0,0,0,0,1,1
1085 Total,,Count,1,1,1,1,1,1,2,1,9
1086
1087 Table: Symmetric Measures
1088 ,,Value,Asymp. Std. Error,Approx. T
1089 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860
1090 Interval by Interval,Pearson's R,.966,.017,9.915
1091 N of Valid Cases,,9,,
1092 ])
1093 AT_CLEANUP
1094
1095 AT_SETUP([CROSSTABS Pearson's R - 4])
1096 AT_DATA([pearson4.sps], [dnl
1097 SET FORMAT F8.3.
1098
1099 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
1100 DATA LIST FREE/x y.
1101 BEGIN DATA.
1102 5 5
1103 10 20
1104 6 4
1105 8 15
1106 4 11
1107 4 9
1108 3 12
1109 10 18
1110 2 7
1111 6 2
1112 7 14
1113 9 17
1114 END DATA.
1115 CROSSTABS x BY y/STATISTICS=CORR.
1116 ])
1117 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson4.sps])
1118 AT_CHECK([cat pspp.csv], [0], [dnl
1119 Table: Summary
1120 ,Cases,,,,,
1121 ,Valid,,Missing,,Total,
1122 ,N,Percent,N,Percent,N,Percent
1123 x × y,12,100.0%,0,.0%,12,100.0%
1124
1125 Table: x × y
1126 ,,,y,,,,,,,,,,,,Total
1127 ,,,2.000,4.000,5.000,7.000,9.000,11.000,12.000,14.000,15.000,17.000,18.000,20.000,
1128 x,2.000,Count,0,0,0,1,0,0,0,0,0,0,0,0,1
1129 ,3.000,Count,0,0,0,0,0,0,1,0,0,0,0,0,1
1130 ,4.000,Count,0,0,0,0,1,1,0,0,0,0,0,0,2
1131 ,5.000,Count,0,0,1,0,0,0,0,0,0,0,0,0,1
1132 ,6.000,Count,1,1,0,0,0,0,0,0,0,0,0,0,2
1133 ,7.000,Count,0,0,0,0,0,0,0,1,0,0,0,0,1
1134 ,8.000,Count,0,0,0,0,0,0,0,0,1,0,0,0,1
1135 ,9.000,Count,0,0,0,0,0,0,0,0,0,1,0,0,1
1136 ,10.000,Count,0,0,0,0,0,0,0,0,0,0,1,1,2
1137 Total,,Count,1,1,1,1,1,1,1,1,1,1,1,1,12
1138
1139 Table: Symmetric Measures
1140 ,,Value,Asymp. Std. Error,Approx. T
1141 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758
1142 Interval by Interval,Pearson's R,.667,.132,2.830
1143 N of Valid Cases,,12,,
1144 ])
1145 AT_CLEANUP
1146
1147 AT_SETUP([CROSSTABS Pearson's R - 5])
1148 AT_DATA([pearson5.sps], [dnl
1149 SET FORMAT F8.3.
1150
1151 * From http://www.statisticslectures.com/topics/pearsonr/.
1152 DATA LIST FREE/x y.
1153 BEGIN DATA.
1154 18 15000
1155 25 29000
1156 57 68000
1157 45 52000
1158 26 32000
1159 64 80000
1160 37 41000
1161 40 45000
1162 24 26000
1163 33 33000
1164 END DATA.
1165 CROSSTABS x BY y/STATISTICS=CORR.
1166 ])
1167 AT_CHECK([pspp -o pspp.csv -o pspp.txt pearson5.sps])
1168 AT_CHECK([cat pspp.csv], [0], [dnl
1169 Table: Summary
1170 ,Cases,,,,,
1171 ,Valid,,Missing,,Total,
1172 ,N,Percent,N,Percent,N,Percent
1173 x × y,10,100.0%,0,.0%,10,100.0%
1174
1175 Table: x × y
1176 ,,,y,,,,,,,,,,Total
1177 ,,,15000.00,26000.00,29000.00,32000.00,33000.00,41000.00,45000.00,52000.00,68000.00,80000.00,
1178 x,18.000,Count,1,0,0,0,0,0,0,0,0,0,1
1179 ,24.000,Count,0,1,0,0,0,0,0,0,0,0,1
1180 ,25.000,Count,0,0,1,0,0,0,0,0,0,0,1
1181 ,26.000,Count,0,0,0,1,0,0,0,0,0,0,1
1182 ,33.000,Count,0,0,0,0,1,0,0,0,0,0,1
1183 ,37.000,Count,0,0,0,0,0,1,0,0,0,0,1
1184 ,40.000,Count,0,0,0,0,0,0,1,0,0,0,1
1185 ,45.000,Count,0,0,0,0,0,0,0,1,0,0,1
1186 ,57.000,Count,0,0,0,0,0,0,0,0,1,0,1
1187 ,64.000,Count,0,0,0,0,0,0,0,0,0,1,1
1188 Total,,Count,1,1,1,1,1,1,1,1,1,1,10
1189
1190 Table: Symmetric Measures
1191 ,,Value,Asymp. Std. Error,Approx. T
1192 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinit
1193 Interval by Interval,Pearson's R,.992,.004,22.638
1194 N of Valid Cases,,10,,
1195 ])
1196 AT_CLEANUP
1197
1198 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 1])
1199 AT_DATA([lambda.sps], [dnl
1200 SET FORMAT F8.3.
1201
1202 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
1203 DATA LIST LIST NOTABLE/x y w.
1204 WEIGHT BY w.
1205 BEGIN DATA.
1206 1 1 424
1207 1 2 213
1208 1 3 59
1209 3 1 55
1210 3 2 188
1211 3 3 357
1212 END DATA.
1213
1214 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1215 ])
1216 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1217 AT_CHECK([cat pspp.csv], [0], [dnl
1218 Table: Summary
1219 ,Cases,,,,,
1220 ,Valid,,Missing,,Total,
1221 ,N,Percent,N,Percent,N,Percent
1222 x × y,1296.000,100.0%,.000,.0%,1296.000,100.0%
1223
1224 Table: Directional Measures
1225 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1226 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1227 ,,x Dependent,.497,.024,15.986,.000
1228 ,,y Dependent,.370,.020,16.339,.000
1229 ,Goodman and Kruskal tau,x Dependent,.382,,,
1230 ,,y Dependent,.198,,,
1231 ])
1232 AT_CLEANUP
1233
1234 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 2])
1235 AT_DATA([lambda.sps], [dnl
1236 SET FORMAT F8.3.
1237
1238 * From http://vassarstats.net.
1239 DATA LIST LIST NOTABLE/x y w.
1240 WEIGHT BY w.
1241 BEGIN DATA.
1242 1 1 19
1243 1 2 26
1244 1 3 8
1245 2 1 21
1246 2 2 13
1247 2 3 5
1248 3 1 6
1249 3 2 12
1250 3 3 27
1251 END DATA.
1252
1253 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1254 ])
1255 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1256 AT_CHECK([cat pspp.csv], [0], [dnl
1257 Table: Summary
1258 ,Cases,,,,,
1259 ,Valid,,Missing,,Total,
1260 ,N,Percent,N,Percent,N,Percent
1261 x × y,137.000,100.0%,.000,.0%,137.000,100.0%
1262
1263 Table: Directional Measures
1264 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1265 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1266 ,,x Dependent,.250,.089,2.479,.013
1267 ,,y Dependent,.267,.085,2.766,.006
1268 ,Goodman and Kruskal tau,x Dependent,.129,,,
1269 ,,y Dependent,.123,,,
1270 ])
1271 AT_CLEANUP
1272
1273 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - 3])
1274 AT_DATA([lambda.sps], [dnl
1275 SET FORMAT F8.3.
1276
1277 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1278   cross classifications". Part I. Journal of the American Statistical
1279   Association, 49, 732-764.
1280 DATA LIST LIST NOTABLE/x y w.
1281 WEIGHT BY w.
1282 BEGIN DATA.
1283 1 1 1768
1284 1 2 807
1285 1 3 189
1286 1 4 47
1287 2 1 946
1288 2 2 1387
1289 2 3 746
1290 2 4 53
1291 3 1 115
1292 3 2 438
1293 3 3 288
1294 3 4 16
1295 END DATA.
1296 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1297 ])
1298 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1299 AT_CHECK([cat pspp.csv], [0], [dnl
1300 Table: Summary
1301 ,Cases,,,,,
1302 ,Valid,,Missing,,Total,
1303 ,N,Percent,N,Percent,N,Percent
1304 x × y,6800.000,100.0%,.000,.0%,6800.000,100.0%
1305
1306 Table: Directional Measures
1307 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1308 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1309 ,,x Dependent,.224,.013,16.076,.000
1310 ,,y Dependent,.192,.012,14.438,.000
1311 ,Goodman and Kruskal tau,x Dependent,.089,,,
1312 ,,y Dependent,.081,,,
1313 ])
1314 AT_CLEANUP
1315
1316 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1317 AT_DATA([lambda.sps], [dnl
1318 SET FORMAT F8.3.
1319
1320 * From Douglas Bonett.
1321 DATA LIST LIST NOTABLE/x y w.
1322 WEIGHT BY w.
1323 BEGIN DATA.
1324 1 1 225
1325 1 2 43
1326 1 3 216
1327 2 1 3
1328 2 2 1
1329 2 3 12
1330 END DATA.
1331
1332 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1333 ])
1334 AT_CHECK([pspp -o pspp.csv -o pspp.txt lambda.sps])
1335 AT_CHECK([cat pspp.csv], [0], [dnl
1336 Table: Summary
1337 ,Cases,,,,,
1338 ,Valid,,Missing,,Total,
1339 ,N,Percent,N,Percent,N,Percent
1340 x × y,500.000,100.0%,.000,.0%,500.000,100.0%
1341
1342 Table: Directional Measures
1343 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1344 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1345 ,,x Dependent,.000,.000,NaN,NaN
1346 ,,y Dependent,.033,.014,2.336,.019
1347 ,Goodman and Kruskal tau,x Dependent,.012,,,
1348 ,,y Dependent,.009,,,
1349 ])
1350 AT_CLEANUP
1351
1352 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 1])
1353 AT_DATA([somersd.sps], [dnl
1354 SET FORMAT F8.3.
1355
1356 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1357 DATA LIST LIST NOTABLE/x y * w (F10.6).
1358 WEIGHT BY w.
1359 BEGIN DATA.
1360 1 1 0.000025
1361 1 2 0.0001
1362 1 3 0.001
1363 1 4 0.0025
1364 1 5 0.004
1365 1 6 0.0075
1366 1 7 0.0125
1367 2 1 0.049975
1368 2 2 0.0999
1369 2 3 0.199
1370 2 4 0.2475
1371 2 5 0.196
1372 2 6 0.1425
1373 2 7 0.0375
1374 END DATA.
1375 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1376 ])
1377 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1378 AT_CHECK([cat pspp.csv], [0], [dnl
1379 Table: Summary
1380 ,Cases,,,,,
1381 ,Valid,,Missing,,Total,
1382 ,N,Percent,N,Percent,N,Percent
1383 x × y,1.000000,100.0%,.000000,.0%,1.000000,100.0%
1384
1385 Table: Directional Measures
1386 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1387 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1388 ,,x Dependent,-.045,.300,-.149,.882
1389 ,,y Dependent,-.684,2.378,-.149,.882
1390 ])
1391 AT_CLEANUP
1392
1393 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 2])
1394 AT_DATA([somersd.sps], [dnl
1395 SET FORMAT F8.3.
1396
1397 * From http://uregina.ca/~gingrich/gamma.pdf.
1398 DATA LIST LIST NOTABLE/x y w.
1399 WEIGHT BY w.
1400 BEGIN DATA.
1401 1 1 34
1402 1 2 24
1403 1 3 15
1404 2 1 42
1405 2 2 74
1406 2 3 67
1407 3 1 28
1408 3 2 111
1409 3 3 292
1410 END DATA.
1411 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1412 ])
1413 AT_CHECK([pspp -o pspp.csv -o pspp.txt somersd.sps])
1414 AT_CHECK([cat pspp.csv], [0], [dnl
1415 Table: Summary
1416 ,Cases,,,,,
1417 ,Valid,,Missing,,Total,
1418 ,N,Percent,N,Percent,N,Percent
1419 x × y,687.000,100.0%,.000,.0%,687.000,100.0%
1420
1421 Table: Symmetric Measures
1422 ,,Value,Asymp. Std. Error,Approx. T
1423 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669
1424 ,Kendall's tau-c,.310,.029,10.669
1425 ,Gamma,.591,.043,10.669
1426 N of Valid Cases,,687.000,,
1427
1428 Table: Directional Measures
1429 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1430 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1431 ,,x Dependent,.351,.032,10.669,.000
1432 ,,y Dependent,.394,.035,10.669,.000
1433 ])
1434 AT_CLEANUP
1435
1436 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma - 3])
1437 AT_DATA([ordinal.sps], [dnl
1438 SET FORMAT F8.3.
1439
1440 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1441 DATA LIST LIST NOTABLE /x y w.
1442 WEIGHT BY w.
1443 BEGIN DATA.
1444 1 2 40
1445 2 3 80
1446 3 4 30
1447 END DATA.
1448 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1449
1450 * Same site, case 2.
1451 DATA LIST LIST NOTABLE /x y w.
1452 WEIGHT BY w.
1453 BEGIN DATA.
1454 1 1 40
1455 2 3 80
1456 3 4 30
1457 END DATA.
1458 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1459
1460 * Same site, case 3.
1461 DATA LIST LIST NOTABLE /x y w.
1462 WEIGHT BY w.
1463 BEGIN DATA.
1464 1 4 40
1465 2 3 80
1466 3 2 30
1467 END DATA.
1468 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1469
1470 * Same site, case 4.
1471 DATA LIST LIST NOTABLE /x y w.
1472 WEIGHT BY w.
1473 BEGIN DATA.
1474 1 1 20
1475 1 2 20
1476 2 3 80
1477 3 4 30
1478 END DATA.
1479 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1480
1481 * Same site, case 5.
1482 DATA LIST LIST NOTABLE /x y w.
1483 WEIGHT BY w.
1484 BEGIN DATA.
1485 1 2 40
1486 2 2 80
1487 3 2 29
1488 3 3 1
1489 END DATA.
1490 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1491
1492 * Same site, case 6.
1493 DATA LIST LIST NOTABLE /x y w.
1494 WEIGHT BY w.
1495 BEGIN DATA.
1496 1 1 3
1497 1 2 6
1498 1 3 28
1499 1 4 61
1500 2 1 4
1501 2 2 5
1502 2 3 21
1503 2 4 20
1504 END DATA.
1505 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1506
1507 * Same site, case 7.
1508 DATA LIST LIST NOTABLE /x y w.
1509 WEIGHT BY w.
1510 BEGIN DATA.
1511 1 1 38
1512 1 2 6
1513 1 3 3
1514 1 4 51
1515 2 1 4
1516 2 2 20
1517 2 3 21
1518 2 4 5
1519 END DATA.
1520 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1521
1522 * Same site, case 8.
1523 DATA LIST LIST NOTABLE /x y w.
1524 WEIGHT BY w.
1525 BEGIN DATA.
1526 1 1 2
1527 1 2 3
1528 1 3 5
1529 1 4 1
1530 2 1 2
1531 2 2 16
1532 2 3 3
1533 2 4 6
1534 3 1 3
1535 3 2 10
1536 3 3 35
1537 3 4 27
1538 4 1 6
1539 4 2 15
1540 4 3 33
1541 4 4 45
1542 END DATA.
1543 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1544 ])
1545 AT_CHECK([pspp -o pspp.csv -o pspp.txt ordinal.sps])
1546 AT_CHECK([cat pspp.csv], [0], [dnl
1547 Table: Summary
1548 ,Cases,,,,,
1549 ,Valid,,Missing,,Total,
1550 ,N,Percent,N,Percent,N,Percent
1551 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1552
1553 Table: Symmetric Measures
1554 ,,Value,Asymp. Std. Error,Approx. T
1555 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1556 ,Gamma,1.000,.000,24.841
1557 N of Valid Cases,,150.000,,
1558
1559 Table: Directional Measures
1560 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1561 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1562 ,,x Dependent,1.000,.000,24.841,.000
1563 ,,y Dependent,1.000,.000,24.841,.000
1564
1565 Table: Summary
1566 ,Cases,,,,,
1567 ,Valid,,Missing,,Total,
1568 ,N,Percent,N,Percent,N,Percent
1569 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1570
1571 Table: Symmetric Measures
1572 ,,Value,Asymp. Std. Error,Approx. T
1573 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841
1574 ,Gamma,1.000,.000,24.841
1575 N of Valid Cases,,150.000,,
1576
1577 Table: Directional Measures
1578 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1579 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1580 ,,x Dependent,1.000,.000,24.841,.000
1581 ,,y Dependent,1.000,.000,24.841,.000
1582
1583 Table: Summary
1584 ,Cases,,,,,
1585 ,Valid,,Missing,,Total,
1586 ,N,Percent,N,Percent,N,Percent
1587 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1588
1589 Table: Symmetric Measures
1590 ,,Value,Asymp. Std. Error,Approx. T
1591 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841
1592 ,Gamma,-1.000,.000,-24.841
1593 N of Valid Cases,,150.000,,
1594
1595 Table: Directional Measures
1596 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1597 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1598 ,,x Dependent,-1.000,.000,-24.841,.000
1599 ,,y Dependent,-1.000,.000,-24.841,.000
1600
1601 Table: Summary
1602 ,Cases,,,,,
1603 ,Valid,,Missing,,Total,
1604 ,N,Percent,N,Percent,N,Percent
1605 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1606
1607 Table: Symmetric Measures
1608 ,,Value,Asymp. Std. Error,Approx. T
1609 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841
1610 ,Gamma,1.000,.000,24.841
1611 N of Valid Cases,,150.000,,
1612
1613 Table: Directional Measures
1614 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1615 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1616 ,,x Dependent,.944,.013,24.841,.000
1617 ,,y Dependent,1.000,.000,24.841,.000
1618
1619 Table: Summary
1620 ,Cases,,,,,
1621 ,Valid,,Missing,,Total,
1622 ,N,Percent,N,Percent,N,Percent
1623 x × y,150.000,100.0%,.000,.0%,150.000,100.0%
1624
1625 Table: Symmetric Measures
1626 ,,Value,Asymp. Std. Error,Approx. T
1627 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009
1628 ,Gamma,1.000,.000,1.009
1629 N of Valid Cases,,150.000,,
1630
1631 Table: Directional Measures
1632 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1633 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1634 ,,x Dependent,.805,.032,1.009,.313
1635 ,,y Dependent,.018,.017,1.009,.313
1636
1637 Table: Summary
1638 ,Cases,,,,,
1639 ,Valid,,Missing,,Total,
1640 ,N,Percent,N,Percent,N,Percent
1641 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1642
1643 Table: Symmetric Measures
1644 ,,Value,Asymp. Std. Error,Approx. T
1645 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641
1646 ,Gamma,-.381,.130,-2.641
1647 N of Valid Cases,,148.000,,
1648
1649 Table: Directional Measures
1650 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1651 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1652 ,,x Dependent,-.182,.069,-2.641,.008
1653 ,,y Dependent,-.237,.089,-2.641,.008
1654
1655 Table: Summary
1656 ,Cases,,,,,
1657 ,Valid,,Missing,,Total,
1658 ,N,Percent,N,Percent,N,Percent
1659 x × y,148.000,100.0%,.000,.0%,148.000,100.0%
1660
1661 Table: Symmetric Measures
1662 ,,Value,Asymp. Std. Error,Approx. T
1663 Nominal by Nominal,Phi,.731,,
1664 ,Cramer's V,.731,,
1665 Ordinal by Ordinal,Gamma,-.110,.107,-1.022
1666 N of Valid Cases,,148.000,,
1667
1668 Table: Directional Measures
1669 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1670 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1671 ,,x Dependent,.640,.085,4.875,.000
1672 ,,y Dependent,.174,.050,3.248,.001
1673 ,Goodman and Kruskal tau,x Dependent,.534,,,
1674 ,,y Dependent,.167,,,
1675 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1676 ,,x Dependent,-.060,.059,-1.022,.307
1677 ,,y Dependent,-.096,.094,-1.022,.307
1678
1679 Table: Summary
1680 ,Cases,,,,,
1681 ,Valid,,Missing,,Total,
1682 ,N,Percent,N,Percent,N,Percent
1683 x × y,212.000,100.0%,.000,.0%,212.000,100.0%
1684
1685 Table: Symmetric Measures
1686 ,,Value,Asymp. Std. Error,Approx. T
1687 Nominal by Nominal,Phi,.432,,
1688 ,Cramer's V,.249,,
1689 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338
1690 N of Valid Cases,,212.000,,
1691
1692 Table: Directional Measures
1693 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1694 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1695 ,,x Dependent,.027,.087,.302,.763
1696 ,,y Dependent,.165,.065,2.349,.019
1697 ,Goodman and Kruskal tau,x Dependent,.051,,,
1698 ,,y Dependent,.068,,,
1699 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1700 ,,x Dependent,.202,.060,3.338,.001
1701 ,,y Dependent,.217,.064,3.338,.001
1702 ])
1703 AT_CLEANUP
1704
1705 AT_SETUP([CROSSTABS Cohens Kappa])
1706
1707 dnl Example from Wood J. M.
1708 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1709 dnl WebPsychEmpiricist. Oct 3 2007
1710 AT_DATA([kappa.sps], [dnl
1711 SET FORMAT=F8.3.
1712
1713 data list notable list /p1 * p2 * w *.
1714 begin data.
1715 0 0 18
1716 1 0 1
1717 0 1 1
1718 end data.
1719
1720 weight by w.
1721
1722 crosstabs /table = p1 by p2
1723         /statistics = kappa
1724         .
1725 ])
1726
1727 AT_CHECK([pspp -o pspp.csv -o pspp.txt kappa.sps])
1728 AT_CHECK([cat pspp.csv], [0], [dnl
1729 Table: Summary
1730 ,Cases,,,,,
1731 ,Valid,,Missing,,Total,
1732 ,N,Percent,N,Percent,N,Percent
1733 p1 × p2,20.000,100.0%,.000,.0%,20.000,100.0%
1734
1735 Table: p1 × p2
1736 ,,,p2,,Total
1737 ,,,.000,1.000,
1738 p1,.000,Count,18.000,1.000,19.000
1739 ,1.000,Count,1.000,.000,1.000
1740 Total,,Count,19.000,1.000,20.000
1741
1742 Table: Symmetric Measures
1743 ,,Value,Asymp. Std. Error,Approx. T
1744 Measure of Agreement,Kappa,-.053,.037,-.235
1745 N of Valid Cases,,20.000,,
1746 ])
1747
1748 AT_CLEANUP
1749
1750
1751 AT_SETUP([CROSSTABS many statistics])
1752 AT_DATA([crosstabs.sps], [dnl
1753 SET FORMAT=F8.4.
1754
1755 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1756 DATA LIST LIST NOTABLE/x y w.
1757 WEIGHT BY w.
1758 BEGIN DATA.
1759 1 1 25
1760 1 2 25
1761 1 3 12
1762 2 2 1
1763 2 3 3
1764 END DATA.
1765 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1766 ])
1767 AT_CHECK([pspp -o pspp.csv -o pspp.txt crosstabs.sps])
1768 AT_CHECK([cat pspp.csv], [0], [dnl
1769 Table: Summary
1770 ,Cases,,,,,
1771 ,Valid,,Missing,,Total,
1772 ,N,Percent,N,Percent,N,Percent
1773 x × y,66.0000,100.0%,.0000,.0%,66.0000,100.0%
1774
1775 Table: Chi-Square Tests
1776 ,Value,df,Asymptotic Sig. (2-tailed)
1777 Pearson Chi-Square,6.9562,2.0000,.031
1778 Likelihood Ratio,6.6901,2.0000,.035
1779 Linear-by-Linear Association,5.8450,1.0000,.016
1780 N of Valid Cases,66.0000,,
1781
1782 Table: Symmetric Measures
1783 ,,Value,Asymp. Std. Error,Approx. T
1784 Nominal by Nominal,Phi,.3246,,
1785 ,Cramer's V,.3246,,
1786 ,Contingency Coefficient,.3088,,
1787 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920
1788 ,Kendall's tau-c,.1497,.0751,1.9920
1789 ,Gamma,.8717,.1250,1.9920
1790 ,Spearman Correlation,.2908,.0906,2.4311
1791 Interval by Interval,Pearson's R,.2999,.0973,2.5147
1792 N of Valid Cases,,66.0000,,
1793
1794 Table: Directional Measures
1795 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1796 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1797 ,,x Dependent,.0000,.0000,NaN,NaN
1798 ,,y Dependent,.0500,.1791,.2723,.785
1799 ,Goodman and Kruskal tau,x Dependent,.1054,,,
1800 ,,y Dependent,.0434,,,
1801 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,
1802 ,,x Dependent,.2217,.1062,1.5373,
1803 ,,y Dependent,.0473,.0306,1.5373,
1804 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1805 ,,x Dependent,.1152,.0572,1.9920,.046
1806 ,,y Dependent,.6573,.1417,1.9920,.046
1807 ])
1808 AT_CLEANUP
1809
1810 AT_SETUP([CROSSTABS uncertainy coefficient])
1811 AT_DATA([uc.sps], [dnl
1812 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1813 SET FORMAT=F8.3.
1814
1815 DATA LIST LIST NOTABLE/x y w.
1816 WEIGHT BY w.
1817 BEGIN DATA.
1818 1 1 416
1819 1 2 121
1820 2 1 335
1821 2 2 2
1822 3 1 112
1823 3 2 1
1824 END DATA.
1825 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1826 ])
1827 AT_CHECK([pspp -o pspp.csv -o pspp.txt uc.sps])
1828 AT_CHECK([cat pspp.csv], [0], [dnl
1829 Table: Summary
1830 ,Cases,,,,,
1831 ,Valid,,Missing,,Total,
1832 ,N,Percent,N,Percent,N,Percent
1833 x × y,987.000,100.0%,.000,.0%,987.000,100.0%
1834
1835 Table: Directional Measures
1836 ,,,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1837 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1838 ,,x Dependent,.000,.000,NaN,NaN
1839 ,,y Dependent,.000,.000,NaN,NaN
1840 ,Goodman and Kruskal tau,x Dependent,.076,,,
1841 ,,y Dependent,.108,,,
1842 ,Uncertainty Coefficient,Symmetric,.105,.012,,
1843 ,,x Dependent,.073,.009,7.890,
1844 ,,y Dependent,.184,.019,7.890,
1845 ])
1846 AT_CLEANUP
1847
1848 AT_SETUP([CROSSTABS estimated risk])
1849 dnl Example data and expected output from
1850 dnl http://www.psychology.nottingham.ac.uk/staff/ddc/c8cxpa/further/Project_resources/SPSSCrosstabW.pdf
1851 AT_DATA([risk.sps], [dnl
1852 DATA LIST LIST /factor disease count (F8.0).
1853 WEIGHT BY count.
1854 VALUE LABELS /factor 0 'Placebo' 1 'Aspirin'
1855              /disease 1 'No' 0 'Yes'.
1856 BEGIN DATA.
1857 0 1 80
1858 0 0 20
1859 1 1 135
1860 1 0 15
1861 END DATA.
1862 CROSSTABS factor BY disease/STATISTICS=RISK CHISQ.
1863 ])
1864 AT_CHECK([pspp -o pspp.csv -o pspp.txt risk.sps])
1865 AT_CHECK([cat pspp.csv], [0], [dnl
1866 Table: Reading free-form data from INLINE.
1867 Variable,Format
1868 factor,F8.0
1869 disease,F8.0
1870 count,F8.0
1871
1872 Table: Summary
1873 ,Cases,,,,,
1874 ,Valid,,Missing,,Total,
1875 ,N,Percent,N,Percent,N,Percent
1876 factor × disease,250,100.0%,0,.0%,250,100.0%
1877
1878 Table: factor × disease
1879 ,,,disease,,Total
1880 ,,,Yes,No,
1881 factor,Placebo,Count,20,80,100
1882 ,Aspirin,Count,15,135,150
1883 Total,,Count,35,215,250
1884
1885 Table: Chi-Square Tests
1886 ,Value,df,Asymptotic Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
1887 Pearson Chi-Square,4.98,1,.026,,
1888 Likelihood Ratio,4.88,1,.027,,
1889 Fisher's Exact Test,,,,.039,.021
1890 Continuity Correction,4.19,1,.041,,
1891 Linear-by-Linear Association,4.96,1,.026,,
1892 N of Valid Cases,250,,,,
1893
1894 Table: Risk Estimate
1895 ,Value,95% Confidence Interval,
1896 ,,Lower,Upper
1897 Odds Ratio for factor (Placebo / Aspirin),2.25,2.25,2.25
1898 For cohort disease = Yes,1.08,1.08,1.08
1899 For cohort disease = No,.99,.99,.99
1900 N of Valid Cases,250.00,,
1901 ])
1902 AT_CLEANUP
1903
1904 AT_SETUP([CROSSTABS barchart])
1905 AT_DATA([bc.sps], [dnl
1906 SET FORMAT=F8.3.
1907
1908 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1909 BEGIN DATA.
1910 This  1  0 416
1911 That  2  0 121
1912 Other 2  0 335
1913 This  2  0 231
1914 That  3  0 112
1915 Other 4  0 130
1916 This  1  1 160
1917 That  2  1 211
1918 Other 2  1 352
1919 This  2  1 212
1920 That  3  1 121
1921 Other 4  1 101
1922 END DATA.
1923
1924 WEIGHT BY w.
1925
1926 CROSSTABS
1927           /table x BY y BY z
1928           /table x BY y
1929           /barchart.
1930 ])
1931
1932 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1933
1934 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1935 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1936
1937 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])
1938
1939 AT_CLEANUP