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