Move all command implementations into a single 'commands' directory.
[pspp] / tests / language / commands / reliability.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([RELIABILITY])
18
19 AT_SETUP([RELIABILITY])
20 AT_DATA([reliability.sps], [dnl
21 data list notable list  /var1 *
22         var2  *
23         var6  *
24         var7  *
25         var8  *
26         var9  *
27         var11 *
28         var12 *
29         var15 *
30         var16 *
31         var17 *
32         var19 *
33         .
34
35 begin data.
36 6 7 7 5 7 7 7 7 7 7 6 6
37 6 7 7 6 7 6 7 5 6 5 7 7
38 6 6 7 6 5 3 6 4 5 6 4 5
39 4 6 5 6 6 5 4 3 5 6 5 6
40 5 6 5 5 6 5 4 4 6 6 5 5
41 6 6 7 6 6 5 6 5 6 6 5 6
42 5 6 6 5 6 5 5 4 6 5 5 5
43 5 7 7 7 7 7 6 5 7 7 7 7
44 6 6 6 5 5 7 6 5 6 6 5 6
45 . . . . . . . . . . . .
46 6 6 5 5 5 6 6 4 6 5 5 5
47 7 7 7 6 7 6 7 6 6 6 7 6
48 4 7 6 6 6 5 5 4 4 5 5 6
49 5 6 3 5 4 1 4 6 2 3 3 2
50 3 6 6 5 6 2 4 2 2 4 4 5
51 6 6 7 5 6 5 7 6 5 6 6 5
52 6 5 6 6 5 6 6 6 6 4 5 5
53 5 7 7 . 6 6 6 5 6 6 6 6
54 5 7 5 5 4 6 7 6 5 4 6 5
55 7 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6 6 7 5 6
136 5 7 6 6 6 6 6 5 6 7 7 6
137 7 7 5 6 7 7 7 7 6 5 7 7
138 6 7 6 6 5 6 7 7 6 5 6 6
139 6 7 7 7 7 6 6 7 6 7 7 7
140 4 6 4 7 3 6 5 5 4 3 5 6
141 5 5 7 5 4 6 7 5 4 6 6 5
142 5 5 6 4 6 5 7 6 5 5 5 6
143 . . . . . . . . . . . .
144 . . . . . . . . . . . .
145 5 7 7 5 6 6 7 7 6 6 6 7
146 6 7 7 1 2 1 7 7 5 5 5 2
147 . . . . . . . . . . . .
148 3 7 4 6 4 7 4 6 4 7 4 7
149 5 7 3 5 5 6 7 5 4 7 7 4
150 4 7 7 5 4 6 7 7 6 5 4 4
151 6 6 2 2 6 4 6 5 5 1 5 2
152 5 5 6 4 5 4 6 5 5 6 5 5
153 . . . . . . . . . . . .
154 5 7 6 6 6 6 6 6 5 6 6 6
155 6 6 6 5 6 6 6 6 7 5 6 7
156 3 6 3 3 5 3 3 5 3 5 7 4
157 4 4 6 3 3 3 4 3 4 2 3 6
158 5 7 7 6 5 4 7 5 7 7 3 7
159 4 5 4 4 4 4 3 3 3 4 3 3
160 6 7 7 5 6 6 7 5 4 5 5 5
161 3 5 3 3 1 3 4 3 4 7 6 7
162 4 5 4 4 4 3 4 5 6 6 4 5
163 5 6 3 4 5 3 5 3 4 5 6 4
164 5 5 5 6 6 6 6 4 5 6 6 5
165 6 7 7 2 2 6 7 7 7 7 5 7
166 5 7 7 4 6 5 7 5 5 5 6 6
167 6 6 7 7 5 5 5 7 6 7 7 7
168 6 5 7 3 6 5 6 5 5 6 5 4
169 5 7 6 5 6 6 6 5 6 5 5 6
170 4 5 5 5 6 3 5 3 3 6 5 5
171 . . . . . . . . . . . .
172 5 6 6 4 4 4 5 3 5 5 2 6
173 5 6 7 5 5 6 6 5 5 6 6 6
174 6 7 7 6 4 7 7 6 7 5 6 7
175 6 6 5 4 5 2 7 6 6 5 6 6
176 2 2 2 2 2 2 3 2 3 1 1 2
177 end data.
178
179 RELIABILITY
180   /VARIABLES=var2 var8 var15 var17 var6
181   /SCALE('Everything') var6 var8 var15 var17
182   /MODEL=ALPHA.
183
184 RELIABILITY
185   /VARIABLES=var6 var8 var15 var17
186   /SCALE('Nothing') ALL
187   /MODEL=SPLIT(2)
188  .
189
190 RELIABILITY
191   /VARIABLES=var2 var6 var8 var15 var17 var19
192   /SCALE('Totals') var6 var8 var15 var17
193   /SUMMARY = total
194   /STATISTICS = DESCRIPTIVES COVARIANCES
195  .
196
197
198 RELIABILITY
199   /VARIABLES=var6 var8 var15 var17
200   .
201 ])
202 AT_CHECK([pspp -o pspp.csv -o pspp.txt reliability.sps], [0], [dnl
203 reliability.sps:174.4-174.40: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
204   174 |   /STATISTICS = DESCRIPTIVES COVARIANCES
205       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206 ])
207 AT_CHECK([cat pspp.csv], [0], [dnl
208 Scale: Everything
209
210 Table: Case Processing Summary
211 Cases,N,Percent
212 Valid,131,92.9%
213 Excluded,10,7.1%
214 Total,141,100.0%
215
216 Table: Reliability Statistics
217 Cronbach's Alpha,N of Items
218 .75,4
219
220 Scale: Nothing
221
222 Table: Case Processing Summary
223 Cases,N,Percent
224 Valid,131,92.9%
225 Excluded,10,7.1%
226 Total,141,100.0%
227
228 Table: Reliability Statistics
229 Cronbach's Alpha,Part 1,Value,.55
230 ,,N of Items,2
231 ,Part 2,Value,.63
232 ,,N of Items,2
233 ,Total N of Items,,4
234 Correlation Between Forms,,,.61
235 Spearman-Brown Coefficient,Equal Length,,.75
236 ,Unequal Length,,.75
237 Guttman Split-Half Coefficient,,,.75
238
239 "reliability.sps:174.4-174.40: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
240   174 |   /STATISTICS = DESCRIPTIVES COVARIANCES
241       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
242
243 Scale: Totals
244
245 Table: Case Processing Summary
246 Cases,N,Percent
247 Valid,131,92.9%
248 Excluded,10,7.1%
249 Total,141,100.0%
250
251 Table: Reliability Statistics
252 Cronbach's Alpha,N of Items
253 .75,4
254
255 Table: Item-Total Statistics
256 ,Scale Mean if Item Deleted,Scale Variance if Item Deleted,Corrected Item-Total Correlation,Cronbach's Alpha if Item Deleted
257 var6,15.97,8.43,.51,.71
258 var8,16.56,7.86,.53,.70
259 var15,16.47,8.45,.56,.68
260 var17,16.60,8.00,.57,.67
261
262 Scale: ANY
263
264 Table: Case Processing Summary
265 Cases,N,Percent
266 Valid,131,92.9%
267 Excluded,10,7.1%
268 Total,141,100.0%
269
270 Table: Reliability Statistics
271 Cronbach's Alpha,N of Items
272 .75,4
273 ])
274 AT_CLEANUP
275
276
277 dnl This was causing a AT.
278 AT_SETUP([RELIABILITY bad syntax])
279 AT_DATA([bad-syntax.sps], [dnl
280 data list notable list /x * y *.
281 begin data.
282 1 10
283 2 20
284 3 30
285 4 50
286 5 50
287 end data.
288
289 * This syntax is incorrect
290 reliability x y.
291 ])
292
293 AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
294
295 AT_CLEANUP
296
297 dnl Checks for a crash when bad syntax followed scale specification.
298 AT_SETUP([RELIABILITY bad syntax 2])
299 AT_DATA([bad-syntax.sps], [dnl
300 new file.
301 data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
302 begin data.
303 end data.
304
305 * This syntax is incorrect
306 reliability variables=f01 to f10/asdfj.
307 ])
308 AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
309 AT_CLEANUP
310
311
312 dnl Checks for a crash when the active file was empty.  Bug #38660.
313 AT_SETUP([RELIABILITY crash with no data])
314 AT_DATA([reliability.sps], [dnl
315 new file.
316 data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
317 begin data.
318 end data.
319
320 reliability variables=f01 to f10.
321 ])
322 AT_CHECK([pspp -O format=csv reliability.sps], [0], [])
323 AT_CLEANUP
324
325
326
327
328 dnl This is an example from doc/tutorial.texi
329 dnl So if the results of this have to be changed in any way,
330 dnl make sure to update that file.
331 AT_SETUP([RELIABILITY tutorial example])
332 AT_DATA([tut-example.sps], [dnl
333 get file='hotel.sav'.
334
335 compute v3 = 6 - v3.
336 compute v5 = 6 - v5.
337
338 reliability variables = v1 v3 v4.
339 ])
340
341 AT_CHECK([ln -s $top_srcdir/examples/hotel.sav .], [0])
342 AT_CHECK([pspp -o pspp.csv -o pspp.txt tut-example.sps])
343 AT_CHECK([cat pspp.csv], [0], [dnl
344 Scale: ANY
345
346 Table: Case Processing Summary
347 Cases,N,Percent
348 Valid,17,100.0%
349 Excluded,0,.0%
350 Total,17,100.0%
351
352 Table: Reliability Statistics
353 Cronbach's Alpha,N of Items
354 .81,3
355 ])
356 AT_CLEANUP
357
358 AT_SETUP([RELIABILITY syntax errors])
359 AT_DATA([reliability.sps], [dnl
360 DATA LIST LIST NOTABLE/x y z.
361 RELIABILITY **.
362 RELIABILITY VARIABLES=**.
363 RELIABILITY VARIABLES=x/ **.
364 RELIABILITY VARIABLES=x y/SCALE **.
365 RELIABILITY VARIABLES=x y/SCALE(**).
366 RELIABILITY VARIABLES=x y/SCALE('a' **).
367 RELIABILITY VARIABLES=x y/SCALE('a')=**.
368 RELIABILITY VARIABLES=x y/MODEL SPLIT(**).
369 RELIABILITY VARIABLES=x y/MODEL SPLIT(1 **).
370 RELIABILITY VARIABLES=x y/MODEL **.
371 RELIABILITY VARIABLES=x y/SUMMARY **.
372 RELIABILITY VARIABLES=x y/MISSING=**.
373 RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
374 RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
375 ])
376 AT_CHECK([pspp -O format=csv reliability.sps], [1], [dnl
377 "reliability.sps:2.13-2.14: error: RELIABILITY: Syntax error expecting VARIABLES.
378     2 | RELIABILITY **.
379       |             ^~"
380
381 "reliability.sps:3.23-3.24: error: RELIABILITY: Syntax error expecting variable name.
382     3 | RELIABILITY VARIABLES=**.
383       |                       ^~"
384
385 "reliability.sps:4.23: warning: RELIABILITY: Reliability on a single variable is not useful.
386     4 | RELIABILITY VARIABLES=x/ **.
387       |                       ^"
388
389 "reliability.sps:4.26-4.27: error: RELIABILITY: Syntax error expecting SCALE, MODEL, SUMMARY, MISSING, or STATISTICS.
390     4 | RELIABILITY VARIABLES=x/ **.
391       |                          ^~"
392
393 "reliability.sps:5.33-5.34: error: RELIABILITY: Syntax error expecting `('.
394     5 | RELIABILITY VARIABLES=x y/SCALE **.
395       |                                 ^~"
396
397 "reliability.sps:6.33-6.34: error: RELIABILITY: Syntax error expecting string.
398     6 | RELIABILITY VARIABLES=x y/SCALE(**).
399       |                                 ^~"
400
401 "reliability.sps:7.37-7.38: error: RELIABILITY: Syntax error expecting `)'.
402     7 | RELIABILITY VARIABLES=x y/SCALE('a' **).
403       |                                     ^~"
404
405 "reliability.sps:8.38-8.39: error: RELIABILITY: Syntax error expecting variable name.
406     8 | RELIABILITY VARIABLES=x y/SCALE('a')=**.
407       |                                      ^~"
408
409 "reliability.sps:9.39-9.40: error: RELIABILITY: Syntax error expecting number.
410     9 | RELIABILITY VARIABLES=x y/MODEL SPLIT(**).
411       |                                       ^~"
412
413 "reliability.sps:10.41-10.42: error: RELIABILITY: Syntax error expecting `@:}@'.
414    10 | RELIABILITY VARIABLES=x y/MODEL SPLIT(1 **).
415       |                                         ^~"
416
417 "reliability.sps:11.33-11.34: error: RELIABILITY: Syntax error expecting ALPHA or SPLIT.
418    11 | RELIABILITY VARIABLES=x y/MODEL **.
419       |                                 ^~"
420
421 "reliability.sps:12.35-12.36: error: RELIABILITY: Syntax error expecting TOTAL or ALL.
422    12 | RELIABILITY VARIABLES=x y/SUMMARY **.
423       |                                   ^~"
424
425 "reliability.sps:13.35-13.36: error: RELIABILITY: Syntax error expecting INCLUDE or EXCLUDE.
426    13 | RELIABILITY VARIABLES=x y/MISSING=**.
427       |                                   ^~"
428
429 "reliability.sps:14.27-14.45: warning: RELIABILITY: The STATISTICS subcommand is not yet implemented.  No statistics will be produced.
430    14 | RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
431       |                           ^~~~~~~~~~~~~~~~~~~"
432
433 "reliability.sps:14.48-14.49: error: RELIABILITY: Syntax error expecting SCALE, MODEL, SUMMARY, MISSING, or STATISTICS.
434    14 | RELIABILITY VARIABLES=x y/STATISTICS=x y zz y/ **.
435       |                                                ^~"
436
437 "reliability.sps:15.39: error: RELIABILITY: The split point must be less than the number of variables.
438    15 | RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
439       |                                       ^"
440
441 "reliability.sps:15.23-15.25: note: RELIABILITY: There are 2 variables.
442    15 | RELIABILITY VARIABLES=x y/MODEL SPLIT(5).
443       |                       ^~~"
444 ])
445 AT_CLEANUP