4316bd77c3aacf583ddd53f614d2933f7c5c5518
[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
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