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 -o pspp.txt correlations.sps])
53 AT_CHECK([cat pspp.csv], [0],
56 foo,Pearson Correlation,1.000,.802,.890[a],-.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[a],.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,
64 Footnote: a. Significant at .05 level
68 bar,Pearson Correlation,1.000,.497
69 ,Sig. (2-tailed),,.210
70 wiz,Pearson Correlation,.497,1.000
71 ,Sig. (2-tailed),.210,
75 foo,Pearson Correlation,1.000,.805[a],.883[a],-.308
76 ,Sig. (2-tailed),,.029,.008,.553
78 bar,Pearson Correlation,.805[a],1.000,.497,.164
79 ,Sig. (2-tailed),.029,,.210,.725
81 wiz,Pearson Correlation,.883[a],.497,1.000,-.337
82 ,Sig. (2-tailed),.008,.210,,.460
84 bang,Pearson Correlation,-.308,.164,-.337,1.000
85 ,Sig. (2-tailed),.553,.725,.460,
87 Footnote: a. Significant at .05 level
91 AT_SETUP([CORRELATIONS -- weighted])
92 AT_DATA([correlations1.sps], [dnl
94 data list notable list /foo * bar * wiz * bang * w *.
107 variables = foo bar wiz bang
108 /statistics=descriptives xprod
111 AT_DATA([correlations2.sps], [dnl
113 data list notable list /foo * bar * wiz * bang * w *.
129 variables = foo bar wiz bang
130 /statistics=descriptives xprod
133 AT_CHECK([pspp -O format=csv correlations1.sps], [0], [stdout])
135 AT_CHECK([pspp -O format=csv correlations2.sps], [0], [expout])
139 AT_SETUP([CORRELATIONS -- non-square])
140 AT_DATA([corr-ns.sps], [dnl
142 data list notable list /foo * bar * wiz *.
153 variables = foo with bar wiz
157 AT_CHECK([pspp -O format=csv corr-ns.sps], [0], [dnl
160 foo,Pearson Correlation,1.000,-1.000
161 ,Sig. (2-tailed),.000,.000
167 dnl Checks for bug #38661.
168 AT_SETUP([CORRELATIONS -- crash with WITH keyword])
169 AT_DATA([correlations.sps], [dnl
170 DATA LIST LIST NOTABLE /a b c d e f g h i.
173 20 21 17 28 23 4.35 24 19 25
174 28 18 29 30 23 4.55 17 23 28
175 47 18 30 30 29 4.35 26 31 31
176 20 7 19 22 22 4.80 24 16 27
177 19 12 17 27 22 . 22 14 25
178 22 9 19 30 33 5 29 30 27
179 41 16 22 32 23 3.90 26 27 23
180 18 18 20 26 22 5.80 17 20 39
181 18 24 25 25 31 5.15 27 27 34
182 19 22 26 23 37 6 41 32 27
183 23 12 15 29 25 4.10 21 27 20
184 21 4 28 37 31 5.65 27 18 42
185 19 5 17 17 29 3.10 19 16 19
186 21 17 20 35 31 . 28 30 22
189 CORRELATIONS VARIABLE=a f b WITH c g h i e d/STATISTICS=DESCRIPTIVES.
191 AT_CHECK([pspp -o pspp.csv correlations.sps])
192 # Check the output, ignoring the actual correlations values since
193 # they look pretty nonsensical to me for this input (they include NaNs).
194 AT_CHECK([sed '/a,Pearson/,$s/,\([[^,]]*\),.*/,\1,.../' pspp.csv], [0], [dnl
195 Table: Descriptive Statistics
196 ,Mean,Std. Deviation,N
209 a,Pearson Correlation,...
212 f,Pearson Correlation,...
215 b,Pearson Correlation,...
223 dnl Checks for bug #40661
224 AT_SETUP([CORRELATIONS -- incorrect subtable selection])
225 AT_DATA([correlations.sps], [dnl
227 OUTPUT MODIFY /SELECT TABLES /TABLECELLS SELECT = [[CORRELATIONS]] FORMAT=F12.4.
229 data list notable list /var1 var2 var3 var4 var5 *.
334 /VARIABLES = var1 var2 var3 WITH var4 var5
335 /PRINT = TWOTAIL NOSIG.
338 /VARIABLES = var3 var4 var5 WITH var1 var2
339 /PRINT = TWOTAIL NOSIG.
343 AT_CHECK([pspp -o pspp.csv -o pspp.txt correlations.sps])
344 AT_CHECK([cat pspp.csv], [0],
345 [[Table: Correlations
347 var1,Pearson Correlation,.5693[a],-.0519
348 ,Sig. (2-tailed),.000,.623
350 var2,Pearson Correlation,.3792[a],-.0407
351 ,Sig. (2-tailed),.000,.698
353 var3,Pearson Correlation,.3699[a],-.0543
354 ,Sig. (2-tailed),.000,.603
356 Footnote: a. Significant at .05 level
360 var3,Pearson Correlation,.6964[a],.5615[a]
361 ,Sig. (2-tailed),.000,.000
363 var4,Pearson Correlation,.5693[a],.3792[a]
364 ,Sig. (2-tailed),.000,.000
366 var5,Pearson Correlation,-.0519,-.0407
367 ,Sig. (2-tailed),.623,.698
369 Footnote: a. Significant at .05 level
375 dnl Crash found by zzuf
376 AT_SETUP([CORRELATIONS -- empty dataset])
378 AT_DATA([correlations.sps], [dnl
379 data list list /a b c q g *.
380 CORRELATIONS 'VARIABLES = a b.]
383 AT_CHECK([pspp -o pspp.csv correlations.sps], [1], [ignore])
387 dnl Another Crash found by zzuf
388 AT_SETUP([CORRELATIONS -- empty dataset 2])
390 AT_DATA([correlations.sps], [dnl
391 data list notable list /foo * bar * wiz bang *.
401 variables = foo bar wiz bang
406 AT_CHECK([pspp -O format=csv correlations.sps], [1], [dnl
407 correlations.sps:13: error: CORRELATIONS: The data for the chosen variables are all missing or empty.