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,
66 a,Significant at .05 level
70 bar,Pearson Correlation,1.000,.497
71 ,Sig. (2-tailed),,.210
72 wiz,Pearson Correlation,.497,1.000
73 ,Sig. (2-tailed),.210,
77 foo,Pearson Correlation,1.000,.805[a],.883[a],-.308
78 ,Sig. (2-tailed),,.029,.008,.553
80 bar,Pearson Correlation,.805[a],1.000,.497,.164
81 ,Sig. (2-tailed),.029,,.210,.725
83 wiz,Pearson Correlation,.883[a],.497,1.000,-.337
84 ,Sig. (2-tailed),.008,.210,,.460
86 bang,Pearson Correlation,-.308,.164,-.337,1.000
87 ,Sig. (2-tailed),.553,.725,.460,
91 a,Significant at .05 level
95 AT_SETUP([CORRELATIONS -- weighted])
96 AT_DATA([correlations1.sps], [dnl
98 data list notable list /foo * bar * wiz * bang * w *.
111 variables = foo bar wiz bang
112 /statistics=descriptives xprod
115 AT_DATA([correlations2.sps], [dnl
117 data list notable list /foo * bar * wiz * bang * w *.
133 variables = foo bar wiz bang
134 /statistics=descriptives xprod
137 AT_CHECK([pspp -O format=csv correlations1.sps], [0], [stdout])
139 AT_CHECK([pspp -O format=csv correlations2.sps], [0], [expout])
143 AT_SETUP([CORRELATIONS -- non-square])
144 AT_DATA([corr-ns.sps], [dnl
146 data list notable list /foo * bar * wiz *.
157 variables = foo with bar wiz
161 AT_CHECK([pspp -O format=csv corr-ns.sps], [0], [dnl
164 foo,Pearson Correlation,1.000,-1.000
165 ,Sig. (2-tailed),.000,.000
171 dnl Checks for bug #38661.
172 AT_SETUP([CORRELATIONS -- crash with WITH keyword])
173 AT_DATA([correlations.sps], [dnl
174 DATA LIST LIST NOTABLE /a b c d e f g h i.
177 20 21 17 28 23 4.35 24 19 25
178 28 18 29 30 23 4.55 17 23 28
179 47 18 30 30 29 4.35 26 31 31
180 20 7 19 22 22 4.80 24 16 27
181 19 12 17 27 22 . 22 14 25
182 22 9 19 30 33 5 29 30 27
183 41 16 22 32 23 3.90 26 27 23
184 18 18 20 26 22 5.80 17 20 39
185 18 24 25 25 31 5.15 27 27 34
186 19 22 26 23 37 6 41 32 27
187 23 12 15 29 25 4.10 21 27 20
188 21 4 28 37 31 5.65 27 18 42
189 19 5 17 17 29 3.10 19 16 19
190 21 17 20 35 31 . 28 30 22
193 CORRELATIONS VARIABLE=a f b WITH c g h i e d/STATISTICS=DESCRIPTIVES.
195 AT_CHECK([pspp -o pspp.csv correlations.sps])
196 # Check the output, ignoring the actual correlations values since
197 # they look pretty nonsensical to me for this input (they include NaNs).
198 AT_CHECK([sed '/a,Pearson/,$s/,\([[^,]]*\),.*/,\1,.../' pspp.csv], [0], [dnl
199 Table: Descriptive Statistics
200 ,Mean,Std. Deviation,N
213 a,Pearson Correlation,...
216 f,Pearson Correlation,...
219 b,Pearson Correlation,...
227 dnl Checks for bug #40661
228 AT_SETUP([CORRELATIONS -- incorrect subtable selection])
229 AT_DATA([correlations.sps], [dnl
231 OUTPUT MODIFY /SELECT TABLES /TABLECELLS SELECT = [[CORRELATIONS]] FORMAT=F12.4.
233 data list notable list /var1 var2 var3 var4 var5 *.
338 /VARIABLES = var1 var2 var3 WITH var4 var5
339 /PRINT = TWOTAIL NOSIG.
342 /VARIABLES = var3 var4 var5 WITH var1 var2
343 /PRINT = TWOTAIL NOSIG.
347 AT_CHECK([pspp -o pspp.csv -o pspp.txt correlations.sps])
348 AT_CHECK([cat pspp.csv], [0],
349 [[Table: Correlations
351 var1,Pearson Correlation,.5693[a],-.0519
352 ,Sig. (2-tailed),.000,.623
354 var2,Pearson Correlation,.3792[a],-.0407
355 ,Sig. (2-tailed),.000,.698
357 var3,Pearson Correlation,.3699[a],-.0543
358 ,Sig. (2-tailed),.000,.603
362 a,Significant at .05 level
366 var3,Pearson Correlation,.6964[a],.5615[a]
367 ,Sig. (2-tailed),.000,.000
369 var4,Pearson Correlation,.5693[a],.3792[a]
370 ,Sig. (2-tailed),.000,.000
372 var5,Pearson Correlation,-.0519,-.0407
373 ,Sig. (2-tailed),.623,.698
377 a,Significant at .05 level
383 dnl Crash found by zzuf
384 AT_SETUP([CORRELATIONS -- empty dataset])
386 AT_DATA([correlations.sps], [dnl
387 data list list /a b c q g *.
388 CORRELATIONS 'VARIABLES = a b.]
391 AT_CHECK([pspp -o pspp.csv correlations.sps], [1], [ignore])
395 dnl Another Crash found by zzuf
396 AT_SETUP([CORRELATIONS -- empty dataset 2])
398 AT_DATA([correlations.sps], [dnl
399 data list notable list /foo * bar * wiz bang *.
409 variables = foo bar wiz bang
414 AT_CHECK([pspp -O format=csv correlations.sps], [1], [dnl
415 correlations.sps:13: error: CORRELATIONS: The data for the chosen variables are all missing or empty.