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/>.
17 AT_BANNER([CORRELATIONS])
19 AT_SETUP([CORRELATIONS -- unweighted])
20 AT_DATA([correlations.sps], [dnl
22 data list notable list /foo * bar * wiz * bang *.
35 variables = foo bar wiz bang
47 variables = foo bar wiz bang
52 AT_CHECK([pspp -o pspp.csv correlations.sps])
53 AT_CHECK([cat pspp.csv], [0], [dnl
56 foo,Pearson Correlation,1.000,.802,.890,-.308
57 ,Sig. (2-tailed),,.055,.017,.553
58 bar,Pearson Correlation,.802,1.000,.519,.118
59 ,Sig. (2-tailed),.055,,.291,.824
60 wiz,Pearson Correlation,.890,.519,1.000,-.344
61 ,Sig. (2-tailed),.017,.291,,.505
62 bang,Pearson Correlation,-.308,.118,-.344,1.000
63 ,Sig. (2-tailed),.553,.824,.505,
67 bar,Pearson Correlation,1.000,.497
68 ,Sig. (2-tailed),,.210
69 wiz,Pearson Correlation,.497,1.000
70 ,Sig. (2-tailed),.210,
74 foo,Pearson Correlation,1.000,.805,.883,-.308
75 ,Sig. (2-tailed),,.029,.008,.553
77 bar,Pearson Correlation,.805,1.000,.497,.164
78 ,Sig. (2-tailed),.029,,.210,.725
80 wiz,Pearson Correlation,.883,.497,1.000,-.337
81 ,Sig. (2-tailed),.008,.210,,.460
83 bang,Pearson Correlation,-.308,.164,-.337,1.000
84 ,Sig. (2-tailed),.553,.725,.460,
89 AT_SETUP([CORRELATIONS -- weighted])
90 AT_DATA([correlations1.sps], [dnl
92 data list notable list /foo * bar * wiz * bang * w *.
105 variables = foo bar wiz bang
106 /statistics=descriptives xprod
109 AT_DATA([correlations2.sps], [dnl
111 data list notable list /foo * bar * wiz * bang * w *.
127 variables = foo bar wiz bang
128 /statistics=descriptives xprod
131 AT_CHECK([pspp -O format=csv correlations1.sps], [0], [stdout])
133 AT_CHECK([pspp -O format=csv correlations2.sps], [0], [expout])
137 AT_SETUP([CORRELATIONS -- non-square])
138 AT_DATA([corr-ns.sps], [dnl
140 data list notable list /foo * bar * wiz *.
151 variables = foo with bar wiz
155 AT_CHECK([pspp -O format=csv corr-ns.sps], [0], [dnl
158 foo,Pearson Correlation,1.000,-1.000
159 ,Sig. (2-tailed),.000,.000
165 dnl Checks for bug #38661.
166 AT_SETUP([CORRELATIONS -- crash with WITH keyword])
167 AT_DATA([correlations.sps], [dnl
168 DATA LIST LIST NOTABLE /a b c d e f g h i.
171 20 21 17 28 23 4.35 24 19 25
172 28 18 29 30 23 4.55 17 23 28
173 47 18 30 30 29 4.35 26 31 31
174 20 7 19 22 22 4.80 24 16 27
175 19 12 17 27 22 . 22 14 25
176 22 9 19 30 33 5 29 30 27
177 41 16 22 32 23 3.90 26 27 23
178 18 18 20 26 22 5.80 17 20 39
179 18 24 25 25 31 5.15 27 27 34
180 19 22 26 23 37 6 41 32 27
181 23 12 15 29 25 4.10 21 27 20
182 21 4 28 37 31 5.65 27 18 42
183 19 5 17 17 29 3.10 19 16 19
184 21 17 20 35 31 . 28 30 22
187 CORRELATIONS VARIABLE=a f b WITH c g h i e d/STATISTICS=DESCRIPTIVES.
189 AT_CHECK([pspp -o pspp.csv correlations.sps])
190 # Check the output, ignoring the actual correlations values since
191 # they look pretty nonsensical to me for this input (they include NaNs).
192 AT_CHECK([sed '/a,Pearson/,$s/,\([[^,]]*\),.*/,\1,.../' pspp.csv], [0], [dnl
193 Table: Descriptive Statistics
194 ,Mean,Std. Deviation,N
207 a,Pearson Correlation,...
210 f,Pearson Correlation,...
213 b,Pearson Correlation,...
221 dnl Checks for bug #40661
222 AT_SETUP([CORRELATIONS -- incorrect subtable selection])
223 AT_DATA([correlations.sps], [dnl
226 data list notable list /var1 var2 var3 var4 var5 *.
331 /VARIABLES = var1 var2 var3 WITH var4 var5
332 /PRINT = TWOTAIL NOSIG.
335 /VARIABLES = var3 var4 var5 WITH var1 var2
336 /PRINT = TWOTAIL NOSIG.
340 AT_CHECK([pspp -O format=csv correlations.sps], [0],
343 var1,Pearson Correlation,.5693,-.0519
344 ,Sig. (2-tailed),.000,.623
346 var2,Pearson Correlation,.3792,-.0407
347 ,Sig. (2-tailed),.000,.698
349 var3,Pearson Correlation,.3699,-.0543
350 ,Sig. (2-tailed),.000,.603
355 var3,Pearson Correlation,.6964,.5615
356 ,Sig. (2-tailed),.000,.000
358 var4,Pearson Correlation,.5693,.3792
359 ,Sig. (2-tailed),.000,.000
361 var5,Pearson Correlation,-.0519,-.0407
362 ,Sig. (2-tailed),.623,.698
369 dnl Crash found by zzuf
370 AT_SETUP([CORRELATIONS -- empty dataset])
372 AT_DATA([correlations.sps], [dnl
373 data list list /a b c q g *.
374 CORRELATIONS 'VARIABLES = a b.]
377 AT_CHECK([pspp -o pspp.csv correlations.sps], [1], [ignore])
381 dnl Another Crash found by zzuf
382 AT_SETUP([CORRELATIONS -- empty dataset 2])
384 AT_DATA([correlations.sps], [dnl
385 data list notable list /foo * bar * wiz bang *.
395 variables = foo bar wiz bang
400 AT_CHECK([pspp -O format=csv correlations.sps], [1], [dnl
401 correlations.sps:13: error: CORRELATIONS: The data for the chosen variables are all missing or empty.