Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / stats / crosstabs.at
index c33857b8f2eaa45805efdc847765b5b4d0fad8ca..6c34c68a436ad7fd6367da29354be1b0ba5ed024 100644 (file)
@@ -1,3 +1,19 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl 
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
 AT_BANNER([CROSSTABS procedure])
 
 AT_SETUP([CROSSTABS integer mode crash])
@@ -37,6 +53,32 @@ Total,.00,.00,.00,.00,1.00,.00,.00,1.00
 ]])
 AT_CLEANUP
 
+# Bug #47600.
+AT_SETUP([CROSSTABS integer mode crash 2])
+AT_DATA([crosstabs.sps], [dnl
+DATA LIST lIST /x y.
+BEGIN DATA.
+4 5
+END DATA.
+
+CROSSTABS
+        VARIABLES x (1,3) y (1,7)
+      /TABLES x BY y.
+])
+AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
+  [[Table: Reading free-form data from INLINE.
+Variable,Format
+x,F8.0
+y,F8.0
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,0,0.0%,1,100.0%,1,100.0%
+]])
+AT_CLEANUP
+
 # Bug #22037.
 AT_SETUP([CROSSTABS long string crash])
 AT_DATA([crosstabs.sps],
@@ -376,36 +418,141 @@ z,Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
 
 Table: Directional measures.
 z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,
-,,,x Dependent,.25,,1.12,
-,,,y Dependent,1.00,,1.12,
-,,Goodman and Kruskal tau,x Dependent,.25,,,
-,,,y Dependent,1.00,,,
-,,Uncertainty Coefficient,Symmetric,.47,.18,1.51,
-,,,x Dependent,.31,.15,2.02,
-,,,y Dependent,1.00,.00,2.02,
-,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,
-,,,x Dependent,.00,.50,.00,
-,,,y Dependent,.00,.20,.00,
-,Nominal by Interval,Eta,x Dependent,.04,,,
-,,,y Dependent,1.00,,,
-2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,
-,,,x Dependent,.33,,1.15,
-,,,y Dependent,1.00,,1.15,
-,,Goodman and Kruskal tau,x Dependent,.33,,,
-,,,y Dependent,1.00,,,
-,,Uncertainty Coefficient,Symmetric,.58,.17,1.56,
-,,,x Dependent,.41,.17,2.36,
-,,,y Dependent,1.00,.00,2.36,
-,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,
-,,,x Dependent,-1.00,.00,-1.73,
-,,,y Dependent,-.50,.29,-1.73,
-,Nominal by Interval,Eta,x Dependent,.73,,,
-,,,y Dependent,1.00,,,
+1,Nominal by Nominal,Lambda,Symmetric,.40,.28,1.12,.264
+,,,x Dependent,.25,.22,1.12,.264
+,,,y Dependent,1.00,.00,1.12,.264
+,,Goodman and Kruskal tau,x Dependent,.25,,,.   @&t@
+,,,y Dependent,1.00,,,.   @&t@
+,,Uncertainty Coefficient,Symmetric,.47,.18,,.   @&t@
+,,,x Dependent,.31,.15,2.02,.   @&t@
+,,,y Dependent,1.00,.00,2.02,.   @&t@
+,Ordinal by Ordinal,Somers' d,Symmetric,.00,,.00,1.000
+,,,x Dependent,.00,.50,.00,1.000
+,,,y Dependent,.00,.20,.00,1.000
+,Nominal by Interval,Eta,x Dependent,.04,,,.   @&t@
+,,,y Dependent,1.00,,,.   @&t@
+2,Nominal by Nominal,Lambda,Symmetric,.50,.25,2.00,.046
+,,,x Dependent,.33,.27,1.15,.248
+,,,y Dependent,1.00,.00,1.15,.248
+,,Goodman and Kruskal tau,x Dependent,.33,,,.   @&t@
+,,,y Dependent,1.00,,,.   @&t@
+,,Uncertainty Coefficient,Symmetric,.58,.17,,.   @&t@
+,,,x Dependent,.41,.17,2.36,.   @&t@
+,,,y Dependent,1.00,.00,2.36,.   @&t@
+,Ordinal by Ordinal,Somers' d,Symmetric,-.67,,-1.73,.083
+,,,x Dependent,-1.00,.00,-1.73,.083
+,,,y Dependent,-.50,.29,-1.73,.083
+,Nominal by Interval,Eta,x Dependent,.73,,,.   @&t@
+,,,y Dependent,1.00,,,.   @&t@
 ]])
 AT_CLEANUP
 
