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/>.
16 dnl AT_BANNER([CROSSTABS procedure])
18 AT_SETUP([CROSSTABS integer mode crash])
19 AT_DATA([crosstabs.sps],
20 [DATA LIST LIST /A * B * X * Y * .
25 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
27 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
28 [[Table: Reading free-form data from INLINE.
37 ,Valid,,Missing,,Total,
38 ,N,Percent,N,Percent,N,Percent
39 X * Y,1,100.0%,0,0.0%,1,100.0%
43 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
44 1.00,.00,.00,.00,.00,.00,.00,.00,.00
45 2.00,.00,.00,.00,.00,.00,.00,.00,.00
46 3.00,.00,.00,.00,.00,.00,.00,.00,.00
47 4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
48 5.00,.00,.00,.00,.00,.00,.00,.00,.00
49 6.00,.00,.00,.00,.00,.00,.00,.00,.00
50 7.00,.00,.00,.00,.00,.00,.00,.00,.00
51 Total,.00,.00,.00,.00,1.00,.00,.00,1.00
56 AT_SETUP([CROSSTABS integer mode crash 2])
57 AT_DATA([crosstabs.sps], [dnl
64 VARIABLES x (1,3) y (1,7)
67 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
68 [[Table: Reading free-form data from INLINE.
75 ,Valid,,Missing,,Total,
76 ,N,Percent,N,Percent,N,Percent
77 x * y,0,0.0%,1,100.0%,1,100.0%
82 AT_SETUP([CROSSTABS long string crash])
83 AT_DATA([crosstabs.sps],
84 [data list list /x * y (a18).
95 CROSSTABS /TABLES = x BY y.
97 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
98 [[Table: Reading free-form data from INLINE.
103 "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."
105 "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."
109 ,Valid,,Missing,,Total,
110 ,N,Percent,N,Percent,N,Percent
111 x * y,4,66.7%,2,33.3%,6,100.0%
113 Table: x * y [count].
115 x,one unity ,three lots ,two duality ,zero none ,Total
116 1.00,1.00,.00,.00,1.00,2.00
117 2.00,.00,.00,1.00,.00,1.00
118 3.00,.00,1.00,.00,.00,1.00
119 Total,1.00,1.00,1.00,1.00,4.00
123 AT_SETUP([CROSSTABS crash])
124 AT_DATA([crosstabs.sps],
145 CROSSTABS TABLES y by z.
147 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
148 [[Table: Reading 1 record from INLINE.
149 Variable,Record,Columns,Format
168 ,Valid,,Missing,,Total,
169 ,N,Percent,N,Percent,N,Percent
170 y * z,9,100.0%,0,0.0%,9,100.0%
172 Table: y * z [count].
181 # Bug #26739, which caused CROSSTABS to crash or to fail to output
182 # chi-square results.
183 AT_SETUP([CROSSTABS chi-square crash])
184 AT_DATA([crosstabs.sps],
185 [[DATA LIST LIST /x * y *.
197 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
198 [[Table: Reading free-form data from INLINE.
205 ,Valid,,Missing,,Total,
206 ,N,Percent,N,Percent,N,Percent
207 x * y,4,100.0%,0,0.0%,4,100.0%
209 Table: x * y [count].
217 Table: Chi-square tests.
218 Statistic,Value,df,Asymp. Sig. (2-tailed)
219 Pearson Chi-Square,2.00,2,.368
220 Likelihood Ratio,2.77,2,.250
221 Linear-by-Linear Association,.27,1,.602
227 AT_SETUP([CROSSTABS crash with SPLIT FILE])
228 AT_DATA([crosstabs.sps],
229 [data list notable / v0 to v2 1-6 (A)
243 SPLIT FILE SEPARATE BY v0.
247 /FORMAT=AVALUE TABLES PIVOT
249 /CELLS=COUNT ROW COLUMN TOTAL.
252 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
253 [[Variable,Value,Label
258 ,Valid,,Missing,,Total,
259 ,N,Percent,N,Percent,N,Percent
260 v1 * v2,6,100.0%,0,0.0%,6,100.0%
262 "Table: v1 * v2 [count, row %, column %, total %]."
266 ,75.00%,25.00%,100.00%
267 ,75.00%,50.00%,66.67%
268 ,50.00%,16.67%,66.67%
270 ,50.00%,50.00%,100.00%
271 ,25.00%,50.00%,33.33%
272 ,16.67%,16.67%,33.33%
274 ,66.67%,33.33%,100.00%
275 ,100.00%,100.00%,100.00%
276 ,66.67%,33.33%,100.00%
278 Table: Chi-square tests.
279 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
280 Pearson Chi-Square,.38,1,.540,,
281 Likelihood Ratio,.37,1,.545,,
282 Fisher's Exact Test,,,,1.000,.600
283 Continuity Correction,.00,1,1.000,,
284 N of Valid Cases,6,,,,
291 ,Valid,,Missing,,Total,
292 ,N,Percent,N,Percent,N,Percent
293 v1 * v2,4,100.0%,0,0.0%,4,100.0%
295 "Table: v1 * v2 [count, row %, column %, total %]."
299 ,.00%,100.00%,100.00%
303 ,33.33%,66.67%,100.00%
304 ,100.00%,66.67%,75.00%
305 ,25.00%,50.00%,75.00%
307 ,25.00%,75.00%,100.00%
308 ,100.00%,100.00%,100.00%
309 ,25.00%,75.00%,100.00%
311 Table: Chi-square tests.
312 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
313 Pearson Chi-Square,.44,1,.505,,
314 Likelihood Ratio,.68,1,.410,,
315 Fisher's Exact Test,,,,1.000,.750
316 Continuity Correction,.00,1,1.000,,
317 N of Valid Cases,4,,,,
322 AT_SETUP([3-way CROSSTABS])
323 AT_DATA([crosstabs.sps],
344 CROSSTABS TABLES x BY y BY z/STATISTICS=ALL.
346 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
347 [[Table: Reading 1 record from INLINE.
348 Variable,Record,Columns,Format
367 ,Valid,,Missing,,Total,
368 ,N,Percent,N,Percent,N,Percent
369 x * y * z,9,100.0%,0,0.0%,9,100.0%
371 Table: x * y * z [count].
379 Total,,4.00,1.00,5.00
384 Total,,3.00,1.00,4.00
386 Table: Chi-square tests.
387 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
388 1,Pearson Chi-Square,5.00,4,.287
389 ,Likelihood Ratio,5.00,4,.287
390 ,Linear-by-Linear Association,.01,1,.938
391 ,N of Valid Cases,5,,
392 2,Pearson Chi-Square,4.00,3,.261
393 ,Likelihood Ratio,4.50,3,.212
394 ,Linear-by-Linear Association,1.58,1,.209
395 ,N of Valid Cases,4,,
397 Table: Symmetric measures.
398 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
399 1,Nominal by Nominal,Phi,1.00,,,
401 ,,Contingency Coefficient,.71,,,
402 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
403 ,,Kendall's tau-c,.00,.32,.00,
405 ,,Spearman Correlation,.00,.22,.00,
406 ,Interval by Interval,Pearson's R,.04,.22,.07,
407 ,N of Valid Cases,,5,,,
408 2,Nominal by Nominal,Phi,1.00,,,
410 ,,Contingency Coefficient,.71,,,
411 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
412 ,,Kendall's tau-c,-.75,.43,-1.73,
413 ,,Gamma,-1.00,.00,-1.73,
414 ,,Spearman Correlation,-.77,.17,-1.73,
415 ,Interval by Interval,Pearson's R,-.73,.18,-1.49,
416 ,N of Valid Cases,,4,,,
418 Table: Directional measures.
419 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
420 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
421 ,,,x Dependent,.25,.22,1.12,.264
422 ,,,y Dependent,1.00,.00,1.12,.264
423 ,,Goodman and Kruskal tau,x Dependent,.25,,,. @&t@
424 ,,,y Dependent,1.00,,,. @&t@
425 ,,Uncertainty Coefficient,Symmetric,.47,.18,,. @&t@
426 ,,,x Dependent,.31,.15,2.02,. @&t@
427 ,,,y Dependent,1.00,.00,2.02,. @&t@
428 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
429 ,,,x Dependent,.00,.50,.00,1.000
430 ,,,y Dependent,.00,.20,.00,1.000
431 ,Nominal by Interval,Eta,x Dependent,.04,,,. @&t@
432 ,,,y Dependent,1.00,,,. @&t@
433 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
434 ,,,x Dependent,.33,.27,1.15,.248
435 ,,,y Dependent,1.00,.00,1.15,.248
436 ,,Goodman and Kruskal tau,x Dependent,.33,,,. @&t@
437 ,,,y Dependent,1.00,,,. @&t@
438 ,,Uncertainty Coefficient,Symmetric,.58,.17,,. @&t@
439 ,,,x Dependent,.41,.17,2.36,. @&t@
440 ,,,y Dependent,1.00,.00,2.36,. @&t@
441 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
442 ,,,x Dependent,-1.00,.00,-1.73,.083
443 ,,,y Dependent,-.50,.29,-1.73,.083
444 ,Nominal by Interval,Eta,x Dependent,.73,,,. @&t@
445 ,,,y Dependent,1.00,,,. @&t@
449 AT_SETUP([CROSSTABS rounding weights with COUNT])
450 AT_DATA([crosstabs.sps],
451 [[DATA LIST NOTABLE LIST /x y w.
462 * These should have the same effect (no rounding).
463 CROSSTABS /TABLES x BY y.
464 CROSSTABS /TABLES x BY y /COUNT ASIS.
466 * Round input weights.
467 CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
468 CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
470 * Round cell weights.
471 CROSSTABS /TABLES x BY y /COUNT.
472 CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
475 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
478 ,Valid,,Missing,,Total,
479 ,N,Percent,N,Percent,N,Percent
480 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
482 Table: x * y [count].
491 ,Valid,,Missing,,Total,
492 ,N,Percent,N,Percent,N,Percent
493 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
495 Table: x * y [count].
504 ,Valid,,Missing,,Total,
505 ,N,Percent,N,Percent,N,Percent
506 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
508 Table: x * y [count].
517 ,Valid,,Missing,,Total,
518 ,N,Percent,N,Percent,N,Percent
519 x * y,7.00,100.0%,.00,0.0%,7.00,100.0%
521 Table: x * y [count].
530 ,Valid,,Missing,,Total,
531 ,N,Percent,N,Percent,N,Percent
532 x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
534 Table: x * y [count].
543 ,Valid,,Missing,,Total,
544 ,N,Percent,N,Percent,N,Percent
545 x * y,8.00,100.0%,.00,0.0%,8.00,100.0%
547 Table: x * y [count].
556 AT_SETUP([CROSSTABS descending sort order])
557 AT_DATA([crosstabs-descending.sps],
558 [[DATA LIST NOTABLE LIST /x * y *.
573 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
576 ,Valid,,Missing,,Total,
577 ,N,Percent,N,Percent,N,Percent
578 x * y,6,100.0%,0,0.0%,6,100.0%
580 Table: x * y [count].
591 AT_SETUP([CROSSTABS crash when all cases missing])
592 AT_DATA([crosstabs.sps], [dnl
593 DATA LIST LIST NOTABLE /X1 X2.
598 MISSING VALUES x2 (1).
600 CROSSTABS /TABLES= X1 by X2.
602 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
605 ,Valid,,Missing,,Total,
606 ,N,Percent,N,Percent,N,Percent
607 X1 * X2,0,0.0%,1,100.0%,1,100.0%
609 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
615 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
616 AT_SETUP([CROSSTABS Fisher Exact Test])
618 AT_DATA([fisher-exact.sps], [dnl
622 DATA LIST notable LIST /schtyp (F9.2) female (F9.2) ses (F9.2) .
826 VARIABLE LABEL schtyp 'type of school'.
827 ADD VALUE LABELS female 0 male 1 female.
828 ADD VALUE LABELS ses 1 low 2 middle 3 high.
829 ADD VALUE LABELS schtyp 1 public 2 private.
831 crosstabs /tables = schtyp by female /statistic = chisq.
832 crosstabs /tables = female by ses /statistic = chisq.
835 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
838 ,Valid,,Missing,,Total,
839 ,N,Percent,N,Percent,N,Percent
840 type of school * female,200,100.0%,0,0.0%,200,100.0%
842 Table: type of school * female [[count]].
844 type of school,male,female,Total
845 public,77.000,91.000,168.000
846 private,14.000,18.000,32.000
847 Total,91.000,109.000,200.000
849 Table: Chi-square tests.
850 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
851 Pearson Chi-Square,.047,1,.828,,
852 Likelihood Ratio,.047,1,.828,,
853 Fisher's Exact Test,,,,.849,.492
854 Continuity Correction,.001,1,.981,,
855 Linear-by-Linear Association,.047,1,.829,,
856 N of Valid Cases,200,,,,
860 ,Valid,,Missing,,Total,
861 ,N,Percent,N,Percent,N,Percent
862 female * ses,200,100.0%,0,0.0%,200,100.0%
864 Table: female * ses [[count]].
866 female,low,middle,high,Total
867 male,15.000,47.000,29.000,91.000
868 female,32.000,48.000,29.000,109.000
869 Total,47.000,95.000,58.000,200.000
871 Table: Chi-square tests.
872 Statistic,Value,df,Asymp. Sig. (2-tailed)
873 Pearson Chi-Square,4.577,2,.101
874 Likelihood Ratio,4.679,2,.096
875 Linear-by-Linear Association,3.110,1,.078
876 N of Valid Cases,200,,
881 AT_SETUP([CROSSTABS Pearson's R])
883 AT_DATA([pearson.sps], [dnl
886 * From http://www.statisticslectures.com/topics/pearsonr/.
895 CROSSTABS x BY y/STATISTICS=CORR.
897 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
900 ,Valid,,Missing,,Total,
901 ,N,Percent,N,Percent,N,Percent
902 x * y,5,100.0%,0,0.0%,5,100.0%
904 Table: x * y [[count]].
906 x,4.000,6.000,10.000,12.000,13.000,Total
907 1.000,1.000,.000,.000,.000,.000,1.000
908 3.000,.000,1.000,.000,.000,.000,1.000
909 5.000,.000,.000,1.000,1.000,.000,2.000
910 6.000,.000,.000,.000,.000,1.000,1.000
911 Total,1.000,1.000,1.000,1.000,1.000,5.000
913 Table: Symmetric measures.
914 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
915 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550,
916 Interval by Interval,Pearson's R,.968,.017,6.708,
917 N of Valid Cases,,5,,,
921 AT_DATA([pearson2.sps], [dnl
924 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
938 CROSSTABS x BY y/STATISTICS=CORR.
940 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
943 ,Valid,,Missing,,Total,
944 ,N,Percent,N,Percent,N,Percent
945 x * y,10,100.0%,0,0.0%,10,100.0%
947 Table: x * y [[count]].
948 ,y,,,,,,,,,
949 x,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,Total
950 1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
951 2.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
952 3.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
953 4.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
954 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
955 6.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
956 7.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
957 8.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
958 9.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
959 10.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
960 Total,2.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
962 Table: Symmetric measures.
963 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
964 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844,
965 Interval by Interval,Pearson's R,.971,.017,11.580,
966 N of Valid Cases,,10,,,
970 AT_DATA([pearson3.sps], [dnl
973 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
986 CROSSTABS x BY y/STATISTICS=CORR.
988 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
991 ,Valid,,Missing,,Total,
992 ,N,Percent,N,Percent,N,Percent
993 x * y,9,100.0%,0,0.0%,9,100.0%
995 Table: x * y [[count]].
997 x,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,Total
998 25.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
999 35.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
1000 44.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1001 50.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1002 56.000,.000,.000,.000,.000,.000,1.000,1.000,.000,2.000
1003 65.000,.000,.000,.000,.000,1.000,.000,1.000,.000,2.000
1004 87.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
1005 Total,1.000,1.000,1.000,1.000,1.000,1.000,2.000,1.000,9.000
1007 Table: Symmetric measures.
1008 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1009 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860,
1010 Interval by Interval,Pearson's R,.966,.017,9.915,
1011 N of Valid Cases,,9,,,
1015 AT_DATA([pearson4.sps], [dnl
1018 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
1034 CROSSTABS x BY y/STATISTICS=CORR.
1036 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
1039 ,Valid,,Missing,,Total,
1040 ,N,Percent,N,Percent,N,Percent
1041 x * y,12,100.0%,0,0.0%,12,100.0%
1043 Table: x * y [[count]].
1044 ,y,,,,,,,,,,,,
1045 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
1046 2.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1047 3.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1048 4.000,.000,.000,.000,.000,1.000,1.000,.000,.000,.000,.000,.000,.000,2.000
1049 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1050 6.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,2.000
1051 7.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1052 8.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
1053 9.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
1054 10.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,2.000
1055 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
1057 Table: Symmetric measures.
1058 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1059 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758,
1060 Interval by Interval,Pearson's R,.667,.132,2.830,
1061 N of Valid Cases,,12,,,
1065 AT_DATA([pearson5.sps], [dnl
1068 * From http://www.statisticslectures.com/topics/pearsonr/.
1082 CROSSTABS x BY y/STATISTICS=CORR.
1084 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
1087 ,Valid,,Missing,,Total,
1088 ,N,Percent,N,Percent,N,Percent
1089 x * y,10,100.0%,0,0.0%,10,100.0%
1091 Table: x * y [[count]].
1092 ,y,,,,,,,,,,
1093 x,15000.000,26000.000,29000.000,32000.000,33000.000,41000.000,45000.000,52000.000,68000.000,80000.000,Total
1094 18.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1095 24.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
1096 25.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
1097 26.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
1098 33.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
1099 37.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
1100 40.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
1101 45.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
1102 57.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
1103 64.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
1104 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
1106 Table: Symmetric measures.
1107 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1108 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinity,
1109 Interval by Interval,Pearson's R,.992,.004,22.638,
1110 N of Valid Cases,,10,,,
1114 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda])
1115 AT_DATA([lambda.sps], [dnl
1118 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
1119 DATA LIST LIST NOTABLE/x y w.
1130 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1132 * From http://vassarstats.net.
1133 DATA LIST LIST NOTABLE/x y w.
1147 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1149 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1150 cross classifications". Part I. Journal of the American Statistical
1151 Association, 49, 732-764.
1152 DATA LIST LIST NOTABLE/x y w.
1168 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1170 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1173 ,Valid,,Missing,,Total,
1174 ,N,Percent,N,Percent,N,Percent
1175 x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
1177 Table: Directional measures.
1178 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1179 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
1180 ,,x Dependent,.497,.024,15.986,.000
1181 ,,y Dependent,.370,.020,16.339,.000
1182 ,Goodman and Kruskal tau,x Dependent,.382,,,. @&t@
1183 ,,y Dependent,.198,,,. @&t@
1187 ,Valid,,Missing,,Total,
1188 ,N,Percent,N,Percent,N,Percent
1189 x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
1191 Table: Directional measures.
1192 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1193 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
1194 ,,x Dependent,.250,.089,2.479,.013
1195 ,,y Dependent,.267,.085,2.766,.006
1196 ,Goodman and Kruskal tau,x Dependent,.129,,,. @&t@
1197 ,,y Dependent,.123,,,. @&t@
1201 ,Valid,,Missing,,Total,
1202 ,N,Percent,N,Percent,N,Percent
1203 x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
1205 Table: Directional measures.
1206 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1207 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
1208 ,,x Dependent,.224,.013,16.076,.000
1209 ,,y Dependent,.192,.012,14.438,.000
1210 ,Goodman and Kruskal tau,x Dependent,.089,,,. @&t@
1211 ,,y Dependent,.081,,,. @&t@
1215 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
1216 AT_DATA([lambda.sps], [dnl
1219 * From Douglas Bonett.
1220 DATA LIST LIST NOTABLE/x y w.
1231 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1233 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1236 ,Valid,,Missing,,Total,
1237 ,N,Percent,N,Percent,N,Percent
1238 x * y,500.000,100.0%,.000,0.0%,500.000,100.0%
1240 Table: Directional measures.
1241 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1242 Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
1243 ,,x Dependent,.000,.000,NaN,NaN
1244 ,,y Dependent,.033,.014,2.336,.019
1245 ,Goodman and Kruskal tau,x Dependent,.012,,,. @&t@
1246 ,,y Dependent,.009,,,. @&t@
1250 AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma])
1251 AT_DATA([somersd.sps], [dnl
1254 * From http://stats.stackexchange.com/questions/72203/problem-with-calculating-asymptotic-standard-error-for-somers-d.
1255 DATA LIST LIST NOTABLE/x y * w (F10.6).
1273 CROSSTABS x BY y/STATISTICS=D/CELLS=NONE.
1275 * From http://uregina.ca/~gingrich/gamma.pdf.
1276 DATA LIST LIST NOTABLE/x y w.
1289 CROSSTABS x BY y/STATISTICS=BTAU CTAU GAMMA D/CELLS=NONE.
1291 AT_CHECK([pspp -O format=csv somersd.sps], [0], [dnl
1294 ,Valid,,Missing,,Total,
1295 ,N,Percent,N,Percent,N,Percent
1296 x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
1298 Table: Directional measures.
1299 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1300 Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
1301 ,,x Dependent,-.045,.300,-.149,.882
1302 ,,y Dependent,-.684,2.378,-.149,.882
1306 ,Valid,,Missing,,Total,
1307 ,N,Percent,N,Percent,N,Percent
1308 x * y,687.000,100.0%,.000,0.0%,687.000,100.0%
1310 Table: Symmetric measures.
1311 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1312 Ordinal by Ordinal,Kendall's tau-b,.372,.033,10.669,
1313 ,Kendall's tau-c,.310,.029,10.669,
1314 ,Gamma,.591,.043,10.669,
1315 N of Valid Cases,,687.000,,,
1317 Table: Directional measures.
1318 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1319 Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
1320 ,,x Dependent,.351,.032,10.669,.000
1321 ,,y Dependent,.394,.035,10.669,.000
1324 AT_DATA([ordinal.sps], [dnl
1327 * From https://www.iup.edu/WorkArea/DownloadAsset.aspx?id=9829, "Case 1".
1328 DATA LIST LIST NOTABLE /x y w.
1335 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1337 * Same site, case 2.
1338 DATA LIST LIST NOTABLE /x y w.
1345 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1347 * Same site, case 3.
1348 DATA LIST LIST NOTABLE /x y w.
1355 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1357 * Same site, case 4.
1358 DATA LIST LIST NOTABLE /x y w.
1366 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1368 * Same site, case 5.
1369 DATA LIST LIST NOTABLE /x y w.
1377 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1379 * Same site, case 6.
1380 DATA LIST LIST NOTABLE /x y w.
1392 CROSSTABS x BY y/STATISTICS=GAMMA D BTAU/CELLS=NONE.
1394 * Same site, case 7.
1395 DATA LIST LIST NOTABLE /x y w.
1407 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI GAMMA/CELLS=NONE.
1409 * Same site, case 8.
1410 DATA LIST LIST NOTABLE /x y w.
1430 CROSSTABS x BY y/STATISTICS=LAMBDA D PHI BTAU/CELLS=NONE.
1432 AT_CHECK([pspp -O format=csv ordinal.sps], [0], [dnl
1435 ,Valid,,Missing,,Total,
1436 ,N,Percent,N,Percent,N,Percent
1437 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1439 Table: Symmetric measures.
1440 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1441 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1442 ,Gamma,1.000,.000,24.841,
1443 N of Valid Cases,,150.000,,,
1445 Table: Directional measures.
1446 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1447 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1448 ,,x Dependent,1.000,.000,24.841,.000
1449 ,,y Dependent,1.000,.000,24.841,.000
1453 ,Valid,,Missing,,Total,
1454 ,N,Percent,N,Percent,N,Percent
1455 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1457 Table: Symmetric measures.
1458 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1459 Ordinal by Ordinal,Kendall's tau-b,1.000,.000,24.841,
1460 ,Gamma,1.000,.000,24.841,
1461 N of Valid Cases,,150.000,,,
1463 Table: Directional measures.
1464 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1465 Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
1466 ,,x Dependent,1.000,.000,24.841,.000
1467 ,,y Dependent,1.000,.000,24.841,.000
1471 ,Valid,,Missing,,Total,
1472 ,N,Percent,N,Percent,N,Percent
1473 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1475 Table: Symmetric measures.
1476 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1477 Ordinal by Ordinal,Kendall's tau-b,-1.000,.000,-24.841,
1478 ,Gamma,-1.000,.000,-24.841,
1479 N of Valid Cases,,150.000,,,
1481 Table: Directional measures.
1482 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1483 Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
1484 ,,x Dependent,-1.000,.000,-24.841,.000
1485 ,,y Dependent,-1.000,.000,-24.841,.000
1489 ,Valid,,Missing,,Total,
1490 ,N,Percent,N,Percent,N,Percent
1491 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1493 Table: Symmetric measures.
1494 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1495 Ordinal by Ordinal,Kendall's tau-b,.972,.007,24.841,
1496 ,Gamma,1.000,.000,24.841,
1497 N of Valid Cases,,150.000,,,
1499 Table: Directional measures.
1500 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1501 Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
1502 ,,x Dependent,.944,.013,24.841,.000
1503 ,,y Dependent,1.000,.000,24.841,.000
1507 ,Valid,,Missing,,Total,
1508 ,N,Percent,N,Percent,N,Percent
1509 x * y,150.000,100.0%,.000,0.0%,150.000,100.0%
1511 Table: Symmetric measures.
1512 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1513 Ordinal by Ordinal,Kendall's tau-b,.119,.059,1.009,
1514 ,Gamma,1.000,.000,1.009,
1515 N of Valid Cases,,150.000,,,
1517 Table: Directional measures.
1518 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1519 Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
1520 ,,x Dependent,.805,.032,1.009,.313
1521 ,,y Dependent,.018,.017,1.009,.313
1525 ,Valid,,Missing,,Total,
1526 ,N,Percent,N,Percent,N,Percent
1527 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1529 Table: Symmetric measures.
1530 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1531 Ordinal by Ordinal,Kendall's tau-b,-.208,.078,-2.641,
1532 ,Gamma,-.381,.130,-2.641,
1533 N of Valid Cases,,148.000,,,
1535 Table: Directional measures.
1536 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1537 Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
1538 ,,x Dependent,-.182,.069,-2.641,.008
1539 ,,y Dependent,-.237,.089,-2.641,.008
1543 ,Valid,,Missing,,Total,
1544 ,N,Percent,N,Percent,N,Percent
1545 x * y,148.000,100.0%,.000,0.0%,148.000,100.0%
1547 Table: Symmetric measures.
1548 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1549 Nominal by Nominal,Phi,.731,,,
1551 Ordinal by Ordinal,Gamma,-.110,.107,-1.022,
1552 N of Valid Cases,,148.000,,,
1554 Table: Directional measures.
1555 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1556 Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
1557 ,,x Dependent,.640,.085,4.875,.000
1558 ,,y Dependent,.174,.050,3.248,.001
1559 ,Goodman and Kruskal tau,x Dependent,.534,,,. @&t@
1560 ,,y Dependent,.167,,,. @&t@
1561 Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
1562 ,,x Dependent,-.060,.059,-1.022,.307
1563 ,,y Dependent,-.096,.094,-1.022,.307
1567 ,Valid,,Missing,,Total,
1568 ,N,Percent,N,Percent,N,Percent
1569 x * y,212.000,100.0%,.000,0.0%,212.000,100.0%
1571 Table: Symmetric measures.
1572 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1573 Nominal by Nominal,Phi,.432,,,
1575 Ordinal by Ordinal,Kendall's tau-b,.209,.062,3.338,
1576 N of Valid Cases,,212.000,,,
1578 Table: Directional measures.
1579 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1580 Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
1581 ,,x Dependent,.027,.087,.302,.763
1582 ,,y Dependent,.165,.065,2.349,.019
1583 ,Goodman and Kruskal tau,x Dependent,.051,,,. @&t@
1584 ,,y Dependent,.068,,,. @&t@
1585 Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
1586 ,,x Dependent,.202,.060,3.338,.001
1587 ,,y Dependent,.217,.064,3.338,.001
1591 AT_SETUP([CROSSTABS Cohens Kappa])
1593 dnl Example from Wood J. M.
1594 dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
1595 dnl WebPsychEmpiricist. Oct 3 2007
1596 AT_DATA([kappa.sps], [dnl
1599 data list notable list /p1 * p2 * w *.
1608 crosstabs /table = p1 by p2
1613 AT_CHECK([pspp -O format=csv kappa.sps], [0], [dnl
1616 ,Valid,,Missing,,Total,
1617 ,N,Percent,N,Percent,N,Percent
1618 p1 * p2,20.000,100.0%,.000,0.0%,20.000,100.0%
1620 Table: p1 * p2 [[count]].
1623 .000,18.000,1.000,19.000
1624 1.000,1.000,.000,1.000
1625 Total,19.000,1.000,20.000
1627 Table: Symmetric measures.
1628 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1629 Measure of Agreement,Kappa,-.053,.037,-.235,
1630 N of Valid Cases,,20.000,,,
1636 AT_SETUP([CROSSTABS many statistics])
1637 AT_DATA([crosstabs.sps], [dnl
1640 * From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
1641 DATA LIST LIST NOTABLE/x y w.
1650 CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
1652 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
1655 ,Valid,,Missing,,Total,
1656 ,N,Percent,N,Percent,N,Percent
1657 x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
1659 Table: Chi-square tests.
1660 Statistic,Value,df,Asymp. Sig. (2-tailed)
1661 Pearson Chi-Square,6.9562,2.0000,.031
1662 Likelihood Ratio,6.6901,2.0000,.035
1663 Linear-by-Linear Association,5.8450,1.0000,.016
1664 N of Valid Cases,66.0000,,
1666 Table: Symmetric measures.
1667 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1668 Nominal by Nominal,Phi,.3246,,,
1669 ,Cramer's V,.3246,,,
1670 ,Contingency Coefficient,.3088,,,
1671 Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
1672 ,Kendall's tau-c,.1497,.0751,1.9920,
1673 ,Gamma,.8717,.1250,1.9920,
1674 ,Spearman Correlation,.2908,.0906,2.4311,
1675 Interval by Interval,Pearson's R,.2999,.0973,2.5147,
1676 N of Valid Cases,,66.0000,,,
1678 Table: Directional measures.
1679 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1680 Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
1681 ,,x Dependent,.0000,.0000,NaN,NaN
1682 ,,y Dependent,.0500,.1791,.2723,.785
1683 ,Goodman and Kruskal tau,x Dependent,.1054,,,. @&t@
1684 ,,y Dependent,.0434,,,. @&t@
1685 ,Uncertainty Coefficient,Symmetric,.0780,.0474,,. @&t@
1686 ,,x Dependent,.2217,.1062,1.5373,. @&t@
1687 ,,y Dependent,.0473,.0306,1.5373,. @&t@
1688 Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
1689 ,,x Dependent,.1152,.0572,1.9920,.046
1690 ,,y Dependent,.6573,.1417,1.9920,.046
1694 AT_SETUP([CROSSTABS uncertainy coefficient])
1695 AT_DATA([uc.sps], [dnl
1696 * From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
1699 DATA LIST LIST NOTABLE/x y w.
1709 CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
1711 AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
1714 ,Valid,,Missing,,Total,
1715 ,N,Percent,N,Percent,N,Percent
1716 x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
1718 Table: Directional measures.
1719 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1720 Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
1721 ,,x Dependent,.000,.000,NaN,NaN
1722 ,,y Dependent,.000,.000,NaN,NaN
1723 ,Goodman and Kruskal tau,x Dependent,.076,,,. @&t@
1724 ,,y Dependent,.108,,,. @&t@
1725 ,Uncertainty Coefficient,Symmetric,.105,.012,,. @&t@
1726 ,,x Dependent,.073,.009,7.890,. @&t@
1727 ,,y Dependent,.184,.019,7.890,. @&t@
1733 AT_SETUP([CROSSTABS barchart])
1734 AT_DATA([bc.sps], [dnl
1737 DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
1761 AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
1763 AT_CHECK([test -e xxx-1.png], [0], [ignore])
1764 AT_CHECK([test -e xxx-2.png], [0], [ignore])
1766 AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])