Added result_class parameter to tab_double and updated all callers. Removed tab_fixed
[pspp] / tests / language / stats / npar.at
index cc1bd167c5cc81f8a09ef318c5d4f7a483ecc763..328c0e6041fefb302e4604b7892642a3d4649092 100644 (file)
@@ -274,6 +274,28 @@ x,Group1,10.000,10.000,.435,.500,.678
 ])
 AT_CLEANUP
 
+
+
+dnl Test for a bug which caused binomial to crash.
+AT_SETUP([NPAR TESTS BINOMIAL - crash])
+AT_DATA([nparX.sps], [dnl
+data list list /range *.
+begin data.
+0
+1
+end data.
+
+* This is invalid syntax
+NPAR TEST
+       /BINOMIAL(0.5) = Range().
+
+])
+AT_CHECK([pspp -O format=csv nparX.sps], [1], [ignore])
+
+AT_CLEANUP
+
+
+
 AT_SETUP([NPAR TESTS CHISQUARE])
 AT_DATA([npar.sps], [dnl
 DATA LIST NOTABLE LIST /x * y * w *.
@@ -303,6 +325,7 @@ NPAR TESTS
   /EXPECTED = 6 10 3
   .
 ])
+
 AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
 Table: x
 ,Observed N,Expected N,Residual
@@ -326,7 +349,7 @@ Table: Test Statistics
 ,x,y
 Chi-Square,3.14,6.00
 df,5,3
-Asymp. Sig.,.68,.11
+Asymp. Sig.,.678,.112
 
 Table: y
 ,Observed N,Expected N,Residual
@@ -340,7 +363,7 @@ Table: Test Statistics
 ,y
 Chi-Square,10.61
 df,3
-Asymp. Sig.,.01
+Asymp. Sig.,.014
 
 Table: Frequencies
 ,x,,,,y,,,
@@ -354,8 +377,9 @@ Table: Test Statistics
 ,x,y
 Chi-Square,.13,4.13
 df,2,2
-Asymp. Sig.,.94,.13
+Asymp. Sig.,.936,.127
 ])
+
 AT_CLEANUP
 
 AT_SETUP([NPAR TESTS CHISQUARE expected values missing])
@@ -378,6 +402,7 @@ NPAR TESTS
   /EXPECTED = 3 4 5 4 3 1
   .
 ])
+
 AT_CHECK([pspp -O format=csv npar.sps], [1], [dnl
 "error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y."
 
@@ -385,8 +410,9 @@ Table: Test Statistics
 ,y
 Chi-Square,.00
 df,0
-Asymp. Sig.,1.00
+Asymp. Sig.,1.000
 ])
+
 AT_CLEANUP
 
 AT_SETUP([NPAR TESTS CHISQUARE with DESCRIPTIVES])
@@ -413,6 +439,7 @@ NPAR TESTS
   /STATISTICS=DESCRIPTIVES
   .
 ])
+
 AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
 Table: Frequencies
 ,x,,,,y,,,
@@ -431,7 +458,7 @@ Table: Test Statistics
 ,x,y
 Chi-Square,17.33,22.87
 df,7,7
-Asymp. Sig.,.02,.00
+Asymp. Sig.,.015,.002
 
 Table: Descriptive Statistics
 ,N,Mean,Std. Deviation,Minimum,Maximum
@@ -465,6 +492,7 @@ NPAR TESTS
   /STATISTICS=DESCRIPTIVES
   .
 ])
+
 AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
 Table: Frequencies
 ,x,,,,y,,,
@@ -483,7 +511,7 @@ Table: Test Statistics
 ,x,y
 Chi-Square,13.43,26.00
 df,7,7
-Asymp. Sig.,.06,.00
+Asymp. Sig.,.062,.001
 
 Table: Descriptive Statistics
 ,N,Mean,Std. Deviation,Minimum,Maximum
@@ -522,8 +550,8 @@ npar test
  /missing analysis
  /method=exact.
 ])
-AT_CHECK([pspp -o pspp.csv npar.sps])
-AT_CHECK([cat pspp.csv], [0], [dnl
+
+AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
 Table: Ranks
 ,,N,Mean Rank,Sum of Ranks
 first - second,Negative Ranks,8,6.00,48.00
@@ -534,10 +562,11 @@ first - second,Negative Ranks,8,6.00,48.00
 Table: Test Statistics
 ,first - second
 Z,-.18
-Asymp. Sig. (2-tailed),.86
-Exact Sig. (2-tailed),.89
-Exact Sig. (1-tailed),.45
+Asymp. Sig. (2-tailed),.861
+Exact Sig. (2-tailed),.893
+Exact Sig. (1-tailed),.446
 ])
