28d5ac672e53c481742c35001fc2fa1489f663d6
[pspp] / tests / output / charts.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
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.
8 dnl 
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.
13 dnl 
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/>.
16 dnl
17 AT_BANNER([CHARTS Rudimentary run tests])
18
19 dnl Check that the charts work
20 dnl Currently, "work" means that the commands which
21 dnl should generate them, run without crashing.
22 dnl Better tests will come later (hopefully)
23
24 AT_SETUP([Examine])
25 AT_DATA([charts.sps],[
26 input program.
27 loop #i = 1 to 1000.
28  compute x  = rv.normal (56, 3) + rv.uniform (1, 1).
29  compute y  = rv.normal (6, 2) + rv.uniform (1, 2).
30  compute A  = rv.uniform (-1, 1).
31   compute A = (A > 0).
32  end case.
33 end loop.
34 end file.
35 end input program.
36
37 examine x y by a
38         /plot = histogram, npplot spreadlevel(1)
39         .
40
41 examine x y by a
42         /compare = groups
43         /plot = boxplot
44         .
45
46 examine x y by a
47         /compare = variables
48         /plot = boxplot
49         .
50 ])
51
52 AT_CHECK([pspp -o pspp.txt charts.sps], [0], [ignore])
53
54 AT_CLEANUP
55
56 AT_SETUP([Roc])
57 AT_DATA([roc.sps],[
58 data list list /fred * group * w *.
59 begin data.
60 99  0 1000
61 99  1 3
62 97  0 908
63 97  1 2
64 95  0 904
65 96  1 7
66 94  1 9
67 93  0 823
68 93  1 12
69 90  0 723
70 90  1 42
71 84  0 523
72 84  1 98
73 73  0 500
74 75  1 180
75 63  0 520
76 69  1 320
77 60  0 510
78 60  1 418
79 50  0 488
80 54  1 432
81 46  0 428
82 43  1 528
83 36  0 324
84 36  1 612
85 26  0 294
86 28  1 682
87 20  0 119
88 20  1 719
89 10  0 97
90 10  1 809
91 end data.
92
93 weight by w.
94
95 compute bert = fred + (group < 0.5) * 45.
96 compute charlie = fred + (group > 0.5) * 15.
97
98
99 ROC /fred bert charlie by group (0)
100         /plot = curve (reference).
101
102 ])
103
104 AT_CHECK([pspp -o pspp.txt roc.sps], [0], [ignore])
105
106 AT_CLEANUP
107
108
109
110
111 AT_SETUP([Scree])
112 AT_DATA([scree.sps],[
113 input program.
114 vector vec(10).
115 loop #i = 1 to 100.
116  loop #v = 1 to 3.
117  compute vec(#v) = rv.normal (0, 45).
118  end loop.
119  loop #v = 4 to 10.
120  compute vec(#v) = vec (#v - 3) + rv.normal (0, 30).
121  end loop.
122  end case.
123 end loop.
124 end file.
125 end input program.
126
127
128 factor /variables = all
129         /print initial
130         /plot = eigen.
131
132 ])
133
134 AT_CHECK([pspp -o pspp.txt scree.sps], [0], [ignore])
135
136 AT_CLEANUP
137
138
139 AT_SETUP([Histogram])
140 AT_DATA([histogram.sps],[
141 * This test is designed to "torture" the code which
142   generates histograms.  It is no-crash test. However
143   the code is rich in assertions, so any problems we
144   hope will be caught there.
145   
146
147 input program.
148 loop #i = 1 to 1000.
149  compute pos  = rv.normal (56, 3) + rv.uniform (1, 1).
150  compute neg  = rv.normal (-86, 2) + rv.uniform (1, 1).
151  compute pn  = rv.normal (0, 2) + rv.uniform (1, 2).
152  compute A  = rv.uniform (-1, 1).
153   compute A = (A > 0).
154  end case.
155 end loop.
156 end file.
157 end input program.
158
159
160 examine pos neg pn by a
161         /plot = histogram
162         .
163
164 frequencies pos neg pn
165         /format=notable
166         /histogram=normal.
167 ])
168
169
170 dnl The --testing-mode flag is important!!
171 AT_CHECK([pspp --testing-mode -o pspp.txt histogram.sps], [0], [ignore])
172
173 AT_CLEANUP
174
175
176 AT_SETUP([FREQUENCIES charts])
177 AT_DATA([xxx.sps],[
178 DATA LIST LIST /nationality (A10)  religion (A20) gender (A8).
179 BEGIN DATA.
180 Australian  Sikh      Male
181 Australian  Sikh      Male
182 Australian  Sikh      Male
183 Australian  Sikh      Male
184 British     Zoroastrian Female
185 British     Buddist   Female
186 British     Buddist   Female
187 British      Zoroastrian Female
188 German      Muslim    Male
189 German      Christian Male
190 German      Christian Female
191 German      Christian Male
192 German      Zoroastrian Female
193 German      Sikh   Female
194 German      Muslim Female
195 German      Pastafarian Female
196 German      "Jedi Knight" Female
197 Belgian     Sikh      Male
198 French       Muslim      Male
199 French       Muslim      Male
200 French       Christian      Male
201 END DATA.
202
203
204 FREQUENCIES /VARIABLES=religion nationality /BARCHART /PIECHART. 
205 ])
206
207
208 AT_CHECK([pspp  -o pspp.txt xxx.sps], [0], [ignore])
209
210 AT_CLEANUP
211
212
213
214 AT_SETUP([CROSSTABS charts])
215 AT_DATA([xxx.sps],[
216 DATA LIST LIST /nationality (A10)  religion (A20) gender (A8).
217 BEGIN DATA.
218 Australian  Sikh      Male
219 Australian  Sikh      Male
220 Australian  Sikh      Male
221 Australian  Sikh      Male
222 British     Zoroastrian Female
223 British     Buddist   Female
224 British     Buddist   Female
225 British      Zoroastrian Female
226 German      Muslim    Male
227 German      Christian Male
228 German      Christian Female
229 German      Christian Male
230 German      Zoroastrian Female
231 German      Sikh   Female
232 German      Muslim Female
233 German      Pastafarian Female
234 German      "Jedi Knight" Female
235 Belgian     Sikh      Male
236 French       Muslim      Male
237 French       Muslim      Male
238 French       Christian      Male
239 END DATA.
240
241
242 CROSSTABS 
243           /tables = nationality by religion by gender
244           /tables = nationality by religion
245           /tables = religion by gender
246           /tables = nationality by religion by gender
247           /barchart.
248 ])
249
250
251 AT_CHECK([pspp  -o pspp.txt xxx.sps], [0], [ignore])
252
253 AT_CLEANUP
254
255
256
257
258 AT_SETUP([BOXPLOT Empty])
259 AT_DATA([bp.sps],[
260 DATA LIST LIST /X * Y * .
261 BEGIN DATA
262 1
263 2
264 2
265 2
266 3
267 END DATA
268
269 EXAMINE
270     /VARIABLES = Y
271     /PLOT = BOXPLOT.
272 ])
273
274
275 AT_CHECK([pspp -o pspp.txt bp.sps], [0], [ignore])
276
277 AT_CLEANUP
278
279
280
281
282
283
284
285
286
287