1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
17 AT_BANNER([CROSSTABS procedure])
19 AT_SETUP([CROSSTABS integer mode crash])
20 AT_DATA([crosstabs.sps],
21 [DATA LIST LIST /A * B * X * Y * .
26 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
28 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
29 [[Table: Reading free-form data from INLINE.
38 ,Valid,,Missing,,Total,
39 ,N,Percent,N,Percent,N,Percent
40 X * Y,1,100.0%,0,0.0%,1,100.0%
44 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
45 1.00,.00,.00,.00,.00,.00,.00,.00,.00
46 2.00,.00,.00,.00,.00,.00,.00,.00,.00
47 3.00,.00,.00,.00,.00,.00,.00,.00,.00
48 4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
49 5.00,.00,.00,.00,.00,.00,.00,.00,.00
50 6.00,.00,.00,.00,.00,.00,.00,.00,.00
51 7.00,.00,.00,.00,.00,.00,.00,.00,.00
52 Total,.00,.00,.00,.00,1.00,.00,.00,1.00
57 AT_SETUP([CROSSTABS integer mode crash 2])
58 AT_DATA([crosstabs.sps], [dnl
65 VARIABLES x (1,3) y (1,7)
68 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
69 [[Table: Reading free-form data from INLINE.
76 ,Valid,,Missing,,Total,
77 ,N,Percent,N,Percent,N,Percent
78 x * y,0,0.0%,1,100.0%,1,100.0%
83 AT_SETUP([CROSSTABS long string crash])
84 AT_DATA([crosstabs.sps],
85 [data list list /x * y (a18).
96 CROSSTABS /TABLES = x BY y.
98 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
99 [[Table: Reading free-form data from INLINE.
104 "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."
106 "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."
110 ,Valid,,Missing,,Total,
111 ,N,Percent,N,Percent,N,Percent
112 x * y,4,66.7%,2,33.3%,6,100.0%
114 Table: x * y [count].
116 x,one unity ,three lots ,two duality ,zero none ,Total
117 1.00,1.00,.00,.00,1.00,2.00
118 2.00,.00,.00,1.00,.00,1.00
119 3.00,.00,1.00,.00,.00,1.00
120 Total,1.00,1.00,1.00,1.00,4.00
124 AT_SETUP([CROSSTABS crash])
125 AT_DATA([crosstabs.sps],
146 CROSSTABS TABLES y by z.
148 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
149 [[Table: Reading 1 record from INLINE.
150 Variable,Record,Columns,Format
169 ,Valid,,Missing,,Total,
170 ,N,Percent,N,Percent,N,Percent
171 y * z,9,100.0%,0,0.0%,9,100.0%
173 Table: y * z [count].
182 # Bug #26739, which caused CROSSTABS to crash or to fail to output
183 # chi-square results.
184 AT_SETUP([CROSSTABS chi-square crash])
185 AT_DATA([crosstabs.sps],
186 [[DATA LIST LIST /x * y *.
198 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
199 [[Table: Reading free-form data from INLINE.
206 ,Valid,,Missing,,Total,
207 ,N,Percent,N,Percent,N,Percent
208 x * y,4,100.0%,0,0.0%,4,100.0%
210 Table: x * y [count].
218 Table: Chi-square tests.
219 Statistic,Value,df,Asymp. Sig. (2-tailed)
220 Pearson Chi-Square,2.00,2,.368
221 Likelihood Ratio,2.77,2,.250
222 Linear-by-Linear Association,.27,1,.602
228 AT_SETUP([CROSSTABS crash with SPLIT FILE])
229 AT_DATA([crosstabs.sps],
230 [data list notable / v0 to v2 1-6 (A)
244 SPLIT FILE SEPARATE BY v0.
248 /FORMAT=AVALUE TABLES PIVOT
250 /CELLS=COUNT ROW COLUMN TOTAL.
253 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
254 [[Variable,Value,Label
259 ,Valid,,Missing,,Total,
260 ,N,Percent,N,Percent,N,Percent
261 v1 * v2,6,100.0%,0,0.0%,6,100.0%
263 "Table: v1 * v2 [count, row %, column %, total %]."
267 ,75.00%,25.00%,100.00%
268 ,75.00%,50.00%,66.67%
269 ,50.00%,16.67%,66.67%
271 ,50.00%,50.00%,100.00%
272 ,25.00%,50.00%,33.33%
273 ,16.67%,16.67%,33.33%
275 ,66.67%,33.33%,100.00%
276 ,100.00%,100.00%,100.00%
277 ,66.67%,33.33%,100.00%
279 Table: Chi-square tests.
280 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
281 Pearson Chi-Square,.38,1,.540,,
282 Likelihood Ratio,.37,1,.545,,
283 Fisher's Exact Test,,,,1.000,.600
284 Continuity Correction,.00,1,1.000,,
285 N of Valid Cases,6,,,,
292 ,Valid,,Missing,,Total,
293 ,N,Percent,N,Percent,N,Percent
294 v1 * v2,4,100.0%,0,0.0%,4,100.0%
296 "Table: v1 * v2 [count, row %, column %, total %]."
300 ,.00%,100.00%,100.00%
304 ,33.33%,66.67%,100.00%
305 ,100.00%,66.67%,75.00%
306 ,25.00%,50.00%,75.00%
308 ,25.00%,75.00%,100.00%
309 ,100.00%,100.00%,100.00%
310 ,25.00%,75.00%,100.00%
312 Table: Chi-square tests.
313 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
314 Pearson Chi-Square,.44,1,.505,,
315 Likelihood Ratio,.68,1,.410,,
316 Fisher's Exact Test,,,,1.000,.750
317 Continuity Correction,.00,1,1.000,,
318 N of Valid Cases,4,,,,
323 AT_SETUP([3-way CROSSTABS])
324 AT_DATA([crosstabs.sps],
345 CROSSTABS TABLES x BY y BY z/STATISTICS=ALL.
347 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
348 [[Table: Reading 1 record from INLINE.
349 Variable,Record,Columns,Format
368 ,Valid,,Missing,,Total,
369 ,N,Percent,N,Percent,N,Percent
370 x * y * z,9,100.0%,0,0.0%,9,100.0%
372 Table: x * y * z [count].
380 Total,,4.00,1.00,5.00
385 Total,,3.00,1.00,4.00
387 Table: Chi-square tests.
388 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
389 1,Pearson Chi-Square,5.00,4,.287
390 ,Likelihood Ratio,5.00,4,.287
391 ,Linear-by-Linear Association,.01,1,.938
392 ,N of Valid Cases,5,,
393 2,Pearson Chi-Square,4.00,3,.261
394 ,Likelihood Ratio,4.50,3,.212
395 ,Linear-by-Linear Association,1.58,1,.209
396 ,N of Valid Cases,4,,
398 Table: Symmetric measures.
399 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
400 1,Nominal by Nominal,Phi,1.00,,,
402 ,,Contingency Coefficient,.71,,,
403 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
404 ,,Kendall's tau-c,.00,.32,.00,
406 ,,Spearman Correlation,.00,.22,.00,
407 ,Interval by Interval,Pearson's R,.04,.22,.07,
408 ,N of Valid Cases,,5,,,
409 2,Nominal by Nominal,Phi,1.00,,,
411 ,,Contingency Coefficient,.71,,,
412 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
413 ,,Kendall's tau-c,-.75,.43,-1.73,
414 ,,Gamma,-1.00,.00,-1.73,
415 ,,Spearman Correlation,-.77,.17,-1.73,
416 ,Interval by Interval,Pearson's R,-.73,.18,-1.49,
417 ,N of Valid Cases,,4,,,
419 Table: Directional measures.
420 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
421 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
422 ,,,x Dependent,.25,.22,1.12,.264
423 ,,,y Dependent,1.00,.00,1.12,.264
424 ,,Goodman and Kruskal tau,x Dependent,.25,,,. @&t@
425 ,,,y Dependent,1.00,,,. @&t@
426 ,,Uncertainty Coefficient,Symmetric,.47,.18,,. @&t@
427 ,,,x Dependent,.31,.15,2.02,. @&t@
428 ,,,y Dependent,1.00,.00,2.02,. @&t@
429 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
430 ,,,x Dependent,.00,.50,.00,1.000
431 ,,,y Dependent,.00,.20,.00,1.000
432 ,Nominal by Interval,Eta,x Dependent,.04,,,. @&t@
433 ,,,y Dependent,1.00,,,. @&t@
434 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
435 ,,,x Dependent,.33,.27,1.15,.248
436 ,,,y Dependent,1.00,.00,1.15,.248
437 ,,Goodman and Kruskal tau,x Dependent,.33,,,. @&t@
438 ,,,y Dependent,1.00,,,. @&t@
439 ,,Uncertainty Coefficient,Symmetric,.58,.17,,. @&t@
440 ,,,x Dependent,.41,.17,2.36,. @&t@
441 ,,,y Dependent,1.00,.00,2.36,. @&t@
442 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
443 ,,,x Dependent,-1.00,.00,-1.73,.083
444 ,,,y Dependent,-.50,.29,-1.73,.083
445 ,Nominal by Interval,Eta,x Dependent,.73,,,. @&t@
446 ,,,y Dependent,1.00,,,. @&t@
450 AT_SETUP([CROSSTABS rounding weights with COUNT])
451 AT_DATA([crosstabs.sps],
452 [[DATA LIST NOTABLE LIST /x y w.
463 * These should have the same effect (no rounding).
464 CROSSTABS /TABLES x BY y.
465 CROSSTABS /TABLES x BY y /COUNT ASIS.
467 * Round input weights.
468 CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
469 CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
471 * Round cell weights.
472 CROSSTABS /TABLES x BY y /COUNT.
473 CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
476 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
479 ,Valid,,Missing,,Total,
480 ,N,Percent,N,Percent,N,Percent
481 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
483 Table: x * y [count].
492 ,Valid,,Missing,,Total,
493 ,N,Percent,N,Percent,N,Percent
494 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
496 Table: x * y [count].
505 ,Valid,,Missing,,Total,
506 ,N,Percent,N,Percent,N,Percent
507 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
509 Table: x * y [count].
518 ,Valid,,Missing,,Total,
519 ,N,Percent,N,Percent,N,Percent
520 x * y,7.00,100.0%,.00,0.0%,7.00,100.0%
522 Table: x * y [count].
531 ,Valid,,Missing,,Total,
532 ,N,Percent,N,Percent,N,Percent
533 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
535 Table: x * y [count].
544 ,Valid,,Missing,,Total,
545 ,N,Percent,N,Percent,N,Percent
546 x * y,8.00,100.0%,.00,0.0%,8.00,100.0%
548 Table: x * y [count].
557 AT_SETUP([CROSSTABS descending sort order])
558 AT_DATA([crosstabs-descending.sps],
559 [[DATA LIST NOTABLE LIST /x * y *.
574 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
577 ,Valid,,Missing,,Total,
578 ,N,Percent,N,Percent,N,Percent
579 x * y,6,100.0%,0,0.0%,6,100.0%
581 Table: x * y [count].
592 AT_SETUP([CROSSTABS crash when all cases missing])
593 AT_DATA([crosstabs.sps], [dnl
594 DATA LIST LIST NOTABLE /X1 X2.
599 MISSING VALUES x2 (1).
601 CROSSTABS /TABLES= X1 by X2.
603 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
606 ,Valid,,Missing,,Total,
607 ,N,Percent,N,Percent,N,Percent
608 X1 * X2,0,0.0%,1,100.0%,1,100.0%
610 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
616 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
617 AT_SETUP([CROSSTABS Fisher Exact Test])
619 AT_DATA([fisher-exact.sps], [dnl
623 DATA LIST notable LIST /schtyp (F9.2) female (F9.2) ses (F9.2) .
827 VARIABLE LABEL schtyp 'type of school'.
828 ADD VALUE LABELS female 0 male 1 female.
829 ADD VALUE LABELS ses 1 low 2 middle 3 high.
830 ADD VALUE LABELS schtyp 1 public 2 private.
832 crosstabs /tables = schtyp by female /statistic = chisq.
833 crosstabs /tables = female by ses /statistic = chisq.
836 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
839 ,Valid,,Missing,,Total,
840 ,N,Percent,N,Percent,N,Percent
841 type of school * female,200,100.0%,0,0.0%,200,100.0%
843 Table: type of school * female [[count]].
845 type of school,male,female,Total
846 public,77.000,91.000,168.000
847 private,14.000,18.000,32.000
848 Total,91.000,109.000,200.000
850 Table: Chi-square tests.
851 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
852 Pearson Chi-Square,.047,1,.828,,
853 Likelihood Ratio,.047,1,.828,,
854 Fisher's Exact Test,,,,.849,.492
855 Continuity Correction,.001,1,.981,,
856 Linear-by-Linear Association,.047,1,.829,,
857 N of Valid Cases,200,,,,
861 ,Valid,,Missing,,Total,
862 ,N,Percent,N,Percent,N,Percent
863 female * ses,200,100.0%,0,0.0%,200,100.0%
865 Table: female * ses [[count]].
867 female,low,middle,high,Total
868 male,15.000,47.000,29.000,91.000
869 female,32.000,48.000,29.000,109.000
870 Total,47.000,95.000,58.000,200.000
872 Table: Chi-square tests.
873 Statistic,Value,df,Asymp. Sig. (2-tailed)
874 Pearson Chi-Square,4.577,2,.101
875 Likelihood Ratio,4.679,2,.096
876 Linear-by-Linear Association,3.110,1,.078
877 N of Valid Cases,200,,
882 AT_SETUP([CROSSTABS Pearson's R])
884 AT_DATA([pearson.sps], [dnl
887 * From http://www.statisticslectures.com/topics/pearsonr/.
896 CROSSTABS x BY y/STATISTICS=CORR.
898 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
901 ,Valid,,Missing,,Total,
902 ,N,Percent,N,Percent,N,Percent
903 x * y,5,100.0%,0,0.0%,5,100.0%
905 Table: x * y [[count]].
907 x,4.000,6.000,10.000,12.000,13.000,Total
908 1.000,1.000,.000,.000,.000,.000,1.000
909 3.000,.000,1.000,.000,.000,.000,1.000
910 5.000,.000,.000,1.000,1.000,.000,2.000
911 6.000,.000,.000,.000,.000,1.000,1.000
912 Total,1.000,1.000,1.000,1.000,1.000,5.000
914 Table: Symmetric measures.
915 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
916 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550,
917 Interval by Interval,Pearson's R,.968,.017,6.708,
918 N of Valid Cases,,5,,,
922 AT_DATA([pearson2.sps], [dnl
925 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
939 CROSSTABS x BY y/STATISTICS=CORR.
941 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
944 ,Valid,,Missing,,Total,
945 ,N,Percent,N,Percent,N,Percent
946 x * y,10,100.0%,0,0.0%,10,100.0%
948 Table: x * y [[count]].
949 ,y,,,,,,,,,
950 x,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,Total
951 1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
952 2.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
953 3.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
954 4.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
955 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
956 6.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
957 7.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
958 8.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
959 9.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
960 10.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
961 Total,2.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
963 Table: Symmetric measures.
964 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
965 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844,
966 Interval by Interval,Pearson's R,.971,.017,11.580,
967 N of Valid Cases,,10,,,
971 AT_DATA([pearson3.sps], [dnl
974 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
987 CROSSTABS x BY y/STATISTICS=CORR.
989 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
992 ,Valid,,Missing,,Total,
993 ,N,Percent,N,Percent,N,Percent
994 x * y,9,100.0%,0,0.0%,9,100.0%
996 Table: x * y [[count]].
998 x,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,Total
999 25.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
1000 35.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
1001 44.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1002 50.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1003 56.000,.000,.000,.000,.000,.000,1.000,1.000,.000,2.000
1004 65.000,.000,.000,.000,.000,1.000,.000,1.000,.000,2.000
1005 87.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
1006 Total,1.000,1.000,1.000,1.000,1.000,1.000,2.000,1.000,9.000
1008 Table: Symmetric measures.
1009 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1010 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860,
1011 Interval by Interval,Pearson's R,.966,.017,9.915,
1012 N of Valid Cases,,9,,,
1016 AT_DATA([pearson4.sps], [dnl
1019 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
1035 CROSSTABS x BY y/STATISTICS=CORR.
1037 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
1040 ,Valid,,Missing,,Total,
1041 ,N,Percent,N,Percent,N,Percent
1042 x * y,12,100.0%,0,0.0%,12,100.0%
1044 Table: x * y [[count]].
1045 ,y,,,,,,,,,,,,
1046 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
1047 2.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1048 3.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1049 4.000,.000,.000,.000,.000,1.000,1.000,.000,.000,.000,.000,.000,.000,2.000
1050 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1051 6.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,2.000
1052 7.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1053 8.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
1054 9.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
1055 10.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,2.000
1056 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
1058 Table: Symmetric measures.
1059 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1060 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758,
1061 Interval by Interval,Pearson's R,.667,.132,2.830,
1062 N of Valid Cases,,12,,,
1066 AT_DATA([pearson5.sps], [dnl
1069 * From http://www.statisticslectures.com/topics/pearsonr/.
1083 CROSSTABS x BY y/STATISTICS=CORR.
1085 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
1088 ,Valid,,Missing,,Total,
1089 ,N,Percent,N,Percent,N,Percent
1090 x * y,10,100.0%,0,0.0%,10,100.0%
1092 Table: x * y [[count]].
1093 ,y,,,,,,,,,,
1094 x,15000.000,26000.000,29000.000,32000.000,33000.000,41000.000,45000.000,52000.000,68000.000,80000.000,Total
1095 18.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1096 24.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1097 25.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
1098 26.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
1099 33.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1100 37.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1101 40.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
1102 45.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
1103 57.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
1104 64.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
1105 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
1107 Table: Symmetric measures.
1108 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1109 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinity,
1110 Interval by Interval,Pearson's R,.992,.004,22.638,
1111 N of Valid Cases,,10,,,
1115 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda])
1116 AT_DATA([lambda.sps], [dnl
1119 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
1120 DATA LIST LIST NOTABLE/x y w.
1131 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1133 * From http://vassarstats.net.
1134 DATA LIST LIST NOTABLE/x y w.
1148 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1150 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1151 cross classifications". Part I. Journal of the American Statistical
1152 Association, 49, 732-764.
1153 DATA LIST LIST NOTABLE/x y w.
1169 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1171 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1174 ,Valid,,Missing,,Total,
1175 ,N,Percent,N,Percent,N,Percent
1176 x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
1178 Table: Directional measures.
1179 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1180 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1181 ,,x Dependent,.497,.024,15.986,.000
1182 ,,y Dependent,.370,.020,16.339,.000
1183 ,Goodman and Kruskal tau,x Dependent,.382,,,. @&t@
1184 ,,y Dependent,.198,,,. @&t@
1188 ,Valid,,Missing,,Total,
1189 ,N,Percent,N,Percent,N,Percent
1190 x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
1192 Table: Directional measures.
1193 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1194 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1195 ,,x Dependent,.250,.089,2.479,.013
1196 ,,y Dependent,.267,.085,2.766,.006
1197 ,Goodman and Kruskal tau,x Dependent,.129,,,. @&t@
1198 ,,y Dependent,.123,,,. @&t@
1202 ,Valid,,Missing,,Total,
1203 ,N,Percent,N,Percent,N,Percent
1204 x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
1206 Table: Directional measures.
1207 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1208 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1209 ,,x Dependent,.224,.013,16.076,.000
1210 ,,y Dependent,.192,.012,14.438,.000
1211 ,Goodman and Kruskal tau,x Dependent,.089,,,. @&t@
1212 ,,y Dependent,.081,,,. @&t@
1216 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1217 AT_DATA([lambda.sps], [dnl
1220 * From Douglas Bonett.
1221 DATA LIST LIST NOTABLE/x y w.
1232 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1234 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1237 ,Valid,,Missing,,Total,
1238 ,N,Percent,N,Percent,N,Percent
1239 x * y,500.000,100.0%,.000,0.0%,500.000,100.0%
1241 Table: Directional measures.
1242 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1243 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1244 ,,x Dependent,.000,.000,NaN,NaN
1245 ,,y Dependent,.033,.014,2.336,.019
1246 ,Goodman and Kruskal tau,x Dependent,.012,,,. @&t@
1247 ,,y Dependent,.009,,,. @&t@
1251 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma])
1252 AT_DATA([somersd.sps], [dnl
1255 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1256 DATA LIST LIST NOTABLE/x y * w (F10.6).
1274 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1276 * From http://uregina.ca/~gingrich/gamma.pdf.
1277 DATA LIST LIST NOTABLE/x y w.
1290 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1292 AT_CHECK([pspp -O format=csv somersd.sps], [0], [dnl
1295 ,Valid,,Missing,,Total,
1296 ,N,Percent,N,Percent,N,Percent
1297 x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
1299 Table: Directional measures.
1300 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1301 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1302 ,,x Dependent,-.045,.300,-.149,.882
1303 ,,y Dependent,-.684,2.378,-.149,.882
1307 ,Valid,,Missing,,Total,
1308 ,N,Percent,N,Percent,N,Percent
1309 x * y,687.000,100.0%,.000,0.0%,687.000,100.0%
1311 Table: Symmetric measures.
1312 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1313 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669,
1314 ,Kendall's tau-c,.310,.029,10.669,
1315 ,Gamma,.591,.043,10.669,
1316 N of Valid Cases,,687.000,,,
1318 Table: Directional measures.
1319 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1320 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1321 ,,x Dependent,.351,.032,10.669,.000
1322 ,,y Dependent,.394,.035,10.669,.000
1325 AT_DATA([ordinal.sps], [dnl
1328 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1329 DATA LIST LIST NOTABLE /x y w.
1336 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1338 * Same site, case 2.
1339 DATA LIST LIST NOTABLE /x y w.
1346 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1348 * Same site, case 3.
1349 DATA LIST LIST NOTABLE /x y w.
1356 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1358 * Same site, case 4.
1359 DATA LIST LIST NOTABLE /x y w.
1367 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1369 * Same site, case 5.
1370 DATA LIST LIST NOTABLE /x y w.
1378 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1380 * Same site, case 6.
1381 DATA LIST LIST NOTABLE /x y w.
1393 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1395 * Same site, case 7.
1396 DATA LIST LIST NOTABLE /x y w.
1408 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1410 * Same site, case 8.
1411 DATA LIST LIST NOTABLE /x y w.
1431 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1433 AT_CHECK([pspp -O format=csv ordinal.sps], [0], [dnl
1436 ,Valid,,Missing,,Total,
1437 ,N,Percent,N,Percent,N,Percent
1438 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1440 Table: Symmetric measures.
1441 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1442 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1443 ,Gamma,1.000,.000,24.841,
1444 N of Valid Cases,,150.000,,,
1446 Table: Directional measures.
1447 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1448 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1449 ,,x Dependent,1.000,.000,24.841,.000
1450 ,,y Dependent,1.000,.000,24.841,.000
1454 ,Valid,,Missing,,Total,
1455 ,N,Percent,N,Percent,N,Percent
1456 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1458 Table: Symmetric measures.
1459 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1460 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1461 ,Gamma,1.000,.000,24.841,
1462 N of Valid Cases,,150.000,,,
1464 Table: Directional measures.
1465 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1466 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1467 ,,x Dependent,1.000,.000,24.841,.000
1468 ,,y Dependent,1.000,.000,24.841,.000
1472 ,Valid,,Missing,,Total,
1473 ,N,Percent,N,Percent,N,Percent
1474 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1476 Table: Symmetric measures.
1477 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1478 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841,
1479 ,Gamma,-1.000,.000,-24.841,
1480 N of Valid Cases,,150.000,,,
1482 Table: Directional measures.
1483 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1484 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1485 ,,x Dependent,-1.000,.000,-24.841,.000
1486 ,,y Dependent,-1.000,.000,-24.841,.000
1490 ,Valid,,Missing,,Total,
1491 ,N,Percent,N,Percent,N,Percent
1492 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1494 Table: Symmetric measures.
1495 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1496 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841,
1497 ,Gamma,1.000,.000,24.841,
1498 N of Valid Cases,,150.000,,,
1500 Table: Directional measures.
1501 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1502 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1503 ,,x Dependent,.944,.013,24.841,.000
1504 ,,y Dependent,1.000,.000,24.841,.000
1508 ,Valid,,Missing,,Total,
1509 ,N,Percent,N,Percent,N,Percent
1510 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1512 Table: Symmetric measures.
1513 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1514 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009,
1515 ,Gamma,1.000,.000,1.009,
1516 N of Valid Cases,,150.000,,,
1518 Table: Directional measures.
1519 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1520 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1521 ,,x Dependent,.805,.032,1.009,.313
1522 ,,y Dependent,.018,.017,1.009,.313
1526 ,Valid,,Missing,,Total,
1527 ,N,Percent,N,Percent,N,Percent
1528 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1530 Table: Symmetric measures.
1531 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1532 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641,
1533 ,Gamma,-.381,.130,-2.641,
1534 N of Valid Cases,,148.000,,,
1536 Table: Directional measures.
1537 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1538 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1539 ,,x Dependent,-.182,.069,-2.641,.008
1540 ,,y Dependent,-.237,.089,-2.641,.008
1544 ,Valid,,Missing,,Total,
1545 ,N,Percent,N,Percent,N,Percent
1546 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1548 Table: Symmetric measures.
1549 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1550 Nominal by Nominal,Phi,.731,,,
1552 Ordinal by Ordinal,Gamma,-.110,.107,-1.022,
1553 N of Valid Cases,,148.000,,,
1555 Table: Directional measures.
1556 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1557 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1558 ,,x Dependent,.640,.085,4.875,.000
1559 ,,y Dependent,.174,.050,3.248,.001
1560 ,Goodman and Kruskal tau,x Dependent,.534,,,. @&t@
1561 ,,y Dependent,.167,,,. @&t@
1562 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1563 ,,x Dependent,-.060,.059,-1.022,.307
1564 ,,y Dependent,-.096,.094,-1.022,.307
1568 ,Valid,,Missing,,Total,
1569 ,N,Percent,N,Percent,N,Percent
1570 x * y,212.000,100.0%,.000,0.0%,212.000,100.0%
1572 Table: Symmetric measures.
1573 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1574 Nominal by Nominal,Phi,.432,,,
1576 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338,
1577 N of Valid Cases,,212.000,,,
1579 Table: Directional measures.
1580 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1581 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1582 ,,x Dependent,.027,.087,.302,.763
1583 ,,y Dependent,.165,.065,2.349,.019
1584 ,Goodman and Kruskal tau,x Dependent,.051,,,. @&t@
1585 ,,y Dependent,.068,,,. @&t@
1586 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1587 ,,x Dependent,.202,.060,3.338,.001
1588 ,,y Dependent,.217,.064,3.338,.001
1592 AT_SETUP([CROSSTABS Cohens Kappa])
1594 dnl Example from Wood J. M.
1595 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1596 dnl WebPsychEmpiricist. Oct 3 2007
1597 AT_DATA([kappa.sps], [dnl
1600 data list notable list /p1 * p2 * w *.
1609 crosstabs /table = p1 by p2
1614 AT_CHECK([pspp -O format=csv kappa.sps], [0], [dnl
1617 ,Valid,,Missing,,Total,
1618 ,N,Percent,N,Percent,N,Percent
1619 p1 * p2,20.000,100.0%,.000,0.0%,20.000,100.0%
1621 Table: p1 * p2 [[count]].
1624 .000,18.000,1.000,19.000
1625 1.000,1.000,.000,1.000
1626 Total,19.000,1.000,20.000
1628 Table: Symmetric measures.
1629 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1630 Measure of Agreement,Kappa,-.053,.037,-.235,
1631 N of Valid Cases,,20.000,,,
1637 AT_SETUP([CROSSTABS many statistics])
1638 AT_DATA([crosstabs.sps], [dnl
1641 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1642 DATA LIST LIST NOTABLE/x y w.
1651 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1653 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
1656 ,Valid,,Missing,,Total,
1657 ,N,Percent,N,Percent,N,Percent
1658 x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
1660 Table: Chi-square tests.
1661 Statistic,Value,df,Asymp. Sig. (2-tailed)
1662 Pearson Chi-Square,6.9562,2.0000,.031
1663 Likelihood Ratio,6.6901,2.0000,.035
1664 Linear-by-Linear Association,5.8450,1.0000,.016
1665 N of Valid Cases,66.0000,,
1667 Table: Symmetric measures.
1668 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1669 Nominal by Nominal,Phi,.3246,,,
1670 ,Cramer's V,.3246,,,
1671 ,Contingency Coefficient,.3088,,,
1672 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
1673 ,Kendall's tau-c,.1497,.0751,1.9920,
1674 ,Gamma,.8717,.1250,1.9920,
1675 ,Spearman Correlation,.2908,.0906,2.4311,
1676 Interval by Interval,Pearson's R,.2999,.0973,2.5147,
1677 N of Valid Cases,,66.0000,,,
1679 Table: Directional measures.
1680 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1681 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1682 ,,x Dependent,.0000,.0000,NaN,NaN
1683 ,,y Dependent,.0500,.1791,.2723,.785
1684 ,Goodman and Kruskal tau,x Dependent,.1054,,,. @&t@
1685 ,,y Dependent,.0434,,,. @&t@
1686 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,. @&t@
1687 ,,x Dependent,.2217,.1062,1.5373,. @&t@
1688 ,,y Dependent,.0473,.0306,1.5373,. @&t@
1689 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1690 ,,x Dependent,.1152,.0572,1.9920,.046
1691 ,,y Dependent,.6573,.1417,1.9920,.046
1695 AT_SETUP([CROSSTABS uncertainy coefficient])
1696 AT_DATA([uc.sps], [dnl
1697 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1700 DATA LIST LIST NOTABLE/x y w.
1710 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1712 AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
1715 ,Valid,,Missing,,Total,
1716 ,N,Percent,N,Percent,N,Percent
1717 x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
1719 Table: Directional measures.
1720 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1721 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1722 ,,x Dependent,.000,.000,NaN,NaN
1723 ,,y Dependent,.000,.000,NaN,NaN
1724 ,Goodman and Kruskal tau,x Dependent,.076,,,. @&t@
1725 ,,y Dependent,.108,,,. @&t@
1726 ,Uncertainty Coefficient,Symmetric,.105,.012,,. @&t@
1727 ,,x Dependent,.073,.009,7.890,. @&t@
1728 ,,y Dependent,.184,.019,7.890,. @&t@
1734 AT_SETUP([CROSSTABS barchart])
1735 AT_DATA([bc.sps], [dnl
1738 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1762 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1764 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1765 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1767 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])