+AT_SETUP([CROSSTABS rounding weights with COUNT])
+AT_DATA([crosstabs.sps],
+  [[DATA LIST NOTABLE LIST /x y w.
+BEGIN DATA.
+1 1 1.4
+1 1 1.4
+1 2 1.6
+1 2 1.6
+2 1 1
+2 2 2
+END DATA.
+WEIGHT BY w.
+
+* These should have the same effect (no rounding).
+CROSSTABS /TABLES x BY y.
+CROSSTABS /TABLES x BY y /COUNT ASIS.
+
+* Round input weights.
+CROSSTABS /TABLES x BY y /COUNT CASE ROUND.
+CROSSTABS /TABLES x BY y /COUNT CASE TRUNCATE.
+
+* Round cell weights.
+CROSSTABS /TABLES x BY y /COUNT.
+CROSSTABS /TABLES x BY y /COUNT TRUNCATE.
+]])
 
+AT_CHECK([pspp -O format=csv crosstabs.sps], [0],
+  [[Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,2.80,3.20,6.00
+2.00,1.00,2.00,3.00
+Total,3.80,5.20,9.00
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,2.80,3.20,6.00
+2.00,1.00,2.00,3.00
+Total,3.80,5.20,9.00
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,2.00,4.00,6.00
+2.00,1.00,2.00,3.00
+Total,3.00,6.00,9.00
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,7.00,100.0%,.00,0.0%,7.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,2.00,2.00,4.00
+2.00,1.00,2.00,3.00
+Total,3.00,4.00,7.00
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,9.00,100.0%,.00,0.0%,9.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,3.00,3.00,6.00
+2.00,1.00,2.00,3.00
+Total,4.00,5.00,9.00
+
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,8.00,100.0%,.00,0.0%,8.00,100.0%
+
+Table: x * y [count].
+,y,,
+x,1.00,2.00,Total
+1.00,2.00,3.00,5.00
+2.00,1.00,2.00,3.00
+Total,3.00,5.00,8.00
+]])
+AT_CLEANUP
 
 AT_SETUP([CROSSTABS descending sort order])
 AT_DATA([crosstabs-descending.sps],
@@ -1030,11 +1177,11 @@ x * y,1296.000,100.0%,.000,0.0%,1296.000,100.0%
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,
-,,x Dependent,.497,,15.986,
-,,y Dependent,.370,,16.339,
-,Goodman and Kruskal tau,x Dependent,.382,,,
-,,y Dependent,.198,,,
+Nominal by Nominal,Lambda,Symmetric,.423,.021,16.875,.000
+,,x Dependent,.497,.024,15.986,.000
+,,y Dependent,.370,.020,16.339,.000
+,Goodman and Kruskal tau,x Dependent,.382,,,.   @&t@
+,,y Dependent,.198,,,.   @&t@
 
 Table: Summary.
 ,Cases,,,,,
@@ -1044,11 +1191,11 @@ x * y,137.000,100.0%,.000,0.0%,137.000,100.0%
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,
-,,x Dependent,.250,,2.479,
-,,y Dependent,.267,,2.766,
-,Goodman and Kruskal tau,x Dependent,.129,,,
-,,y Dependent,.123,,,
+Nominal by Nominal,Lambda,Symmetric,.259,.081,2.902,.004
+,,x Dependent,.250,.089,2.479,.013
+,,y Dependent,.267,.085,2.766,.006
+,Goodman and Kruskal tau,x Dependent,.129,,,.   @&t@
+,,y Dependent,.123,,,.   @&t@
 
 Table: Summary.
 ,Cases,,,,,
@@ -1058,11 +1205,46 @@ x * y,6800.000,100.0%,.000,0.0%,6800.000,100.0%
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,
-,,x Dependent,.224,,16.076,
-,,y Dependent,.192,,14.438,
-,Goodman and Kruskal tau,x Dependent,.089,,,
-,,y Dependent,.081,,,
+Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000
+,,x Dependent,.224,.013,16.076,.000
+,,y Dependent,.192,.012,14.438,.000
+,Goodman and Kruskal tau,x Dependent,.089,,,.   @&t@
+,,y Dependent,.081,,,.   @&t@
+])
+AT_CLEANUP
+
+AT_SETUP([CROSSTABS Goodman and Kruskal's lambda - treatment of ties])
+AT_DATA([lambda.sps], [dnl
+SET FORMAT F8.3.
+
+* From Douglas Bonett.
+DATA LIST LIST NOTABLE/x y w.
+WEIGHT BY w.
+BEGIN DATA.
+1 1 225
+1 2 43
+1 3 216
+2 1 3
+2 2 1
+2 3 12
+END DATA.
+
+CROSSTABS x BY y/CELLS=NONE/STATISTICS=LAMBDA.
+])
+AT_CHECK([pspp -O format=csv lambda.sps], [0], [dnl
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,500.000,100.0%,.000,0.0%,500.000,100.0%
+
+Table: Directional measures.
+Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
+Nominal by Nominal,Lambda,Symmetric,.031,.013,2.336,.019
+,,x Dependent,.000,.000,NaN,NaN
+,,y Dependent,.033,.014,2.336,.019
+,Goodman and Kruskal tau,x Dependent,.012,,,.   @&t@
+,,y Dependent,.009,,,.   @&t@
 ])
 AT_CLEANUP
 
@@ -1116,9 +1298,9 @@ x * y,1.000000,100.0%,.000000,0.0%,1.000000,100.0%
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,
-,,x Dependent,-.045,.300,-.149,
-,,y Dependent,-.684,2.378,-.149,
+Ordinal by Ordinal,Somers' d,Symmetric,-.084,,-.149,.882
+,,x Dependent,-.045,.300,-.149,.882
+,,y Dependent,-.684,2.378,-.149,.882
 
 Table: Summary.
 ,Cases,,,,,
@@ -1135,9 +1317,9 @@ N of Valid Cases,,687.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,
-,,x Dependent,.351,.032,10.669,
-,,y Dependent,.394,.035,10.669,
+Ordinal by Ordinal,Somers' d,Symmetric,.371,,10.669,.000
+,,x Dependent,.351,.032,10.669,.000
+,,y Dependent,.394,.035,10.669,.000
 ])
 
 AT_DATA([ordinal.sps], [dnl
@@ -1263,9 +1445,9 @@ N of Valid Cases,,150.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,
-,,x Dependent,1.000,.000,24.841,
-,,y Dependent,1.000,.000,24.841,
+Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
+,,x Dependent,1.000,.000,24.841,.000
+,,y Dependent,1.000,.000,24.841,.000
 
 Table: Summary.
 ,Cases,,,,,
@@ -1281,9 +1463,9 @@ N of Valid Cases,,150.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,
-,,x Dependent,1.000,.000,24.841,
-,,y Dependent,1.000,.000,24.841,
+Ordinal by Ordinal,Somers' d,Symmetric,1.000,,24.841,.000
+,,x Dependent,1.000,.000,24.841,.000
+,,y Dependent,1.000,.000,24.841,.000
 
 Table: Summary.
 ,Cases,,,,,
@@ -1299,9 +1481,9 @@ N of Valid Cases,,150.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,
-,,x Dependent,-1.000,.000,-24.841,
-,,y Dependent,-1.000,.000,-24.841,
+Ordinal by Ordinal,Somers' d,Symmetric,-1.000,,-24.841,.000
+,,x Dependent,-1.000,.000,-24.841,.000
+,,y Dependent,-1.000,.000,-24.841,.000
 
 Table: Summary.
 ,Cases,,,,,
@@ -1317,9 +1499,9 @@ N of Valid Cases,,150.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,
-,,x Dependent,.944,.013,24.841,
-,,y Dependent,1.000,.000,24.841,
+Ordinal by Ordinal,Somers' d,Symmetric,.971,,24.841,.000
+,,x Dependent,.944,.013,24.841,.000
+,,y Dependent,1.000,.000,24.841,.000
 
 Table: Summary.
 ,Cases,,,,,
@@ -1335,9 +1517,9 @@ N of Valid Cases,,150.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,
-,,x Dependent,.805,.032,1.009,
-,,y Dependent,.018,.017,1.009,
+Ordinal by Ordinal,Somers' d,Symmetric,.035,,1.009,.313
+,,x Dependent,.805,.032,1.009,.313
+,,y Dependent,.018,.017,1.009,.313
 
 Table: Summary.
 ,Cases,,,,,
@@ -1353,9 +1535,9 @@ N of Valid Cases,,148.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,
-,,x Dependent,-.182,.069,-2.641,
-,,y Dependent,-.237,.089,-2.641,
+Ordinal by Ordinal,Somers' d,Symmetric,-.206,,-2.641,.008
+,,x Dependent,-.182,.069,-2.641,.008
+,,y Dependent,-.237,.089,-2.641,.008
 
 Table: Summary.
 ,Cases,,,,,
@@ -1372,14 +1554,14 @@ N of Valid Cases,,148.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,
-,,x Dependent,.640,,4.875,
-,,y Dependent,.174,,3.248,
-,Goodman and Kruskal tau,x Dependent,.534,,,
-,,y Dependent,.167,,,
-Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,
-,,x Dependent,-.060,.059,-1.022,
-,,y Dependent,-.096,.094,-1.022,
+Nominal by Nominal,Lambda,Symmetric,.338,.059,4.743,.000
+,,x Dependent,.640,.085,4.875,.000
+,,y Dependent,.174,.050,3.248,.001
+,Goodman and Kruskal tau,x Dependent,.534,,,.   @&t@
+,,y Dependent,.167,,,.   @&t@
+Ordinal by Ordinal,Somers' d,Symmetric,-.074,,-1.022,.307
+,,x Dependent,-.060,.059,-1.022,.307
+,,y Dependent,-.096,.094,-1.022,.307
 
 Table: Summary.
 ,Cases,,,,,
@@ -1396,13 +1578,192 @@ N of Valid Cases,,212.000,,,
 
 Table: Directional measures.
 Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
-Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,
-,,x Dependent,.027,,.302,
-,,y Dependent,.165,,2.349,
-,Goodman and Kruskal tau,x Dependent,.051,,,
-,,y Dependent,.068,,,
-Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,
-,,x Dependent,.202,.060,3.338,
-,,y Dependent,.217,.064,3.338,
+Nominal by Nominal,Lambda,Symmetric,.102,.067,1.473,.141
+,,x Dependent,.027,.087,.302,.763
+,,y Dependent,.165,.065,2.349,.019
+,Goodman and Kruskal tau,x Dependent,.051,,,.   @&t@
+,,y Dependent,.068,,,.   @&t@
+Ordinal by Ordinal,Somers' d,Symmetric,.209,,3.338,.001
+,,x Dependent,.202,.060,3.338,.001
+,,y Dependent,.217,.064,3.338,.001
+])
+AT_CLEANUP
+
+AT_SETUP([CROSSTABS Cohens Kappa])
+
+dnl Example from Wood J. M. 
+dnl "Understanding and Computing Cohen's Kappa: A Tutorial"
+dnl WebPsychEmpiricist. Oct 3 2007
+AT_DATA([kappa.sps], [dnl
+SET FORMAT=F8.3.
+
+data list notable list /p1 * p2 * w *.
+begin data.
+0 0 18
+1 0 1
+0 1 1
+end data.
+
+weight by w.
+
+crosstabs /table = p1 by p2
+       statistics = kappa
+       .
+])
+
+AT_CHECK([pspp -O format=csv kappa.sps], [0], [dnl
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+p1 * p2,20.000,100.0%,.000,0.0%,20.000,100.0%
+
+Table: p1 * p2 [[count]].
+,p2,,
+p1,.000,1.000,Total
+.000,18.000,1.000,19.000
+1.000,1.000,.000,1.000
+Total,19.000,1.000,20.000
+
+Table: Symmetric measures.
+Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
+Measure of Agreement,Kappa,-.053,.037,-.235,
+N of Valid Cases,,20.000,,,
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([CROSSTABS many statistics])
+AT_DATA([crosstabs.sps], [dnl
+SET FORMAT=F8.4.
+
+* From http://www4.stat.ncsu.edu/~dzhang2/st744/table3.9.lst.txt.
+DATA LIST LIST NOTABLE/x y w.
+WEIGHT BY w.
+BEGIN DATA.
+1 1 25
+1 2 25
+1 3 12
+2 2 1
+2 3 3
+END DATA.
+CROSSTABS x BY y/STATISTICS=CHISQ PHI CC LAMBDA UC BTAU CTAU GAMMA D CORR/CELLS=NONE.
+])
+AT_CHECK([pspp -O format=csv crosstabs.sps], [0], [dnl
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,66.0000,100.0%,.0000,0.0%,66.0000,100.0%
+
+Table: Chi-square tests.
+Statistic,Value,df,Asymp. Sig. (2-tailed)
+Pearson Chi-Square,6.9562,2.0000,.031
+Likelihood Ratio,6.6901,2.0000,.035
+Linear-by-Linear Association,5.8450,1.0000,.016
+N of Valid Cases,66.0000,,
+
+Table: Symmetric measures.
+Category,Statistic,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
+Nominal by Nominal,Phi,.3246,,,
+,Cramer's V,.3246,,,
+,Contingency Coefficient,.3088,,,
+Ordinal by Ordinal,Kendall's tau-b,.2752,.0856,1.9920,
+,Kendall's tau-c,.1497,.0751,1.9920,
+,Gamma,.8717,.1250,1.9920,
+,Spearman Correlation,.2908,.0906,2.4311,
+Interval by Interval,Pearson's R,.2999,.0973,2.5147,
+N of Valid Cases,,66.0000,,,
+
+Table: Directional measures.
+Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
+Nominal by Nominal,Lambda,Symmetric,.0455,.1629,.2723,.785
+,,x Dependent,.0000,.0000,NaN,NaN
+,,y Dependent,.0500,.1791,.2723,.785
+,Goodman and Kruskal tau,x Dependent,.1054,,,.   @&t@
+,,y Dependent,.0434,,,.   @&t@
+,Uncertainty Coefficient,Symmetric,.0780,.0474,,.   @&t@
+,,x Dependent,.2217,.1062,1.5373,.   @&t@
+,,y Dependent,.0473,.0306,1.5373,.   @&t@
+Ordinal by Ordinal,Somers' d,Symmetric,.1960,,1.9920,.046
+,,x Dependent,.1152,.0572,1.9920,.046
+,,y Dependent,.6573,.1417,1.9920,.046
 ])
 AT_CLEANUP
+
+AT_SETUP([CROSSTABS uncertainy coefficient])
+AT_DATA([uc.sps], [dnl
+* From http://groups.chass.utoronto.ca/pol242/5bMeasuringAssociation.htm.
+SET FORMAT=F8.3.
+
+DATA LIST LIST NOTABLE/x y w.
+WEIGHT BY w.
+BEGIN DATA.
+1 1 416
+1 2 121
+2 1 335
+2 2 2
+3 1 112
+3 2 1
+END DATA.
+CROSSTABS x BY y/STATISTICS=LAMBDA UC/CELLS=NONE.
+])
+AT_CHECK([pspp -O format=csv uc.sps], [0], [dnl
+Table: Summary.
+,Cases,,,,,
+,Valid,,Missing,,Total,
+,N,Percent,N,Percent,N,Percent
+x * y,987.000,100.0%,.000,0.0%,987.000,100.0%
+
+Table: Directional measures.
+Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig.
+Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN
+,,x Dependent,.000,.000,NaN,NaN
+,,y Dependent,.000,.000,NaN,NaN
+,Goodman and Kruskal tau,x Dependent,.076,,,.   @&t@
+,,y Dependent,.108,,,.   @&t@
+,Uncertainty Coefficient,Symmetric,.105,.012,,.   @&t@
+,,x Dependent,.073,.009,7.890,.   @&t@
+,,y Dependent,.184,.019,7.890,.   @&t@
+])
+AT_CLEANUP
+
+
+
+AT_SETUP([CROSSTABS barchart])
+AT_DATA([bc.sps], [dnl
+SET FORMAT=F8.3.
+
+DATA LIST LIST NOTABLE /x (a20) y (f8) z (f8) w (f8) .
+BEGIN DATA.
+This  1  0 416
+That  2  0 121
+Other 2  0 335
+This  2  0 231
+That  3  0 112
+Other 4  0 130
+This  1  1 160
+That  2  1 211
+Other 2  1 352
+This  2  1 212
+That  3  1 121
+Other 4  1 101
+END DATA.
+
+WEIGHT BY w.
+
+CROSSTABS 
+         /table x BY y BY z
+         /table x BY y
+         /barchart.
+])
+
+AT_CHECK([pspp -O format=txt -o xxx bc.sps], [0], [ignore])
+
+AT_CHECK([test -e xxx-1.png], [0], [ignore])
+AT_CHECK([test -e xxx-2.png], [0], [ignore])
+
+AT_CHECK([diff xxx-1.png xxx-2.png], [0], [ignore])
+
+AT_CLEANUP