5033f1fedbec94a29eb71490b318152b1cdfb076
[pspp] / tests / language / stats / correlations.at
1 AT_BANNER([CORRELATIONS])
2
3 AT_SETUP([CORRELATIONS -- unweighted])
4 AT_DATA([correlations.sps], [dnl
5 set format = F11.3.
6 data list notable list /foo * bar * wiz * bang *.
7 begin data.
8 1   0   3   1
9 3   9 -50   5
10 3   4   3 203
11 4  -9   0  -4
12 98 78 104   2
13 3  50 -49 200
14 .   4   4   4
15 5   3   0   .
16 end data.
17
18 correlations 
19         variables = foo bar wiz bang
20         /print nosig
21         /missing = listwise
22         .
23
24 correlations 
25         variables = bar wiz
26         /print nosig
27         /missing = listwise
28         .
29
30 correlations 
31         variables = foo bar wiz bang
32         /print nosig
33         /missing = pairwise
34         .
35 ])
36 AT_CHECK([pspp -o pspp.csv correlations.sps])
37 AT_CHECK([cat pspp.csv], [0], [dnl
38 Table: Correlations
39 ,,foo,bar,wiz,bang
40 foo,Pearson Correlation,1.000,.802,.890,-.308
41 ,Sig. (2-tailed),,.055,.017,.553
42 bar,Pearson Correlation,.802,1.000,.519,.118
43 ,Sig. (2-tailed),.055,,.291,.824
44 wiz,Pearson Correlation,.890,.519,1.000,-.344
45 ,Sig. (2-tailed),.017,.291,,.505
46 bang,Pearson Correlation,-.308,.118,-.344,1.000
47 ,Sig. (2-tailed),.553,.824,.505,
48
49 Table: Correlations
50 ,,bar,wiz
51 bar,Pearson Correlation,1.000,.497
52 ,Sig. (2-tailed),,.210
53 wiz,Pearson Correlation,.497,1.000
54 ,Sig. (2-tailed),.210,
55
56 Table: Correlations
57 ,,foo,bar,wiz,bang
58 foo,Pearson Correlation,1.000,.805,.883,-.308
59 ,Sig. (2-tailed),,.029,.008,.553
60 ,N,7,7,7,6
61 bar,Pearson Correlation,.805,1.000,.497,.164
62 ,Sig. (2-tailed),.029,,.210,.725
63 ,N,7,8,8,7
64 wiz,Pearson Correlation,.883,.497,1.000,-.337
65 ,Sig. (2-tailed),.008,.210,,.460
66 ,N,7,8,8,7
67 bang,Pearson Correlation,-.308,.164,-.337,1.000
68 ,Sig. (2-tailed),.553,.725,.460,
69 ,N,6,7,7,7
70 ])
71 AT_CLEANUP
72
73 AT_SETUP([CORRELATIONS -- weighted])
74 AT_DATA([correlations1.sps], [dnl
75 set format = F11.3.
76 data list notable list /foo * bar * wiz * bang * w *.
77 begin data.
78 1   0   3   1  1
79 3   9 -50   5  2
80 3   4   3 203  1
81 4  -9   0  -4  1
82 98 78 104   2  3
83 3  50 -49 200  1
84 end data.
85
86 weight by w.
87
88 correlations 
89         variables = foo bar wiz bang
90         /statistics=descriptives xprod
91         .
92 ])
93 AT_DATA([correlations2.sps], [dnl
94 set format = F11.3.
95 data list notable list /foo * bar * wiz * bang * w *.
96 begin data.
97 1   0   3   1  1
98 3   9 -50   5  1
99 3   9 -50   5  1
100 3   4   3 203  1
101 4  -9   0  -4  1
102 98 78 104   2  1
103 98 78 104   2  1
104 98 78 104   2  1
105 3  50 -49 200  1
106 end data.
107
108 weight by w.
109
110 correlations 
111         variables = foo bar wiz bang
112         /statistics=descriptives xprod
113         .
114 ])
115 AT_CHECK([pspp -O format=csv correlations1.sps], [0], [stdout])
116 mv stdout expout
117 AT_CHECK([pspp -O format=csv correlations2.sps], [0], [expout])
118 AT_CLEANUP
119
120
121 AT_SETUP([CORRELATIONS -- non-square])
122 AT_DATA([corr-ns.sps], [dnl
123 set format = F11.3.
124 data list notable list /foo * bar * wiz *.
125 begin data.
126 1 1 6
127 2 2 5 
128 3 3 4
129 4 4 3
130 5 5 2
131 6 6 1
132 end data.
133
134 correlations 
135         variables = foo with bar wiz
136         .
137 ])
138
139 AT_CHECK([pspp -O format=csv corr-ns.sps], [0], [dnl
140 Table: Correlations
141 ,,bar,wiz
142 foo,Pearson Correlation,1.000,-1.000
143 ,Sig. (2-tailed),.000,.000
144 ,N,6,6
145 ])
146
147 AT_CLEANUP
148
149 dnl Checks for bug #38661.
150 AT_SETUP([CORRELATIONS -- crash with WITH keyword])
151 AT_DATA([correlations.sps], [dnl
152 DATA LIST LIST NOTABLE /a b c d e f g h i.
153 .
154 BEGIN DATA.
155 20 21 17 28 23 4.35 24 19 25
156 28 18 29 30 23 4.55 17 23 28
157 47 18 30 30 29 4.35 26 31 31
158 20 7 19 22 22 4.80 24 16 27
159 19 12 17 27 22 . 22 14 25
160 22 9 19 30 33 5 29 30 27
161 41 16 22 32 23 3.90 26 27 23
162 18 18 20 26 22 5.80 17 20 39
163 18 24 25 25 31 5.15 27 27 34
164 19 22 26 23 37 6 41 32 27
165 23 12 15 29 25 4.10 21 27 20
166 21 4 28 37 31 5.65 27 18 42
167 19 5 17 17 29 3.10 19 16 19
168 21 17 20 35 31 . 28 30 22
169 END DATA.
170
171 CORRELATIONS VARIABLE=a f b WITH c g h i e d/STATISTICS=DESCRIPTIVES.
172 ])
173 AT_CHECK([pspp -o pspp.csv correlations.sps])
174 # Check the output, ignoring the actual correlations values since
175 # they look pretty nonsensical to me for this input (they include NaNs).
176 AT_CHECK([sed '/a,Pearson/,$s/,\([[^,]]*\),.*/,\1,.../' pspp.csv], [0], [dnl
177 Table: Descriptive Statistics
178 ,Mean,Std. Deviation,N
179 a,24.00,8.93,14.00
180 f,4.73,.85,12.00
181 b,14.50,6.41,14.00
182 c,21.71,4.98,14.00
183 g,24.86,6.09,14.00
184 h,23.57,6.30,14.00
185 i,27.79,6.73,14.00
186 e,27.21,4.95,14.00
187 d,27.93,5.23,14.00
188
189 Table: Correlations
190 ,,c,g,h,i,e,d
191 a,Pearson Correlation,...
192 ,Sig. (2-tailed),...
193 ,N,...
194 f,Pearson Correlation,...
195 ,Sig. (2-tailed),...
196 ,N,...
197 b,Pearson Correlation,...
198 ,Sig. (2-tailed),...
199 ,N,...
200 ])
201 AT_CLEANUP
202
203
204
205 dnl Checks for bug #40661
206 AT_SETUP([CORRELATIONS -- incorrect subtable selection])
207 AT_DATA([correlations.sps], [dnl
208 set format = F12.4.
209 set decimal = dot.
210 data list notable list /var1 var2 var3 var4 var5 *.
211 begin data.
212 7,6,9,2,3
213 9,12,8,5,8
214 8,9,7,8,6
215 8,8,9,10,8
216 7,6,4,5,3
217 7,9,8,2,1
218 9,8,11,,10
219 8,7,6,,5
220 6,7,6,,8
221 6,,3,,4
222 6,,7,3,3
223 5,4,2,7,8
224 9,8,6,11,10
225 5,6,2,2,4
226 8,7,6,8,7
227 10,13,8,12,10
228 7,8,7,11,2
229 8,7,7,9,6
230 10,11,11,8,1
231 5,8,6,9,9
232 8,7,5,5,6
233 5,7,2,1,8
234 9,8,8,13,6
235 5,8,5,6,4
236 ,7,5,4,5
237 ,8,4,4,3
238 ,6,4,9,5
239 8,11,9,12,3
240 9,11,8,10,6
241 10,10,7,8,1
242 6,6,3,8,9
243 10,9,7,12,2
244 6,8,,7,4
245 6,8,3,2,9
246 7,8,8,2,9
247 5,6,5,5,5
248 9,9,7,7,5
249 9,10,11,7,8
250 8,11,9,3,3
251 5,4,4,0,5
252 9,9,11,14,2
253 5,6,2,4,4
254 8,8,7,4,1
255 9,9,8,14,
256 6,8,7,2,
257 10,9,9,6,
258 8,8,10,9,
259 7,8,4,12,
260 6,6,6,7,1
261 5,7,7,4,10
262 9,10,10,13,4
263 9,11,9,8,7
264 10,13,12,6,8
265 8,11,6,8,5
266 7,8,7,12,2
267 6,7,4,1,10
268 5,4,5,6,10
269 7,8,6,12,10
270 6,5,3,9,2
271 7,8,8,7,2
272 5,4,4,9,8
273 5,7,6,3,9
274 10,10,9,13,1
275 8,10,9,5,4
276 8,9,8,8,7
277 7,9,9,6,7
278 10,9,7,12,6
279 10,13,12,12,4
280 7,10,9,7,2
281 6,8,7,11,6
282 8,11,5,13,2
283 7,10,6,12,8
284 10,10,9,7,9
285 9,12,6,7,10
286 6,6,8,2,9
287 10,9,12,13,10
288 8,9,8,3,6
289 8,7,6,4,10
290 8,7,10,12,2
291 7,6,8,2,7
292 8,11,6,9,4
293 6,6,7,8,2
294 6,7,3,11,4
295 5,6,3,0,5
296 10,10,11,15,6
297 5,4,7,6,8
298 5,4,4,1,3
299 6,9,8,1,6
300 10,11,10,15,8
301 7,10,4,11,7
302 9,12,8,6,3
303 10,10,11,15,2
304 10,9,9,15,3
305 6,6,8,5,1
306 5,7,7,0,3
307 9,8,10,6,8
308 9,8,11,11,4
309 8,10,7,3,4
310 7,8,7,3,3
311 8,9,10,13,8
312 end data.
313
314 CORRELATION
315         /VARIABLES =  var1 var2 var3 WITH var4 var5
316         /PRINT = TWOTAIL NOSIG.
317
318 CORRELATION
319         /VARIABLES =  var3 var4 var5 WITH var1 var2
320         /PRINT = TWOTAIL NOSIG.
321
322 ])
323
324 AT_CHECK([pspp -O format=csv  correlations.sps], [0],
325 [Table: Correlations
326 ,,var4,var5
327 var1,Pearson Correlation,.5693,-.0519
328 ,Sig. (2-tailed),.0000,.6232
329 ,N,93,92
330 var2,Pearson Correlation,.3792,-.0407
331 ,Sig. (2-tailed),.0002,.6985
332 ,N,95,93
333 var3,Pearson Correlation,.3699,-.0543
334 ,Sig. (2-tailed),.0002,.6029
335 ,N,95,94
336
337 Table: Correlations
338 ,,var1,var2
339 var3,Pearson Correlation,.6964,.5615
340 ,Sig. (2-tailed),.0000,.0000
341 ,N,96,97
342 var4,Pearson Correlation,.5693,.3792
343 ,Sig. (2-tailed),.0000,.0002
344 ,N,93,95
345 var5,Pearson Correlation,-.0519,-.0407
346 ,Sig. (2-tailed),.6232,.6985
347 ,N,92,93
348 ])
349
350 AT_CLEANUP