+
 AT_CLEANUP
 
 AT_SETUP([NPAR TESTS WILCOXON with missing values])
@@ -568,11 +597,10 @@ npar test
  /wilcoxon=foo with bar (paired)
  /missing analysis
  /method=exact.
-
 ])
-AT_CHECK([pspp -o pspp.csv npar.sps])
+
 dnl This is the same output as the previous test.
-AT_CHECK([cat pspp.csv], [0], [dnl
+AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
 Table: Ranks
 ,,N,Mean Rank,Sum of Ranks
 first - second,Negative Ranks,8,6.00,48.00
@@ -583,9 +611,9 @@ first - second,Negative Ranks,8,6.00,48.00
 Table: Test Statistics
 ,first - second
 Z,-.18
-Asymp. Sig. (2-tailed),.86
-Exact Sig. (2-tailed),.89
-Exact Sig. (1-tailed),.45
+Asymp. Sig. (2-tailed),.861
+Exact Sig. (2-tailed),.893
+Exact Sig. (1-tailed),.446
 ])
 AT_CLEANUP
 
@@ -610,9 +638,9 @@ npar tests
        .
 ])
 AT_CHECK([pspp -o pspp.csv npar.sps])
-dnl Some machines return .313 instead of .312 for the Point Probability
+dnl Some machines return .313 instead of .312 
 dnl (see bug #31611).
-AT_CHECK([sed 's/\.313$/.312/' pspp.csv], [0], [dnl
+AT_CHECK([sed -e 's/\.313$/.312/' -e 's/^Exact Sig\. (1-tailed),\.313/Exact Sig. (1-tailed),.312/' pspp.csv], [0], [dnl
 Table: Frequencies
 ,,N
 age - height,Negative Differences,3
@@ -672,8 +700,8 @@ AT_CHECK([cat pspp.csv], [0], [dnl
 Table: Ranks
 ,gv,N,Mean Rank
 xscore,timed out,5,4.400
-,handled the ball,4,11.500
 ,hit wicket,5,7.400
+,handled the ball,4,11.500
 ,Total,14,
 
 Table: Test Statistics
@@ -776,12 +804,12 @@ AT_CHECK([cat pspp.csv], [0], [dnl
 Table: Ranks
 ,gv,N,Mean Rank
 xscore,timed out,5,4.400
-,handled the ball,4,11.500
 ,hit wicket,5,7.400
+,handled the ball,4,11.500
 ,Total,14,
-yscore,handled the ball,4,11.500
+yscore,hit wicket,5,7.400
+,handled the ball,4,11.500
 ,bowled,5,4.400
-,hit wicket,5,7.400
 ,Total,14,
 
 Table: Test Statistics
@@ -847,10 +875,8 @@ npar tests
        .
 ])
 
-AT_CHECK([pspp -o pspp.csv npar-runs.sps])
-
-AT_CHECK([cat pspp.csv], [0], [dnl
-Table: Runs Test
+AT_CHECK([pspp -O format=csv npar-runs.sps], [0],
+[Table: Runs Test
 ,score
 Test Value (median),3.0000
 Cases < Test Value,177.0000
@@ -858,7 +884,7 @@ Cases ≥ Test Value,309.0000
 Total Cases,486.0000
 Number of Runs,12
 Z,-20.9931
-Asymp. Sig. (2-tailed),.0000
+Asymp. Sig. (2-tailed),.000
 
 Table: Runs Test
 ,score
@@ -868,7 +894,7 @@ Cases ≥ Test Value,227.0000
 Total Cases,486.0000
 Number of Runs,12
 Z,-21.0650
-Asymp. Sig. (2-tailed),.0000
+Asymp. Sig. (2-tailed),.000
 
 Table: Runs Test
 ,score
@@ -878,7 +904,7 @@ Cases ≥ Test Value,170.0000
 Total Cases,486.0000
 Number of Runs,11
 Z,-21.0742
-Asymp. Sig. (2-tailed),.0000
+Asymp. Sig. (2-tailed),.000
 ])
 
 AT_CLEANUP
@@ -905,9 +931,7 @@ npar tests
      /friedman = x y z.
 ])
 
-AT_CHECK([pspp -o pspp.csv npar-friedman.sps])
-
-AT_CHECK([cat pspp.csv], [0], [dnl
+AT_CHECK([pspp -O format=csv npar-friedman.sps], [0], [dnl
 Table: Ranks
 ,Mean Rank
 x,2.6500
@@ -918,7 +942,7 @@ Table: Test Statistics
 N,10
 Chi-Square,10.4737
 df,2
-Asymp. Sig.,.0053
+Asymp. Sig.,.005
 ])
 
 AT_CLEANUP
@@ -967,9 +991,7 @@ NPAR TESTS
      /M-W = height BY sex (0,1).
 ])
 
-AT_CHECK([pspp -o pspp.csv npar-mann-whitney.sps])
-
-AT_CHECK([cat pspp.csv], [0], [dnl
+AT_CHECK([pspp -O format=csv npar-mann-whitney.sps], [0], [dnl
 Table: Ranks
 ,N,,,Mean Rank,,Sum of Ranks,
 ,0,1,Total,0,1,0,1
@@ -977,7 +999,7 @@ height,15.0000,15.0000,30.0000,14.5333,16.4667,218.0000,247.0000
 
 Table: Test Statistics
 ,Mann-Whitney U,Wilcoxon W,Z,Asymp. Sig. (2-tailed)
-height,98.0000,218.0000,-.6020,.5472
+height,98.0000,218.0000,-.6020,.547
 ])
 
 
@@ -1389,3 +1411,306 @@ Asymp. Sig. (2-tailed),,.569,.552
 
 
 AT_CLEANUP
+
+
+AT_SETUP([NPAR TESTS Median Test (median imputed)])
+
+AT_DATA([median1.sps], [dnl
+set format F12.3.
+data list notable list /ignore * animal * years * w *.
+begin data
+99  1   10  1
+99  4    1  1
+99  5   11  1
+99  5   10  1
+99  3    7  1
+99  6   10  1
+99  0    7  1
+99  3   14  1
+99  2    3  1
+99  1    1  1
+99  4    7  1
+99  5   12  1
+99  3    6  1
+99  4    1  1
+99  3    5  1
+99  5    7  1
+99  4    6  1
+99  3   14  1
+99  4    8  1
+99  5   13  1
+99  2    0  1
+99  4    7  1
+99  4    7  1
+99  1    0  1
+99  2    8  1
+99  4   10  1
+99  2    3  1
+99  2    0  1
+99  4    8  1
+99  1    8  1
+end data.
+
+
+variable label years 'Years expected'.
+variable label animal 'Animal Genus'.
+
+add value labels animal 1 'Animal 1' 2 'Animal 2' 3 'Animal 3' 4 'Animal 4' 5 'Animal 5'.
+
+npar tests
+     /median = years by animal (1, 5)
+     .
+])
+
+
+AT_CHECK([pspp -O format=csv median1.sps], [0], [dnl
+Table: Frequencies
+,,Animal Genus,,,,
+,,Animal 1,Animal 2,Animal 3,Animal 4,Animal 5
+Years expected,> Median,2,1,2,3,4
+,≤ Median,2,4,3,6,1
+
+Table: Test Statistics
+,N,Median,Chi-Square,df,Asymp. Sig.
+Years expected,28,7.000,4.317,4,.365
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([NPAR TESTS Median Test (median given)])
+
+AT_DATA([median2.sps], [dnl
+set format F12.3.
+data list notable list /ignore * animal * years * w *.
+begin data
+99  1   10  1
+99  4    1  1
+99  5   11  1
+99  5   10  1
+99  3    7  1
+99  3   14  1
+99  2    3  1
+99  1    1  1
+99  4    7  1
+99  5   12  1
+99  3    6  1
+99  4    1  1
+99  3    5  1
+99  5    7  1
+99  4    6  1
+99  3   14  1
+99  4    8  1
+99  5   13  1
+99  2    0  1
+99  4    7  1
+99  4    7  1
+99  1    0  1
+99  2    8  1
+99  4   10  1
+99  2    3  1
+99  2    0  1
+99  4    8  1
+99  1    8  1
+end data.
+
+
+variable label years 'Years expected'.
+variable label animal 'Animal Genus'.
+
+add value labels animal 1 'Animal 1' 2 'Animal 2' 3 'Animal 3' 4 'Animal 4' 5 'Animal 5'.
+
+npar tests
+     /median (7) = years by animal (1, 5)
+     .
+])
+
+
+AT_CHECK([pspp -O format=csv median2.sps], [0], [dnl
+Table: Frequencies
+,,Animal Genus,,,,
+,,Animal 1,Animal 2,Animal 3,Animal 4,Animal 5
+Years expected,> Median,2,1,2,3,4
+,≤ Median,2,4,3,6,1
+
+Table: Test Statistics
+,N,Median,Chi-Square,df,Asymp. Sig.
+Years expected,28,7.000,4.317,4,.365
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([NPAR TESTS Median Test (two sample)])
+
+AT_DATA([median3.sps], [dnl
+set format F12.3.
+data list notable list /xx * animal * years * w *.
+begin data
+99  1   10  1
+99  4    1  1
+99  5   11  1
+99  5   10  1
+99  3    7  1
+99  3   14  1
+99  2    3  1
+99  1    1  1
+99  4    7  1
+99  5   12  1
+99  3    6  1
+99  4    1  1
+99  3    5  1
+99  5    7  1
+99  4    6  1
+99  3   14  1
+99  4    8  1
+99  5   13  1
+99  2    0  1
+99  4    7  1
+99  4    7  1
+99  1    0  1
+99  2    8  1
+99  4   10  1
+99  2    3  1
+99  2    0  1
+99  4    8  1
+99  1    8  1
+end data.
+
+
+variable label years 'Years expected'.
+variable label animal 'Animal Genus'.
+
+add value labels animal 1 'Animal 1' 2 'Animal 2' 3 'Animal 3' 4 'Animal 4' 5 'Animal 5'.
+
+npar tests
+     /median (7) = xx years by animal (5, 1)
+     .
+])
+
+
+AT_CHECK([pspp -O format=csv median3.sps], [0], [dnl
+Table: Frequencies
+,,Animal Genus,
+,,Animal 1,Animal 5
+xx,> Median,4,5
+,≤ Median,0,0
+Years expected,> Median,2,4
+,≤ Median,2,1
+
+Table: Test Statistics
+,N,Median,Chi-Square,df,Asymp. Sig.
+xx,9,7.000,NaN,1,NaN
+Years expected,9,7.000,.900,1,.343
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([NPAR TESTS Jonckheere-Terpstra])
+
+AT_DATA([jt.sps], [dnl
+set format = F12.3.
+data list notable list /x * g * w *.
+begin data.
+52  2  2
+58  2  1
+60  2  1
+62  2  1
+58  0  1
+44  2  1
+46  2  1
+14  3  1
+32  2  1
+16  3  1
+56  2  1
+26  3  1
+40  3  2
+50  4  1
+6   5  1
+34  2  3
+36  2  2
+40  2  2
+50  2  1
+end data.
+
+weight by w.
+
+npar test /jonckheere-terpstra = x by g (5, 2).
+])
+
+
+AT_CHECK([pspp -O format=csv jt.sps], [0], [dnl
+Table: Jonckheere-Terpstra Test
+,Number of levels in g,N,Observed J-T Statistic,Mean J-T Statistic,Std. Deviation of J-T Statistic,Std. J-T Statistic,Asymp. Sig. (2-tailed)
+x,4,24.000,29.500,65.000,15.902,-2.232,.026
+])
+
+AT_CLEANUP
+
+dnl Checks that (PAIRED) can have lists where the same 
+dnl variable appears more than once.
+AT_SETUP([NPAR TESTS (PAIRED)])
+AT_DATA([npar.sps], [dnl
+set format = F12.3.
+data list notable list /a * b * c *.
+begin data.
+1 2 4
+4 5 3
+1 2 2
+4 5 1
+end data.
+
+npar tests /wilcoxon a b with c c (paired).
+])
+
+AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl
+Table: Ranks
+,,N,Mean Rank,Sum of Ranks
+a - c,Negative Ranks,2,2.500,5.000
+,Positive Ranks,2,2.500,5.000
+,Ties,0,,
+,Total,4,,
+b - c,Negative Ranks,1,1.500,1.500
+,Positive Ranks,2,2.250,4.500
+,Ties,1,,
+,Total,4,,
+
+Table: Test Statistics
+,a - c,b - c
+Z,.000,-.816
+Asymp. Sig. (2-tailed),1.000,.414
+])
+
+
+AT_CLEANUP
+
+
+
+AT_SETUP([NPAR TESTS CHISQUARE crash])
+dnl This syntax had been observed to crash pspp
+
+AT_DATA([npar.sps], [dnl
+data list list /x *.
+begin data.
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+end data.
+
+* This happens to be invalid syntax.  But should not crash.
+NPAR TEST
+       /CHISQUARE= x(0.098, 99.098)
+       /EXPECTED =  1.2.
+])
+
+AT_CHECK([pspp -O format=csv npar.sps], [1], [ignore])
+
+AT_CLEANUP