CROSSTABS: Drop buggy ASE for asymmetric lambda; fix T for symmetric lambda.
[pspp] / tests / language / stats / crosstabs.at
1 AT_BANNER([CROSSTABS procedure])
2
3 AT_SETUP([CROSSTABS integer mode crash])
4 AT_DATA([crosstabs.sps],
5   [DATA LIST LIST /A * B * X * Y * .
6 BEGIN DATA.
7 2 3 4 5
8 END DATA.
9
10 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
11 ])
12 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], 
13   [[Table: Reading free-form data from INLINE.
14 Variable,Format
15 A,F8.0
16 B,F8.0
17 X,F8.0
18 Y,F8.0
19
20 Table: Summary.
21 ,Cases,,,,,
22 ,Valid,,Missing,,Total,
23 ,N,Percent,N,Percent,N,Percent
24 X * Y,1,100.0%,0,0.0%,1,100.0%
25
26 Table: X * Y [count].
27 ,Y,,,,,,,
28 X,1.00,2.00,3.00,4.00,5.00,6.00,7.00,Total
29 1.00,.00,.00,.00,.00,.00,.00,.00,.00
30 2.00,.00,.00,.00,.00,.00,.00,.00,.00
31 3.00,.00,.00,.00,.00,.00,.00,.00,.00
32 4.00,.00,.00,.00,.00,1.00,.00,.00,1.00
33 5.00,.00,.00,.00,.00,.00,.00,.00,.00
34 6.00,.00,.00,.00,.00,.00,.00,.00,.00
35 7.00,.00,.00,.00,.00,.00,.00,.00,.00
36 Total,.00,.00,.00,.00,1.00,.00,.00,1.00
37 ]])
38 AT_CLEANUP
39
40 # Bug #22037.
41 AT_SETUP([CROSSTABS long string crash])
42 AT_DATA([crosstabs.sps],
43   [data list list /x * y (a18).
44
45 begin data.
46
47    1. 'zero none'
48
49 1 'one unity'
50 2 'two duality'
51 3 'three lots'
52 end data.
53
54 CROSSTABS /TABLES = x BY y.
55 ])
56 AT_CHECK([pspp -o - -O format=csv crosstabs.sps], [0],
57   [[Table: Reading free-form data from INLINE.
58 Variable,Format
59 x,F8.0
60 y,A18
61
62 "crosstabs.sps:4: warning: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
63
64 "crosstabs.sps:6: warning: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
65
66 Table: Summary.
67 ,Cases,,,,,
68 ,Valid,,Missing,,Total,
69 ,N,Percent,N,Percent,N,Percent
70 x * y,4,66.7%,2,33.3%,6,100.0%
71
72 Table: x * y [count].
73 ,y,,,,
74 x,one unity         ,three lots        ,two duality       ,zero none         ,Total
75 1.00,1.00,.00,.00,1.00,2.00
76 2.00,.00,.00,1.00,.00,1.00
77 3.00,.00,1.00,.00,.00,1.00
78 Total,1.00,1.00,1.00,1.00,4.00
79 ]])
80 AT_CLEANUP
81
82 AT_SETUP([CROSSTABS crash])
83 AT_DATA([crosstabs.sps],
84   [[DATA LIST FIXED
85      / x   1-2
86        y   3
87        z   4.
88
89 BEGIN DATA.
90 0111 
91 0222 
92 0311 
93 0412 
94 0521 
95 0612 
96 0711 
97 0811 
98 0912 
99 END DATA.
100
101 LIST.
102
103
104 CROSSTABS TABLES  y by z.
105 ]])
106 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
107   [[Table: Reading 1 record from INLINE.
108 Variable,Record,Columns,Format
109 x,1,1-  2,F2.0
110 y,1,3-  3,F1.0
111 z,1,4-  4,F1.0
112
113 Table: Data List
114 x,y,z
115 1,1,1
116 2,2,2
117 3,1,1
118 4,1,2
119 5,2,1
120 6,1,2
121 7,1,1
122 8,1,1
123 9,1,2
124
125 Table: Summary.
126 ,Cases,,,,,
127 ,Valid,,Missing,,Total,
128 ,N,Percent,N,Percent,N,Percent
129 y * z,9,100.0%,0,0.0%,9,100.0%
130
131 Table: y * z [count].
132 ,z,,
133 y,1,2,Total
134 1,4.00,3.00,7.00
135 2,1.00,1.00,2.00
136 Total,5.00,4.00,9.00
137 ]])
138 AT_CLEANUP
139
140 # Bug #26739, which caused CROSSTABS to crash or to fail to output
141 # chi-square results.
142 AT_SETUP([CROSSTABS chi-square crash])
143 AT_DATA([crosstabs.sps],
144   [[DATA LIST LIST /x * y *.
145 BEGIN DATA.
146 2 2
147 3 1
148 4 2
149 4 1
150 END DATA.
151
152 CROSSTABS
153         /TABLES= x BY y
154         /STATISTICS=CHISQ.
155 ]])
156 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
157   [[Table: Reading free-form data from INLINE.
158 Variable,Format
159 x,F8.0
160 y,F8.0
161
162 Table: Summary.
163 ,Cases,,,,,
164 ,Valid,,Missing,,Total,
165 ,N,Percent,N,Percent,N,Percent
166 x * y,4,100.0%,0,0.0%,4,100.0%
167
168 Table: x * y [count].
169 ,y,,
170 x,1.00,2.00,Total
171 2.00,.00,1.00,1.00
172 3.00,1.00,.00,1.00
173 4.00,1.00,1.00,2.00
174 Total,2.00,2.00,4.00
175
176 Table: Chi-square tests.
177 Statistic,Value,df,Asymp. Sig. (2-tailed)
178 Pearson Chi-Square,2.00,2,.368
179 Likelihood Ratio,2.77,2,.250
180 Linear-by-Linear Association,.27,1,.602
181 N of Valid Cases,4,,
182 ]])
183 AT_CLEANUP
184
185 # Bug #27883.
186 AT_SETUP([CROSSTABS crash with SPLIT FILE])
187 AT_DATA([crosstabs.sps],
188   [data list notable / v0 to v2 1-6 (A)
189 begin data.
190 a c e
191 a c e
192 a c e
193 a d e
194 a d f
195 b d f
196 b d f
197 b c f
198 b d e
199 a c f
200 end data.
201 SORT CASES BY v0.
202 SPLIT FILE SEPARATE BY v0.
203
204 CROSSTABS
205     /TABLES= v1 BY v2
206     /FORMAT=AVALUE TABLES PIVOT
207     /STATISTICS=CHISQ
208     /CELLS=COUNT ROW COLUMN TOTAL.
209 ])
210
211 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
212   [[Variable,Value,Label
213 v0,a ,
214
215 Table: Summary.
216 ,Cases,,,,,
217 ,Valid,,Missing,,Total,
218 ,N,Percent,N,Percent,N,Percent
219 v1 * v2,6,100.0%,0,0.0%,6,100.0%
220
221 "Table: v1 * v2 [count, row %, column %, total %]."
222 ,v2,,
223 v1,e ,f ,Total
224 c ,3.00,1.00,4.00
225 ,75.00%,25.00%,100.00%
226 ,75.00%,50.00%,66.67%
227 ,50.00%,16.67%,66.67%
228 d ,1.00,1.00,2.00
229 ,50.00%,50.00%,100.00%
230 ,25.00%,50.00%,33.33%
231 ,16.67%,16.67%,33.33%
232 Total,4.00,2.00,6.00
233 ,66.67%,33.33%,100.00%
234 ,100.00%,100.00%,100.00%
235 ,66.67%,33.33%,100.00%
236
237 Table: Chi-square tests.
238 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
239 Pearson Chi-Square,.38,1,.540,,
240 Likelihood Ratio,.37,1,.545,,
241 Fisher's Exact Test,,,,1.000,.600
242 Continuity Correction,.00,1,1.000,,
243 N of Valid Cases,6,,,,
244
245 Variable,Value,Label
246 v0,b ,
247
248 Table: Summary.
249 ,Cases,,,,,
250 ,Valid,,Missing,,Total,
251 ,N,Percent,N,Percent,N,Percent
252 v1 * v2,4,100.0%,0,0.0%,4,100.0%
253
254 "Table: v1 * v2 [count, row %, column %, total %]."
255 ,v2,,
256 v1,e ,f ,Total
257 c ,.00,1.00,1.00
258 ,.00%,100.00%,100.00%
259 ,.00%,33.33%,25.00%
260 ,.00%,25.00%,25.00%
261 d ,1.00,2.00,3.00
262 ,33.33%,66.67%,100.00%
263 ,100.00%,66.67%,75.00%
264 ,25.00%,50.00%,75.00%
265 Total,1.00,3.00,4.00
266 ,25.00%,75.00%,100.00%
267 ,100.00%,100.00%,100.00%
268 ,25.00%,75.00%,100.00%
269
270 Table: Chi-square tests.
271 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
272 Pearson Chi-Square,.44,1,.505,,
273 Likelihood Ratio,.68,1,.410,,
274 Fisher's Exact Test,,,,1.000,.750
275 Continuity Correction,.00,1,1.000,,
276 N of Valid Cases,4,,,,
277 ]])
278 AT_CLEANUP
279
280 # Bug #24752.
281 AT_SETUP([3-way CROSSTABS])
282 AT_DATA([crosstabs.sps],
283   [[DATA LIST FIXED
284      / x   1-2
285        y   3
286        z   4.
287
288 BEGIN DATA.
289 0111 
290 0222 
291 0311 
292 0412 
293 0521 
294 0612 
295 0711 
296 0811 
297 0912 
298 END DATA.
299
300 LIST.
301
302
303 CROSSTABS TABLES  x BY y BY z/STATISTICS=ALL.
304 ]])
305 AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
306   [[Table: Reading 1 record from INLINE.
307 Variable,Record,Columns,Format
308 x,1,1-  2,F2.0
309 y,1,3-  3,F1.0
310 z,1,4-  4,F1.0
311
312 Table: Data List
313 x,y,z
314 1,1,1
315 2,2,2
316 3,1,1
317 4,1,2
318 5,2,1
319 6,1,2
320 7,1,1
321 8,1,1
322 9,1,2
323
324 Table: Summary.
325 ,Cases,,,,,
326 ,Valid,,Missing,,Total,
327 ,N,Percent,N,Percent,N,Percent
328 x * y * z,9,100.0%,0,0.0%,9,100.0%
329
330 Table: x * y * z [count].
331 z,,y,,
332 ,x,1,2,Total
333 1,1,1.00,.00,1.00
334 ,3,1.00,.00,1.00
335 ,5,.00,1.00,1.00
336 ,7,1.00,.00,1.00
337 ,8,1.00,.00,1.00
338 Total,,4.00,1.00,5.00
339 2,2,.00,1.00,1.00
340 ,4,1.00,.00,1.00
341 ,6,1.00,.00,1.00
342 ,9,1.00,.00,1.00
343 Total,,3.00,1.00,4.00
344
345 Table: Chi-square tests.
346 z,Statistic,Value,df,Asymp. Sig. (2-tailed)
347 1,Pearson Chi-Square,5.00,4,.287
348 ,Likelihood Ratio,5.00,4,.287
349 ,Linear-by-Linear Association,.01,1,.938
350 ,N of Valid Cases,5,,
351 2,Pearson Chi-Square,4.00,3,.261
352 ,Likelihood Ratio,4.50,3,.212
353 ,Linear-by-Linear Association,1.58,1,.209
354 ,N of Valid Cases,4,,
355
356 Table: Symmetric measures.
357 z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
358 1,Nominal by Nominal,Phi,1.00,,,
359 ,,Cramer's V,1.00,,,
360 ,,Contingency Coefficient,.71,,,
361 ,Ordinal by Ordinal,Kendall's tau-b,.00,.32,.00,
362 ,,Kendall's tau-c,.00,.32,.00,
363 ,,Gamma,.00,.50,.00,
364 ,,Spearman Correlation,.00,.22,.00,
365 ,Interval by Interval,Pearson's R,.04,.22,.07,
366 ,N of Valid Cases,,5,,,
367 2,Nominal by Nominal,Phi,1.00,,,
368 ,,Cramer's V,1.00,,,
369 ,,Contingency Coefficient,.71,,,
370 ,Ordinal by Ordinal,Kendall's tau-b,-.71,.20,-1.73,
371 ,,Kendall's tau-c,-.75,.43,-1.73,
372 ,,Gamma,-1.00,.00,-1.73,
373 ,,Spearman Correlation,-.77,.17,-1.73,
374 ,Interval by Interval,Pearson's R,-.73,.18,-1.49,
375 ,N of Valid Cases,,4,,,
376
377 Table: Directional measures.
378 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
379 1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,
380 ,,,x Dependent,.25,,1.12,
381 ,,,y Dependent,1.00,,1.12,
382 ,,Goodman and Kruskal tau,x Dependent,.25,,,
383 ,,,y Dependent,1.00,,,
384 ,,Uncertainty Coefficient,Symmetric,.47,.18,1.51,
385 ,,,x Dependent,.31,.15,2.02,
386 ,,,y Dependent,1.00,.00,2.02,
387 ,Ordinal by Ordinal,Somers' d,Symmetric,.00,.09,.00,
388 ,,,x Dependent,.00,.50,.00,
389 ,,,y Dependent,.00,.20,.00,
390 ,Nominal by Interval,Eta,x Dependent,.04,,,
391 ,,,y Dependent,1.00,,,
392 2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,
393 ,,,x Dependent,.33,,1.15,
394 ,,,y Dependent,1.00,,1.15,
395 ,,Goodman and Kruskal tau,x Dependent,.33,,,
396 ,,,y Dependent,1.00,,,
397 ,,Uncertainty Coefficient,Symmetric,.58,.17,1.56,
398 ,,,x Dependent,.41,.17,2.36,
399 ,,,y Dependent,1.00,.00,2.36,
400 ,Ordinal by Ordinal,Somers' d,Symmetric,-.67,.04,-1.73,
401 ,,,x Dependent,-1.00,.00,-1.73,
402 ,,,y Dependent,-.50,.29,-1.73,
403 ,Nominal by Interval,Eta,x Dependent,.73,,,
404 ,,,y Dependent,1.00,,,
405 ]])
406 AT_CLEANUP
407
408
409
410 AT_SETUP([CROSSTABS descending sort order])
411 AT_DATA([crosstabs-descending.sps],
412   [[DATA LIST NOTABLE LIST /x * y *.
413 BEGIN DATA.
414 2 2
415 2 2
416 3 1
417 4 1
418 3 2
419 3 2
420 END DATA.
421
422 CROSSTABS
423         /TABLES= x BY y
424         /FORMAT = DVALUE.
425 ]])
426
427 AT_CHECK([pspp -O format=csv crosstabs-descending.sps], [0],
428   [[Table: Summary.
429 ,Cases,,,,,
430 ,Valid,,Missing,,Total,
431 ,N,Percent,N,Percent,N,Percent
432 x * y,6,100.0%,0,0.0%,6,100.0%
433
434 Table: x * y [count].
435 ,y,,
436 x,2.00,1.00,Total
437 4.00,.00,1.00,1.00
438 3.00,2.00,1.00,3.00
439 2.00,2.00,.00,2.00
440 Total,4.00,2.00,6.00
441 ]])
442 AT_CLEANUP
443
444 # Bug #31260.
445 AT_SETUP([CROSSTABS crash when all cases missing])
446 AT_DATA([crosstabs.sps], [dnl
447 DATA LIST LIST NOTABLE /X1 X2.
448 BEGIN DATA.
449 1 1
450 END DATA.
451
452 MISSING VALUES x2 (1).
453
454 CROSSTABS /TABLES= X1 by X2.
455 ])
456 AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
457 Table: Summary.
458 ,Cases,,,,,
459 ,Valid,,Missing,,Total,
460 ,N,Percent,N,Percent,N,Percent
461 X1 * X2,0,0.0%,1,100.0%,1,100.0%
462
463 crosstabs.sps:8: warning: CROSSTABS: Crosstabulation X1 * X2 contained no non-missing cases.
464 ])
465 AT_CLEANUP
466
467
468
469 dnl This example comes from http://www.ats.ucla.edu/stat/spss/whatstat/whatstat.htm#chisq
470 AT_SETUP([CROSSTABS Fisher Exact Test])
471
472 AT_DATA([fisher-exact.sps], [dnl
473 SET FORMAT F12.3.
474 SET DECIMAL DOT.
475
476 DATA LIST notable LIST  /schtyp (F9.2) female (F9.2) ses (F9.2) .
477 begin data.
478       1.00       .00      1.00 
479       1.00      1.00      2.00 
480       1.00       .00      3.00 
481       1.00       .00      3.00 
482       1.00       .00      2.00 
483       1.00       .00      2.00 
484       1.00       .00      2.00 
485       1.00       .00      2.00 
486       1.00       .00      2.00 
487       1.00       .00      2.00 
488       1.00       .00      2.00 
489       1.00       .00      2.00 
490       1.00       .00      3.00 
491       1.00       .00      3.00 
492       1.00       .00      1.00 
493       1.00       .00      1.00 
494       1.00       .00      3.00 
495       2.00       .00      2.00 
496       1.00       .00      3.00 
497       1.00       .00      2.00 
498       1.00       .00      2.00 
499       1.00       .00      2.00 
500       1.00       .00      2.00 
501       1.00       .00      3.00 
502       1.00       .00      2.00 
503       1.00       .00      2.00 
504       1.00       .00      3.00 
505       2.00       .00      2.00 
506       2.00       .00      3.00 
507       1.00       .00      1.00 
508       1.00       .00      2.00 
509       1.00       .00      3.00 
510       2.00       .00      3.00 
511       1.00       .00      2.00 
512       2.00       .00      3.00 
513       1.00       .00      3.00 
514       2.00       .00      2.00 
515       1.00       .00      3.00 
516       1.00       .00      1.00 
517       1.00       .00      2.00 
518       2.00       .00      2.00 
519       2.00       .00      2.00 
520       1.00       .00      2.00 
521       1.00       .00      1.00 
522       1.00       .00      3.00 
523       1.00       .00      1.00 
524       1.00       .00      3.00 
525       1.00       .00      2.00 
526       2.00       .00      2.00 
527       1.00       .00      2.00 
528       1.00       .00      2.00 
529       1.00       .00      3.00 
530       1.00       .00      2.00 
531       2.00       .00      2.00 
532       1.00       .00      2.00 
533       1.00       .00      3.00 
534       1.00       .00      1.00 
535       1.00       .00      2.00 
536       2.00       .00      2.00 
537       1.00       .00      2.00 
538       2.00       .00      2.00 
539       1.00       .00      3.00 
540       1.00       .00      1.00 
541       1.00       .00      2.00 
542       2.00       .00      3.00 
543       1.00       .00      2.00 
544       1.00       .00      2.00 
545       1.00       .00      1.00 
546       1.00       .00      1.00 
547       1.00       .00      2.00 
548       1.00       .00      2.00 
549       1.00       .00      3.00 
550       1.00       .00      2.00 
551       1.00       .00      2.00 
552       1.00       .00      2.00 
553       1.00       .00      1.00 
554       1.00       .00      3.00 
555       1.00       .00      3.00 
556       1.00       .00      2.00 
557       1.00       .00      3.00 
558       1.00       .00      3.00 
559       1.00       .00      1.00 
560       2.00       .00      2.00 
561       1.00       .00      1.00 
562       1.00       .00      2.00 
563       1.00       .00      3.00 
564       1.00       .00      3.00 
565       1.00       .00      3.00 
566       1.00       .00      2.00 
567       1.00       .00      3.00 
568       1.00       .00      2.00 
569       1.00       .00      1.00 
570       1.00      1.00      3.00 
571       1.00      1.00      1.00 
572       1.00      1.00      1.00 
573       1.00      1.00      1.00 
574       1.00      1.00      2.00 
575       1.00      1.00      3.00 
576       1.00      1.00      1.00 
577       2.00      1.00      3.00 
578       1.00      1.00      3.00 
579       1.00      1.00      3.00 
580       1.00      1.00      1.00 
581       1.00      1.00      3.00 
582       1.00      1.00      2.00 
583       1.00      1.00      2.00 
584       1.00      1.00      3.00 
585       1.00      1.00      1.00 
586       2.00      1.00      1.00 
587       2.00      1.00      3.00 
588       1.00      1.00      2.00 
589       1.00      1.00      1.00 
590       1.00      1.00      3.00 
591       1.00      1.00      1.00 
592       2.00      1.00      3.00 
593       1.00      1.00      2.00 
594       1.00      1.00      3.00 
595       1.00      1.00      3.00 
596       1.00      1.00      1.00 
597       1.00      1.00      1.00 
598       2.00      1.00      1.00 
599       1.00      1.00      2.00 
600       1.00      1.00      2.00 
601       1.00      1.00      2.00 
602       1.00      1.00      1.00 
603       1.00      1.00      3.00 
604       1.00      1.00      2.00 
605       1.00      1.00      2.00 
606       1.00      1.00      3.00 
607       1.00      1.00      1.00 
608       1.00      1.00      2.00 
609       1.00      1.00      1.00 
610       1.00      1.00      2.00 
611       1.00      1.00      2.00 
612       1.00      1.00      1.00 
613       1.00      1.00      3.00 
614       2.00      1.00      2.00 
615       1.00      1.00      2.00 
616       1.00      1.00      2.00 
617       2.00      1.00      2.00 
618       1.00      1.00      1.00 
619       1.00      1.00      3.00 
620       1.00      1.00      2.00 
621       1.00      1.00      2.00 
622       1.00      1.00      2.00 
623       2.00      1.00      3.00 
624       1.00      1.00      2.00 
625       2.00      1.00      2.00 
626       1.00      1.00      1.00 
627       1.00      1.00      1.00 
628       1.00      1.00      1.00 
629       1.00      1.00      3.00 
630       1.00      1.00      2.00 
631       1.00      1.00      2.00 
632       1.00      1.00      2.00 
633       1.00      1.00      2.00 
634       1.00      1.00      2.00 
635       1.00      1.00      2.00 
636       1.00      1.00      2.00 
637       1.00      1.00      3.00 
638       1.00      1.00      1.00 
639       1.00      1.00      2.00 
640       2.00      1.00      3.00 
641       1.00      1.00      1.00 
642       1.00      1.00      2.00 
643       1.00      1.00      1.00 
644       1.00      1.00      2.00 
645       1.00      1.00      1.00 
646       2.00      1.00      2.00 
647       1.00      1.00      1.00 
648       1.00      1.00      1.00 
649       1.00      1.00      2.00 
650       1.00      1.00      3.00 
651       1.00      1.00      3.00 
652       1.00      1.00      1.00 
653       1.00      1.00      1.00 
654       1.00      1.00      2.00 
655       1.00      1.00      2.00 
656       1.00      1.00      3.00 
657       1.00      1.00      1.00 
658       1.00      1.00      2.00 
659       2.00      1.00      2.00 
660       1.00      1.00      3.00 
661       1.00      1.00      2.00 
662       1.00      1.00      3.00 
663       1.00      1.00      1.00 
664       1.00      1.00      2.00 
665       1.00      1.00      2.00 
666       2.00      1.00      3.00 
667       1.00      1.00      1.00 
668       1.00      1.00      1.00 
669       2.00      1.00      3.00 
670       2.00      1.00      2.00 
671       1.00      1.00      3.00 
672       2.00      1.00      2.00 
673       2.00      1.00      2.00 
674       1.00      1.00      2.00 
675       2.00      1.00      2.00 
676       1.00      1.00      2.00 
677       1.00      1.00      3.00 
678 end data.
679
680 VARIABLE LABEL schtyp 'type of school'.
681 ADD VALUE LABELS female 0 male 1 female.
682 ADD VALUE LABELS ses 1 low 2 middle 3 high.
683 ADD VALUE LABELS schtyp 1 public 2 private.
684
685 crosstabs /tables = schtyp by female /statistic = chisq.
686 crosstabs /tables = female by ses  /statistic = chisq.
687 ])
688
689 AT_CHECK([pspp -O format=csv fisher-exact.sps], [0], [dnl
690 Table: Summary.
691 ,Cases,,,,,
692 ,Valid,,Missing,,Total,
693 ,N,Percent,N,Percent,N,Percent
694 type of school * female,200,100.0%,0,0.0%,200,100.0%
695
696 Table: type of school * female [[count]].
697 ,female,,
698 type of school,male,female,Total
699 public,77.000,91.000,168.000
700 private,14.000,18.000,32.000
701 Total,91.000,109.000,200.000
702
703 Table: Chi-square tests.
704 Statistic,Value,df,Asymp. Sig. (2-tailed),Exact Sig. (2-tailed),Exact Sig. (1-tailed)
705 Pearson Chi-Square,.047,1,.828,,
706 Likelihood Ratio,.047,1,.828,,
707 Fisher's Exact Test,,,,.849,.492
708 Continuity Correction,.001,1,.981,,
709 Linear-by-Linear Association,.047,1,.829,,
710 N of Valid Cases,200,,,,
711
712 Table: Summary.
713 ,Cases,,,,,
714 ,Valid,,Missing,,Total,
715 ,N,Percent,N,Percent,N,Percent
716 female * ses,200,100.0%,0,0.0%,200,100.0%
717
718 Table: female * ses [[count]].
719 ,ses,,,
720 female,low,middle,high,Total
721 male,15.000,47.000,29.000,91.000
722 female,32.000,48.000,29.000,109.000
723 Total,47.000,95.000,58.000,200.000
724
725 Table: Chi-square tests.
726 Statistic,Value,df,Asymp. Sig. (2-tailed)
727 Pearson Chi-Square,4.577,2,.101
728 Likelihood Ratio,4.679,2,.096
729 Linear-by-Linear Association,3.110,1,.078
730 N of Valid Cases,200,,
731 ])
732
733 AT_CLEANUP
734
735 AT_SETUP([CROSSTABS Pearson's R])
736 # Test 1.
737 AT_DATA([pearson.sps], [dnl
738 SET FORMAT F8.3.
739
740 * From http://www.statisticslectures.com/topics/pearsonr/.
741 DATA LIST FREE/x y.
742 BEGIN DATA.
743 1 4
744 3 6
745 5 10
746 5 12
747 6 13
748 END DATA.
749 CROSSTABS x BY y/STATISTICS=CORR.
750 ])
751 AT_CHECK([pspp -O format=csv pearson.sps], [0], [dnl
752 Table: Summary.
753 ,Cases,,,,,
754 ,Valid,,Missing,,Total,
755 ,N,Percent,N,Percent,N,Percent
756 x * y,5,100.0%,0,0.0%,5,100.0%
757
758 Table: x * y [[count]].
759 ,y,,,,,
760 x,4.000,6.000,10.000,12.000,13.000,Total
761 1.000,1.000,.000,.000,.000,.000,1.000
762 3.000,.000,1.000,.000,.000,.000,1.000
763 5.000,.000,.000,1.000,1.000,.000,2.000
764 6.000,.000,.000,.000,.000,1.000,1.000
765 Total,1.000,1.000,1.000,1.000,1.000,5.000
766
767 Table: Symmetric measures.
768 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
769 Ordinal by Ordinal,Spearman Correlation,.975,.022,7.550,
770 Interval by Interval,Pearson's R,.968,.017,6.708,
771 N of Valid Cases,,5,,,
772 ])
773
774 # Test 2.
775 AT_DATA([pearson2.sps], [dnl
776 SET FORMAT F8.3.
777
778 * Checked with http://www.socscistatistics.com/tests/pearson/Default2.aspx.
779 DATA LIST FREE/x y.
780 BEGIN DATA.
781 1 1.5
782 2 1.5
783 3 4
784 4 6
785 5 5
786 6 7
787 7 6.5
788 8 9
789 9 10.5
790 10 11
791 END DATA.
792 CROSSTABS x BY y/STATISTICS=CORR.
793 ])
794 AT_CHECK([pspp -O format=csv pearson2.sps], [0], [dnl
795 Table: Summary.
796 ,Cases,,,,,
797 ,Valid,,Missing,,Total,
798 ,N,Percent,N,Percent,N,Percent
799 x * y,10,100.0%,0,0.0%,10,100.0%
800
801 Table: x * y [[count]].
802 ,y,,,,,,,,,
803 x,1.500,4.000,5.000,6.000,6.500,7.000,9.000,10.500,11.000,Total
804 1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
805 2.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
806 3.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
807 4.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
808 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
809 6.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
810 7.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
811 8.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
812 9.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
813 10.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
814 Total,2.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
815
816 Table: Symmetric measures.
817 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
818 Ordinal by Ordinal,Spearman Correlation,.973,.015,11.844,
819 Interval by Interval,Pearson's R,.971,.017,11.580,
820 N of Valid Cases,,10,,,
821 ])
822
823 # Test 3.
824 AT_DATA([pearson3.sps], [dnl
825 SET FORMAT F8.3.
826
827 * From http://learntech.uwe.ac.uk/da/Default.aspx?pageid=1442.
828 DATA LIST FREE/x y.
829 BEGIN DATA.
830 56 87
831 56 91
832 65 85
833 65 91
834 50 75
835 25 28
836 87 122
837 44 66
838 35 58
839 END DATA.
840 CROSSTABS x BY y/STATISTICS=CORR.
841 ])
842 AT_CHECK([pspp -O format=csv pearson3.sps], [0], [dnl
843 Table: Summary.
844 ,Cases,,,,,
845 ,Valid,,Missing,,Total,
846 ,N,Percent,N,Percent,N,Percent
847 x * y,9,100.0%,0,0.0%,9,100.0%
848
849 Table: x * y [[count]].
850 ,y,,,,,,,,
851 x,28.000,58.000,66.000,75.000,85.000,87.000,91.000,122.000,Total
852 25.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
853 35.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
854 44.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
855 50.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
856 56.000,.000,.000,.000,.000,.000,1.000,1.000,.000,2.000
857 65.000,.000,.000,.000,.000,1.000,.000,1.000,.000,2.000
858 87.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
859 Total,1.000,1.000,1.000,1.000,1.000,1.000,2.000,1.000,9.000
860
861 Table: Symmetric measures.
862 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
863 Ordinal by Ordinal,Spearman Correlation,.911,.068,5.860,
864 Interval by Interval,Pearson's R,.966,.017,9.915,
865 N of Valid Cases,,9,,,
866 ])
867
868 # Test 4.
869 AT_DATA([pearson4.sps], [dnl
870 SET FORMAT F8.3.
871
872 * From http://psychology.ucdavis.edu/faculty_sites/sommerb/sommerdemo/correlation/hand/pearson_hand.htm.
873 DATA LIST FREE/x y.
874 BEGIN DATA.
875 5 5
876 10 20
877 6 4
878 8 15
879 4 11
880 4 9
881 3 12
882 10 18
883 2 7
884 6 2
885 7 14
886 9 17
887 END DATA.
888 CROSSTABS x BY y/STATISTICS=CORR.
889 ])
890 AT_CHECK([pspp -O format=csv pearson4.sps], [0], [dnl
891 Table: Summary.
892 ,Cases,,,,,
893 ,Valid,,Missing,,Total,
894 ,N,Percent,N,Percent,N,Percent
895 x * y,12,100.0%,0,0.0%,12,100.0%
896
897 Table: x * y [[count]].
898 ,y,,,,,,,,,,,,
899 x,2.000,4.000,5.000,7.000,9.000,11.000,12.000,14.000,15.000,17.000,18.000,20.000,Total
900 2.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
901 3.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
902 4.000,.000,.000,.000,.000,1.000,1.000,.000,.000,.000,.000,.000,.000,2.000
903 5.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
904 6.000,1.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,2.000
905 7.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
906 8.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
907 9.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
908 10.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000,2.000
909 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,12.000
910
911 Table: Symmetric measures.
912 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
913 Ordinal by Ordinal,Spearman Correlation,.657,.140,2.758,
914 Interval by Interval,Pearson's R,.667,.132,2.830,
915 N of Valid Cases,,12,,,
916 ])
917
918 # Test 5.
919 AT_DATA([pearson5.sps], [dnl
920 SET FORMAT F8.3.
921
922 * From http://www.statisticslectures.com/topics/pearsonr/.
923 DATA LIST FREE/x y.
924 BEGIN DATA.
925 18 15000
926 25 29000
927 57 68000
928 45 52000
929 26 32000
930 64 80000
931 37 41000
932 40 45000
933 24 26000
934 33 33000
935 END DATA.
936 CROSSTABS x BY y/STATISTICS=CORR.
937 ])
938 AT_CHECK([pspp -O format=csv pearson5.sps], [0], [dnl
939 Table: Summary.
940 ,Cases,,,,,
941 ,Valid,,Missing,,Total,
942 ,N,Percent,N,Percent,N,Percent
943 x * y,10,100.0%,0,0.0%,10,100.0%
944
945 Table: x * y [[count]].
946 ,y,,,,,,,,,,
947 x,15000.000,26000.000,29000.000,32000.000,33000.000,41000.000,45000.000,52000.000,68000.000,80000.000,Total
948 18.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
949 24.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000
950 25.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,.000,1.000
951 26.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,.000,1.000
952 33.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,.000,1.000
953 37.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,.000,1.000
954 40.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,.000,1.000
955 45.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,.000,1.000
956 57.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,.000,1.000
957 64.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,1.000,1.000
958 Total,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,1.000,10.000
959
960 Table: Symmetric measures.
961 Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
962 Ordinal by Ordinal,Spearman Correlation,1.000,.000,+Infinity,
963 Interval by Interval,Pearson's R,.992,.004,22.638,
964 N of Valid Cases,,10,,,
965 ])
966 AT_CLEANUP
967
968 AT_SETUP([CROSSTABS Goodman and Kruskal's lambda])
969 AT_DATA([lambda.sps], [dnl
970 SET FORMAT F8.3.
971
972 * From http://www.csupomona.edu/~jlkorey/POWERMUTT/Topics/contingency_tables.html.
973 DATA LIST LIST NOTABLE/x y w.
974 WEIGHT BY w.
975 BEGIN DATA.
976 1 1 424
977 1 2 213
978 1 3 59
979 3 1 55
980 3 2 188
981 3 3 357
982 END DATA.
983
984 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
985
986 * From http://vassarstats.net.
987 DATA LIST LIST NOTABLE/x y w.
988 WEIGHT BY w.
989 BEGIN DATA.
990 1 1 19
991 1 2 26
992 1 3 8
993 2 1 21
994 2 2 13
995 2 3 5
996 3 1 6
997 3 2 12
998 3 3 27
999 END DATA.
1000
1001 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1002
1003 * From Goodman, L.A., Kruskal, W.H. (1954) "Measures of association for
1004   cross classifications". Part I. Journal of the American Statistical
1005   Association, 49, 732-764.
1006 DATA LIST LIST NOTABLE/x y w.
1007 WEIGHT BY w.
1008 BEGIN DATA.
1009 1 1 1768
1010 1 2 807
1011 1 3 189
1012 1 4 47
1013 2 1 946
1014 2 2 1387
1015 2 3 746
1016 2 4 53
1017 3 1 115
1018 3 2 438
1019 3 3 288
1020 3 4 16
1021 END DATA.
1022 CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
1023 ])
1024 AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
1025 Table: Summary.
1026 ,Cases,,,,,
1027 ,Valid,,Missing,,Total,
1028 ,N,Percent,N,Percent,N,Percent
1029 x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
1030
1031 Table: Directional measures.
1032 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1033 Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,
1034 ,,x Dependent,.497,,15.986,
1035 ,,y Dependent,.370,,16.339,
1036 ,Goodman and Kruskal tau,x Dependent,.382,,,
1037 ,,y Dependent,.198,,,
1038
1039 Table: Summary.
1040 ,Cases,,,,,
1041 ,Valid,,Missing,,Total,
1042 ,N,Percent,N,Percent,N,Percent
1043 x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
1044
1045 Table: Directional measures.
1046 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1047 Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,
1048 ,,x Dependent,.250,,2.479,
1049 ,,y Dependent,.267,,2.766,
1050 ,Goodman and Kruskal tau,x Dependent,.129,,,
1051 ,,y Dependent,.123,,,
1052
1053 Table: Summary.
1054 ,Cases,,,,,
1055 ,Valid,,Missing,,Total,
1056 ,N,Percent,N,Percent,N,Percent
1057 x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
1058
1059 Table: Directional measures.
1060 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
1061 Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,
1062 ,,x Dependent,.224,,16.076,
1063 ,,y Dependent,.192,,14.438,
1064 ,Goodman and Kruskal tau,x Dependent,.089,,,
1065 ,,y Dependent,.081,,,
1066 ])
1067 AT_CLEANUP