1 AT_BANNER([CROSSTABS procedure])
3 AT_SETUP([CROSSTABS integer mode crash])
4 AT_DATA([crosstabs.sps],
5 [DATA LIST LIST /A * B * X * Y * .
10 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
12 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
13 [[Table: Reading free-form data from INLINE.
22 ,Valid,,Missing,,Total,
23 ,N,Percent,N,Percent,N,Percent
24 X * Y,1,100.0%,0,0.0%,1,100.0%
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
41 AT_SETUP([CROSSTABS integer mode crash 2])
42 AT_DATA([crosstabs.sps], [dnl
49 VARIABLES x (1,3) y (1,7)
52 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
53 [[Table: Reading free-form data from INLINE.
60 ,Valid,,Missing,,Total,
61 ,N,Percent,N,Percent,N,Percent
62 x * y,0,0.0%,1,100.0%,1,100.0%
67 AT_SETUP([CROSSTABS long string crash])
68 AT_DATA([crosstabs.sps],
69 [data list list /x * y (a18).
80 CROSSTABS /TABLES = x BY y.
82 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
83 [[Table: Reading free-form data from INLINE.
88 "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."
90 "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."
94 ,Valid,,Missing,,Total,
95 ,N,Percent,N,Percent,N,Percent
96 x * y,4,66.7%,2,33.3%,6,100.0%
100 x,one unity ,three lots ,two duality ,zero none ,Total
101 1.00,1.00,.00,.00,1.00,2.00
102 2.00,.00,.00,1.00,.00,1.00
103 3.00,.00,1.00,.00,.00,1.00
104 Total,1.00,1.00,1.00,1.00,4.00
108 AT_SETUP([CROSSTABS crash])
109 AT_DATA([crosstabs.sps],
130 CROSSTABS TABLES y by z.
132 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
133 [[Table: Reading 1 record from INLINE.
134 Variable,Record,Columns,Format
153 ,Valid,,Missing,,Total,
154 ,N,Percent,N,Percent,N,Percent
155 y * z,9,100.0%,0,0.0%,9,100.0%
157 Table: y * z [count].
166 # Bug #26739, which caused CROSSTABS to crash or to fail to output
167 # chi-square results.
168 AT_SETUP([CROSSTABS chi-square crash])
169 AT_DATA([crosstabs.sps],
170 [[DATA LIST LIST /x * y *.
182 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
183 [[Table: Reading free-form data from INLINE.
190 ,Valid,,Missing,,Total,
191 ,N,Percent,N,Percent,N,Percent
192 x * y,4,100.0%,0,0.0%,4,100.0%
194 Table: x * y [count].
202 Table: Chi-square tests.
203 Statistic,Value,df,Asymp. Sig. (2-tailed)
204 Pearson Chi-Square,2.00,2,.368
205 Likelihood Ratio,2.77,2,.250
206 Linear-by-Linear Association,.27,1,.602
212 AT_SETUP([CROSSTABS crash with SPLIT FILE])
213 AT_DATA([crosstabs.sps],
214 [data list notable / v0 to v2 1-6 (A)
228 SPLIT FILE SEPARATE BY v0.
232 /FORMAT=AVALUE TABLES PIVOT
234 /CELLS=COUNT ROW COLUMN TOTAL.
237 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
238 [[Variable,Value,Label
243 ,Valid,,Missing,,Total,
244 ,N,Percent,N,Percent,N,Percent
245 v1 * v2,6,100.0%,0,0.0%,6,100.0%
247 "Table: v1 * v2 [count, row %, column %, total %]."
251 ,75.00%,25.00%,100.00%
252 ,75.00%,50.00%,66.67%
253 ,50.00%,16.67%,66.67%
255 ,50.00%,50.00%,100.00%
256 ,25.00%,50.00%,33.33%
257 ,16.67%,16.67%,33.33%
259 ,66.67%,33.33%,100.00%
260 ,100.00%,100.00%,100.00%
261 ,66.67%,33.33%,100.00%
263 Table: Chi-square tests.
264 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
265 Pearson Chi-Square,.38,1,.540,,
266 Likelihood Ratio,.37,1,.545,,
267 Fisher's Exact Test,,,,1.000,.600
268 Continuity Correction,.00,1,1.000,,
269 N of Valid Cases,6,,,,
276 ,Valid,,Missing,,Total,
277 ,N,Percent,N,Percent,N,Percent
278 v1 * v2,4,100.0%,0,0.0%,4,100.0%
280 "Table: v1 * v2 [count, row %, column %, total %]."
284 ,.00%,100.00%,100.00%
288 ,33.33%,66.67%,100.00%
289 ,100.00%,66.67%,75.00%
290 ,25.00%,50.00%,75.00%
292 ,25.00%,75.00%,100.00%
293 ,100.00%,100.00%,100.00%
294 ,25.00%,75.00%,100.00%
296 Table: Chi-square tests.
297 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
298 Pearson Chi-Square,.44,1,.505,,
299 Likelihood Ratio,.68,1,.410,,
300 Fisher's Exact Test,,,,1.000,.750
301 Continuity Correction,.00,1,1.000,,
302 N of Valid Cases,4,,,,
307 AT_SETUP([3-way CROSSTABS])
308 AT_DATA([crosstabs.sps],
329 CROSSTABS TABLES x BY y BY z/STATISTICS=ALL.
331 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
332 [[Table: Reading 1 record from INLINE.
333 Variable,Record,Columns,Format
352 ,Valid,,Missing,,Total,
353 ,N,Percent,N,Percent,N,Percent
354 x * y * z,9,100.0%,0,0.0%,9,100.0%
356 Table: x * y * z [count].
364 Total,,4.00,1.00,5.00
369 Total,,3.00,1.00,4.00
371 Table: Chi-square tests.
372 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
373 1,Pearson Chi-Square,5.00,4,.287
374 ,Likelihood Ratio,5.00,4,.287
375 ,Linear-by-Linear Association,.01,1,.938
376 ,N of Valid Cases,5,,
377 2,Pearson Chi-Square,4.00,3,.261
378 ,Likelihood Ratio,4.50,3,.212
379 ,Linear-by-Linear Association,1.58,1,.209
380 ,N of Valid Cases,4,,
382 Table: Symmetric measures.
383 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
384 1,Nominal by Nominal,Phi,1.00,,,
386 ,,Contingency Coefficient,.71,,,
387 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
388 ,,Kendall's tau-c,.00,.32,.00,
390 ,,Spearman Correlation,.00,.22,.00,
391 ,Interval by Interval,Pearson's R,.04,.22,.07,
392 ,N of Valid Cases,,5,,,
393 2,Nominal by Nominal,Phi,1.00,,,
395 ,,Contingency Coefficient,.71,,,
396 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
397 ,,Kendall's tau-c,-.75,.43,-1.73,
398 ,,Gamma,-1.00,.00,-1.73,
399 ,,Spearman Correlation,-.77,.17,-1.73,
400 ,Interval by Interval,Pearson's R,-.73,.18,-1.49,
401 ,N of Valid Cases,,4,,,
403 Table: Directional measures.
404 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
405 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
406 ,,,x Dependent,.25,.22,1.12,.264
407 ,,,y Dependent,1.00,.00,1.12,.264
408 ,,Goodman and Kruskal tau,x Dependent,.25,,,. @&t@
409 ,,,y Dependent,1.00,,,. @&t@
410 ,,Uncertainty Coefficient,Symmetric,.47,.18,,. @&t@
411 ,,,x Dependent,.31,.15,2.02,. @&t@
412 ,,,y Dependent,1.00,.00,2.02,. @&t@
413 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
414 ,,,x Dependent,.00,.50,.00,1.000
415 ,,,y Dependent,.00,.20,.00,1.000
416 ,Nominal by Interval,Eta,x Dependent,.04,,,. @&t@
417 ,,,y Dependent,1.00,,,. @&t@
418 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
419 ,,,x Dependent,.33,.27,1.15,.248
420 ,,,y Dependent,1.00,.00,1.15,.248
421 ,,Goodman and Kruskal tau,x Dependent,.33,,,. @&t@
422 ,,,y Dependent,1.00,,,. @&t@
423 ,,Uncertainty Coefficient,Symmetric,.58,.17,,. @&t@
424 ,,,x Dependent,.41,.17,2.36,. @&t@
425 ,,,y Dependent,1.00,.00,2.36,. @&t@
426 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
427 ,,,x Dependent,-1.00,.00,-1.73,.083
428 ,,,y Dependent,-.50,.29,-1.73,.083
429 ,Nominal by Interval,Eta,x Dependent,.73,,,. @&t@
430 ,,,y Dependent,1.00,,,. @&t@
436 AT_SETUP([CROSSTABS descending sort order])
437 AT_DATA([crosstabs-descending.sps],
438 [[DATA LIST NOTABLE LIST /x * y *.
453 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
456 ,Valid,,Missing,,Total,
457 ,N,Percent,N,Percent,N,Percent
458 x * y,6,100.0%,0,0.0%,6,100.0%
460 Table: x * y [count].
471 AT_SETUP([CROSSTABS crash when all cases missing])
472 AT_DATA([crosstabs.sps], [dnl
473 DATA LIST LIST NOTABLE /X1 X2.
478 MISSING VALUES x2 (1).
480 CROSSTABS /TABLES= X1 by X2.
482 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
485 ,Valid,,Missing,,Total,
486 ,N,Percent,N,Percent,N,Percent
487 X1 * X2,0,0.0%,1,100.0%,1,100.0%
489 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
495 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
496 AT_SETUP([CROSSTABS Fisher Exact Test])
498 AT_DATA([fisher-exact.sps], [dnl
502 DATA LIST notable LIST /schtyp (F9.2) female (F9.2) ses (F9.2) .
706 VARIABLE LABEL schtyp 'type of school'.
707 ADD VALUE LABELS female 0 male 1 female.
708 ADD VALUE LABELS ses 1 low 2 middle 3 high.
709 ADD VALUE LABELS schtyp 1 public 2 private.
711 crosstabs /tables = schtyp by female /statistic = chisq.
712 crosstabs /tables = female by ses /statistic = chisq.
715 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
718 ,Valid,,Missing,,Total,
719 ,N,Percent,N,Percent,N,Percent
720 type of school * female,200,100.0%,0,0.0%,200,100.0%
722 Table: type of school * female [[count]].
724 type of school,male,female,Total
725 public,77.000,91.000,168.000
726 private,14.000,18.000,32.000
727 Total,91.000,109.000,200.000
729 Table: Chi-square tests.
730 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
731 Pearson Chi-Square,.047,1,.828,,
732 Likelihood Ratio,.047,1,.828,,
733 Fisher's Exact Test,,,,.849,.492
734 Continuity Correction,.001,1,.981,,
735 Linear-by-Linear Association,.047,1,.829,,
736 N of Valid Cases,200,,,,
740 ,Valid,,Missing,,Total,
741 ,N,Percent,N,Percent,N,Percent
742 female * ses,200,100.0%,0,0.0%,200,100.0%
744 Table: female * ses [[count]].
746 female,low,middle,high,Total
747 male,15.000,47.000,29.000,91.000
748 female,32.000,48.000,29.000,109.000
749 Total,47.000,95.000,58.000,200.000
751 Table: Chi-square tests.
752 Statistic,Value,df,Asymp. Sig. (2-tailed)
753 Pearson Chi-Square,4.577,2,.101
754 Likelihood Ratio,4.679,2,.096
755 Linear-by-Linear Association,3.110,1,.078
756 N of Valid Cases,200,,
761 AT_SETUP([CROSSTABS Pearson's R])
763 AT_DATA([pearson.sps], [dnl
766 * From http://www.statisticslectures.com/topics/pearsonr/.
775 CROSSTABS x BY y/STATISTICS=CORR.
777 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
780 ,Valid,,Missing,,Total,
781 ,N,Percent,N,Percent,N,Percent
782 x * y,5,100.0%,0,0.0%,5,100.0%
784 Table: x * y [[count]].
786 x,4.000,6.000,10.000,12.000,13.000,Total
787 1.000,1.000,.000,.000,.000,.000,1.000
788 3.000,.000,1.000,.000,.000,.000,1.000
789 5.000,.000,.000,1.000,1.000,.000,2.000
790 6.000,.000,.000,.000,.000,1.000,1.000
791 Total,1.000,1.000,1.000,1.000,1.000,5.000
793 Table: Symmetric measures.
794 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
795 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550,
796 Interval by Interval,Pearson's R,.968,.017,6.708,
797 N of Valid Cases,,5,,,
801 AT_DATA([pearson2.sps], [dnl
804 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
818 CROSSTABS x BY y/STATISTICS=CORR.
820 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
823 ,Valid,,Missing,,Total,
824 ,N,Percent,N,Percent,N,Percent
825 x * y,10,100.0%,0,0.0%,10,100.0%
827 Table: x * y [[count]].
828 ,y,,,,,,,,,
829 x,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,Total
830 1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
831 2.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
832 3.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
833 4.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
834 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
835 6.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
836 7.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
837 8.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
838 9.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
839 10.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
840 Total,2.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
842 Table: Symmetric measures.
843 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
844 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844,
845 Interval by Interval,Pearson's R,.971,.017,11.580,
846 N of Valid Cases,,10,,,
850 AT_DATA([pearson3.sps], [dnl
853 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
866 CROSSTABS x BY y/STATISTICS=CORR.
868 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
871 ,Valid,,Missing,,Total,
872 ,N,Percent,N,Percent,N,Percent
873 x * y,9,100.0%,0,0.0%,9,100.0%
875 Table: x * y [[count]].
877 x,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,Total
878 25.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
879 35.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
880 44.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
881 50.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
882 56.000,.000,.000,.000,.000,.000,1.000,1.000,.000,2.000
883 65.000,.000,.000,.000,.000,1.000,.000,1.000,.000,2.000
884 87.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
885 Total,1.000,1.000,1.000,1.000,1.000,1.000,2.000,1.000,9.000
887 Table: Symmetric measures.
888 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
889 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860,
890 Interval by Interval,Pearson's R,.966,.017,9.915,
891 N of Valid Cases,,9,,,
895 AT_DATA([pearson4.sps], [dnl
898 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
914 CROSSTABS x BY y/STATISTICS=CORR.
916 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
919 ,Valid,,Missing,,Total,
920 ,N,Percent,N,Percent,N,Percent
921 x * y,12,100.0%,0,0.0%,12,100.0%
923 Table: x * y [[count]].
924 ,y,,,,,,,,,,,,
925 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
926 2.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
927 3.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
928 4.000,.000,.000,.000,.000,1.000,1.000,.000,.000,.000,.000,.000,.000,2.000
929 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
930 6.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,2.000
931 7.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
932 8.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
933 9.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
934 10.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,2.000
935 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
937 Table: Symmetric measures.
938 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
939 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758,
940 Interval by Interval,Pearson's R,.667,.132,2.830,
941 N of Valid Cases,,12,,,
945 AT_DATA([pearson5.sps], [dnl
948 * From http://www.statisticslectures.com/topics/pearsonr/.
962 CROSSTABS x BY y/STATISTICS=CORR.
964 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
967 ,Valid,,Missing,,Total,
968 ,N,Percent,N,Percent,N,Percent
969 x * y,10,100.0%,0,0.0%,10,100.0%
971 Table: x * y [[count]].
972 ,y,,,,,,,,,,
973 x,15000.000,26000.000,29000.000,32000.000,33000.000,41000.000,45000.000,52000.000,68000.000,80000.000,Total
974 18.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
975 24.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
976 25.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
977 26.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
978 33.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
979 37.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
980 40.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
981 45.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
982 57.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
983 64.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
984 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
986 Table: Symmetric measures.
987 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
988 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinity,
989 Interval by Interval,Pearson's R,.992,.004,22.638,
990 N of Valid Cases,,10,,,
994 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda])
995 AT_DATA([lambda.sps], [dnl
998 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
999 DATA LIST LIST NOTABLE/x y w.
1010 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1012 * From http://vassarstats.net.
1013 DATA LIST LIST NOTABLE/x y w.
1027 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1029 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1030 cross classifications". Part I. Journal of the American Statistical
1031 Association, 49, 732-764.
1032 DATA LIST LIST NOTABLE/x y w.
1048 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1050 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1053 ,Valid,,Missing,,Total,
1054 ,N,Percent,N,Percent,N,Percent
1055 x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
1057 Table: Directional measures.
1058 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1059 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1060 ,,x Dependent,.497,.024,15.986,.000
1061 ,,y Dependent,.370,.020,16.339,.000
1062 ,Goodman and Kruskal tau,x Dependent,.382,,,. @&t@
1063 ,,y Dependent,.198,,,. @&t@
1067 ,Valid,,Missing,,Total,
1068 ,N,Percent,N,Percent,N,Percent
1069 x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
1071 Table: Directional measures.
1072 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1073 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1074 ,,x Dependent,.250,.089,2.479,.013
1075 ,,y Dependent,.267,.085,2.766,.006
1076 ,Goodman and Kruskal tau,x Dependent,.129,,,. @&t@
1077 ,,y Dependent,.123,,,. @&t@
1081 ,Valid,,Missing,,Total,
1082 ,N,Percent,N,Percent,N,Percent
1083 x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
1085 Table: Directional measures.
1086 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1087 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1088 ,,x Dependent,.224,.013,16.076,.000
1089 ,,y Dependent,.192,.012,14.438,.000
1090 ,Goodman and Kruskal tau,x Dependent,.089,,,. @&t@
1091 ,,y Dependent,.081,,,. @&t@
1095 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1096 AT_DATA([lambda.sps], [dnl
1099 * From Douglas Bonett.
1100 DATA LIST LIST NOTABLE/x y w.
1111 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1113 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1116 ,Valid,,Missing,,Total,
1117 ,N,Percent,N,Percent,N,Percent
1118 x * y,500.000,100.0%,.000,0.0%,500.000,100.0%
1120 Table: Directional measures.
1121 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1122 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1123 ,,x Dependent,.000,.000,NaN,NaN
1124 ,,y Dependent,.033,.014,2.336,.019
1125 ,Goodman and Kruskal tau,x Dependent,.012,,,. @&t@
1126 ,,y Dependent,.009,,,. @&t@
1130 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma])
1131 AT_DATA([somersd.sps], [dnl
1134 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1135 DATA LIST LIST NOTABLE/x y * w (F10.6).
1153 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1155 * From http://uregina.ca/~gingrich/gamma.pdf.
1156 DATA LIST LIST NOTABLE/x y w.
1169 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1171 AT_CHECK([pspp -O format=csv somersd.sps], [0], [dnl
1174 ,Valid,,Missing,,Total,
1175 ,N,Percent,N,Percent,N,Percent
1176 x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
1178 Table: Directional measures.
1179 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1180 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1181 ,,x Dependent,-.045,.300,-.149,.882
1182 ,,y Dependent,-.684,2.378,-.149,.882
1186 ,Valid,,Missing,,Total,
1187 ,N,Percent,N,Percent,N,Percent
1188 x * y,687.000,100.0%,.000,0.0%,687.000,100.0%
1190 Table: Symmetric measures.
1191 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1192 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669,
1193 ,Kendall's tau-c,.310,.029,10.669,
1194 ,Gamma,.591,.043,10.669,
1195 N of Valid Cases,,687.000,,,
1197 Table: Directional measures.
1198 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1199 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1200 ,,x Dependent,.351,.032,10.669,.000
1201 ,,y Dependent,.394,.035,10.669,.000
1204 AT_DATA([ordinal.sps], [dnl
1207 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1208 DATA LIST LIST NOTABLE /x y w.
1215 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1217 * Same site, case 2.
1218 DATA LIST LIST NOTABLE /x y w.
1225 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1227 * Same site, case 3.
1228 DATA LIST LIST NOTABLE /x y w.
1235 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1237 * Same site, case 4.
1238 DATA LIST LIST NOTABLE /x y w.
1246 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1248 * Same site, case 5.
1249 DATA LIST LIST NOTABLE /x y w.
1257 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1259 * Same site, case 6.
1260 DATA LIST LIST NOTABLE /x y w.
1272 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1274 * Same site, case 7.
1275 DATA LIST LIST NOTABLE /x y w.
1287 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1289 * Same site, case 8.
1290 DATA LIST LIST NOTABLE /x y w.
1310 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1312 AT_CHECK([pspp -O format=csv ordinal.sps], [0], [dnl
1315 ,Valid,,Missing,,Total,
1316 ,N,Percent,N,Percent,N,Percent
1317 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1319 Table: Symmetric measures.
1320 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1321 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1322 ,Gamma,1.000,.000,24.841,
1323 N of Valid Cases,,150.000,,,
1325 Table: Directional measures.
1326 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1327 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1328 ,,x Dependent,1.000,.000,24.841,.000
1329 ,,y Dependent,1.000,.000,24.841,.000
1333 ,Valid,,Missing,,Total,
1334 ,N,Percent,N,Percent,N,Percent
1335 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1337 Table: Symmetric measures.
1338 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1339 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1340 ,Gamma,1.000,.000,24.841,
1341 N of Valid Cases,,150.000,,,
1343 Table: Directional measures.
1344 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1345 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1346 ,,x Dependent,1.000,.000,24.841,.000
1347 ,,y Dependent,1.000,.000,24.841,.000
1351 ,Valid,,Missing,,Total,
1352 ,N,Percent,N,Percent,N,Percent
1353 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1355 Table: Symmetric measures.
1356 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1357 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841,
1358 ,Gamma,-1.000,.000,-24.841,
1359 N of Valid Cases,,150.000,,,
1361 Table: Directional measures.
1362 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1363 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1364 ,,x Dependent,-1.000,.000,-24.841,.000
1365 ,,y Dependent,-1.000,.000,-24.841,.000
1369 ,Valid,,Missing,,Total,
1370 ,N,Percent,N,Percent,N,Percent
1371 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1373 Table: Symmetric measures.
1374 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1375 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841,
1376 ,Gamma,1.000,.000,24.841,
1377 N of Valid Cases,,150.000,,,
1379 Table: Directional measures.
1380 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1381 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1382 ,,x Dependent,.944,.013,24.841,.000
1383 ,,y Dependent,1.000,.000,24.841,.000
1387 ,Valid,,Missing,,Total,
1388 ,N,Percent,N,Percent,N,Percent
1389 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1391 Table: Symmetric measures.
1392 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1393 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009,
1394 ,Gamma,1.000,.000,1.009,
1395 N of Valid Cases,,150.000,,,
1397 Table: Directional measures.
1398 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1399 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1400 ,,x Dependent,.805,.032,1.009,.313
1401 ,,y Dependent,.018,.017,1.009,.313
1405 ,Valid,,Missing,,Total,
1406 ,N,Percent,N,Percent,N,Percent
1407 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1409 Table: Symmetric measures.
1410 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1411 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641,
1412 ,Gamma,-.381,.130,-2.641,
1413 N of Valid Cases,,148.000,,,
1415 Table: Directional measures.
1416 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1417 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1418 ,,x Dependent,-.182,.069,-2.641,.008
1419 ,,y Dependent,-.237,.089,-2.641,.008
1423 ,Valid,,Missing,,Total,
1424 ,N,Percent,N,Percent,N,Percent
1425 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1427 Table: Symmetric measures.
1428 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1429 Nominal by Nominal,Phi,.731,,,
1431 Ordinal by Ordinal,Gamma,-.110,.107,-1.022,
1432 N of Valid Cases,,148.000,,,
1434 Table: Directional measures.
1435 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1436 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1437 ,,x Dependent,.640,.085,4.875,.000
1438 ,,y Dependent,.174,.050,3.248,.001
1439 ,Goodman and Kruskal tau,x Dependent,.534,,,. @&t@
1440 ,,y Dependent,.167,,,. @&t@
1441 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1442 ,,x Dependent,-.060,.059,-1.022,.307
1443 ,,y Dependent,-.096,.094,-1.022,.307
1447 ,Valid,,Missing,,Total,
1448 ,N,Percent,N,Percent,N,Percent
1449 x * y,212.000,100.0%,.000,0.0%,212.000,100.0%
1451 Table: Symmetric measures.
1452 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1453 Nominal by Nominal,Phi,.432,,,
1455 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338,
1456 N of Valid Cases,,212.000,,,
1458 Table: Directional measures.
1459 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1460 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1461 ,,x Dependent,.027,.087,.302,.763
1462 ,,y Dependent,.165,.065,2.349,.019
1463 ,Goodman and Kruskal tau,x Dependent,.051,,,. @&t@
1464 ,,y Dependent,.068,,,. @&t@
1465 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1466 ,,x Dependent,.202,.060,3.338,.001
1467 ,,y Dependent,.217,.064,3.338,.001
1471 AT_SETUP([CROSSTABS Cohens Kappa])
1473 dnl Example from Wood J. M.
1474 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1475 dnl WebPsychEmpiricist. Oct 3 2007
1476 AT_DATA([kappa.sps], [dnl
1479 data list notable list /p1 * p2 * w *.
1488 crosstabs /table = p1 by p2
1493 AT_CHECK([pspp -O format=csv kappa.sps], [0], [dnl
1496 ,Valid,,Missing,,Total,
1497 ,N,Percent,N,Percent,N,Percent
1498 p1 * p2,20.000,100.0%,.000,0.0%,20.000,100.0%
1500 Table: p1 * p2 [[count]].
1503 .000,18.000,1.000,19.000
1504 1.000,1.000,.000,1.000
1505 Total,19.000,1.000,20.000
1507 Table: Symmetric measures.
1508 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1509 Measure of Agreement,Kappa,-.053,.037,-.235,
1510 N of Valid Cases,,20.000,,,
1516 AT_SETUP([CROSSTABS many statistics])
1517 AT_DATA([crosstabs.sps], [dnl
1520 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1521 DATA LIST LIST NOTABLE/x y w.
1530 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1532 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
1535 ,Valid,,Missing,,Total,
1536 ,N,Percent,N,Percent,N,Percent
1537 x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
1539 Table: Chi-square tests.
1540 Statistic,Value,df,Asymp. Sig. (2-tailed)
1541 Pearson Chi-Square,6.9562,2.0000,.031
1542 Likelihood Ratio,6.6901,2.0000,.035
1543 Linear-by-Linear Association,5.8450,1.0000,.016
1544 N of Valid Cases,66.0000,,
1546 Table: Symmetric measures.
1547 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1548 Nominal by Nominal,Phi,.3246,,,
1549 ,Cramer's V,.3246,,,
1550 ,Contingency Coefficient,.3088,,,
1551 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
1552 ,Kendall's tau-c,.1497,.0751,1.9920,
1553 ,Gamma,.8717,.1250,1.9920,
1554 ,Spearman Correlation,.2908,.0906,2.4311,
1555 Interval by Interval,Pearson's R,.2999,.0973,2.5147,
1556 N of Valid Cases,,66.0000,,,
1558 Table: Directional measures.
1559 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1560 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1561 ,,x Dependent,.0000,.0000,NaN,NaN
1562 ,,y Dependent,.0500,.1791,.2723,.785
1563 ,Goodman and Kruskal tau,x Dependent,.1054,,,. @&t@
1564 ,,y Dependent,.0434,,,. @&t@
1565 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,. @&t@
1566 ,,x Dependent,.2217,.1062,1.5373,. @&t@
1567 ,,y Dependent,.0473,.0306,1.5373,. @&t@
1568 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1569 ,,x Dependent,.1152,.0572,1.9920,.046
1570 ,,y Dependent,.6573,.1417,1.9920,.046
1574 AT_SETUP([CROSSTABS uncertainy coefficient])
1575 AT_DATA([uc.sps], [dnl
1576 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1579 DATA LIST LIST NOTABLE/x y w.
1589 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1591 AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
1594 ,Valid,,Missing,,Total,
1595 ,N,Percent,N,Percent,N,Percent
1596 x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
1598 Table: Directional measures.
1599 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1600 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1601 ,,x Dependent,.000,.000,NaN,NaN
1602 ,,y Dependent,.000,.000,NaN,NaN
1603 ,Goodman and Kruskal tau,x Dependent,.076,,,. @&t@
1604 ,,y Dependent,.108,,,. @&t@
1605 ,Uncertainty Coefficient,Symmetric,.105,.012,,. @&t@
1606 ,,x Dependent,.073,.009,7.890,. @&t@
1607 ,,y Dependent,.184,.019,7.890,. @&t@
1613 AT_SETUP([CROSSTABS barchart])
1614 AT_DATA([bc.sps], [dnl
1617 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1641 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1643 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1644 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1646 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])