X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Fcrosstabs.at;h=6c34c68a436ad7fd6367da29354be1b0ba5ed024;hb=f790dbda9d498eef9c9c0a49078adbeecf768d56;hp=1191215333c6997361a7f68ccd349b928756f5f1;hpb=7832ea508cb422d55aa8a871c003d691d33b4767;p=pspp diff --git a/tests/language/stats/crosstabs.at b/tests/language/stats/crosstabs.at index 1191215333..6c34c68a43 100644 --- a/tests/language/stats/crosstabs.at +++ b/tests/language/stats/crosstabs.at @@ -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 . +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], @@ -405,7 +447,112 @@ z,Category,Statistic,Type,Value,Asymp. Std. Error,Approx. T,Approx. Sig. ]]) 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], @@ -1066,6 +1213,41 @@ Nominal by Nominal,Lambda,Symmetric,.208,.010,18.793,.000 ]) 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 + AT_SETUP([CROSSTABS Somers' D, Tau-B, Tau-C, Gamma]) AT_DATA([somersd.sps], [dnl SET FORMAT F8.3. @@ -1407,6 +1589,51 @@ Ordinal by Ordinal,Somers' d,Symmetric,.209,,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. @@ -1501,3 +1728,42 @@ Nominal by Nominal,Lambda,Symmetric,.000,.000,NaN,NaN ,,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