Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / stats / logistic.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([LOGISTIC REGRESSION])
18
19 dnl These examples are adapted from
20 dnl http://www.uvm.edu/~dhowell/gradstat/psych341/lectures/Logistic%20Regression/LogisticReg1.html
21
22
23
24 m4_define([LOGIT_TEST_DATA],
25   [AT_DATA([lr-data.txt], dnl
26  105.00    1.00    33.00    3.00     2.00   .35  17.00  20.00  .50110  -2.00440 1
27  106.00    1.00    50.00    2.00     3.00   .38   7.00  15.00  .20168  -1.25264 1
28  107.00    1.00    91.00    3.00     2.00   .28  15.00   7.00  .00897  -1.00905 1
29  108.00    1.00    90.00    3.00     2.00   .20   2.00   2.00  .00972  -1.00982 1
30  109.00    1.00    70.00    3.00     3.00   .38  23.00  27.00  .04745  -1.04981 1
31  111.00    2.00    31.00    2.00     2.00   .00  19.00  10.00  .54159   1.84640 1
32  112.00    1.00    91.00    2.00     3.00   .18   6.00  16.00  .00897  -1.00905 1
33  113.00    1.00    81.00    3.00     2.00   .00   3.00   9.00  .01998  -1.02039 1
34  114.00    2.00    15.00    1.00     2.00   .13  19.00  13.00  .81241   1.23090 1
35  116.00    2.00     1.00    1.00     2.00   .88  15.00   7.00  .93102   1.07410 1
36  117.00    1.00    93.00    3.00     2.00   .18   9.00  15.00  .00764  -1.00770 1
37  118.00    2.00    14.00    1.00     3.00   .15  23.00  18.00  .82447   1.21289 1
38  120.00    1.00    91.00    2.00     2.00   .43  17.00  14.00  .00897  -1.00905 1
39  121.00    1.00    55.00    3.00     2.00   .69  20.00  14.00  .14409  -1.16834 1
40  122.00    1.00    70.00    2.00     3.00   .03    .00   6.00  .04745  -1.04981 1
41  123.00    1.00    25.00    2.00     2.00   .45   4.00  10.00  .65789  -2.92301 1
42  125.00    1.00    91.00    2.00     2.00   .13    .00   3.00  .00897  -1.00905 1
43  126.00    1.00    91.00    3.00     3.00   .23   4.00   6.00  .00897  -1.00905 1
44  127.00    1.00    91.00    3.00     2.00   .00   8.00   8.00  .00897  -1.00905 1
45  128.00    2.00    13.00    2.00     2.00   .65  16.00  14.00  .83592   1.19629 1
46  129.00    1.00    50.00    2.00     2.00   .25  20.00  23.00  .20168  -1.25264 1
47  135.00    1.00    90.00    3.00     3.00   .03   5.00  12.00  .00972  -1.00982 1
48  138.00    1.00    70.00    3.00     3.00   .10   1.00   6.00  .04745  -1.04981 1
49  139.00    2.00    19.00    3.00     3.00   .10  11.00  12.00  .75787   1.31949 1
50  149.00    2.00    50.00    3.00     2.00   .03    .00    .00  .20168   4.95826 1
51  204.00    1.00    50.00    3.00     1.00   .13    .00   1.00  .20168  -1.25264 1
52  205.00    1.00    91.00    3.00     3.00   .72  16.00  18.00  .00897  -1.00905 1
53  206.00    2.00    24.00    1.00     1.00   .10   5.00  21.00  .67592   1.47947 1
54  207.00    1.00    80.00    3.00     3.00   .13   6.00   7.00  .02164  -1.02212 1
55  208.00    1.00    87.00    2.00     2.00   .18   9.00  20.00  .01237  -1.01253 1
56  209.00    1.00    70.00    2.00     2.00   .53  15.00  12.00  .04745  -1.04981 1
57  211.00    1.00    55.00    2.00     1.00   .33   8.00   5.00  .14409  -1.16834 1
58  212.00    1.00    56.00    3.00     1.00   .30   6.00  20.00  .13436  -1.15522 1
59  214.00    1.00    54.00    2.00     2.00   .15    .00  16.00  .15439  -1.18258 1
60  215.00    1.00    71.00    3.00     3.00   .35  12.00  12.00  .04391  -1.04592 1
61  217.00    2.00    36.00    1.00     1.00   .10  12.00   8.00  .44049   2.27020 1
62  218.00    1.00    91.00    2.00     2.00   .05  11.00  25.00  .00897  -1.00905 1
63  219.00    1.00    91.00    2.00     2.00  1.23  11.00  24.00  .00897  -1.00905 1
64  220.00    1.00    91.00    2.00     3.00   .08   8.00  11.00  .00897  -1.00905 1
65  221.00    1.00    91.00    2.00     2.00   .33   5.00  11.00  .00897  -1.00905 1
66  222.00    2.00    36.00    2.00     1.00   .18   5.00   3.00  .44049   2.27020 1
67  223.00    1.00    70.00    2.00     3.00   .18  14.00   3.00  .04745  -1.04981 1
68  224.00    1.00    91.00    2.00     2.00   .43   2.00  10.00  .00897  -1.00905 1
69  225.00    1.00    55.00    2.00     1.00   .18   6.00  11.00  .14409  -1.16834 1
70  229.00    2.00    75.00    2.00     2.00   .40  30.00  25.00  .03212  31.12941 1
71  232.00    1.00    91.00    3.00     2.00   .15   6.00   3.00  .00897  -1.00905 1
72  233.00    1.00    70.00    2.00     1.00   .00  11.00   8.00  .04745  -1.04981 1
73  234.00    1.00    54.00    3.00     2.00   .10    .00    .00  .15439  -1.18258 1
74  237.00    1.00    70.00    3.00     2.00   .18   5.00  25.00  .04745  -1.04981 1
75  241.00    1.00    19.00    2.00     3.00   .33  13.00   9.00  .75787  -4.12995 1
76  304.00    2.00    18.00    2.00     2.00   .26  25.00   6.00  .77245   1.29458 1
77  305.00    1.00    88.00    3.00     2.00  1.35  17.00  29.00  .01142  -1.01155 1
78  306.00    1.00    70.00    2.00     3.00   .63  14.00  33.00  .04745  -1.04981 1
79  307.00    1.00    85.00    2.00     2.00  2.65  18.00  14.00  .01452  -1.01474 1
80  308.00    1.00    13.00    2.00     2.00   .23   5.00   5.00  .83592  -6.09442 1
81  309.00    2.00    13.00    2.00     2.00   .23   7.00  17.00  .83592   1.19629 1
82  311.00    2.00     1.00    2.00     2.00   .50  20.00  14.00  .93102   1.07410 1
83  315.00    1.00    19.00    2.00     3.00   .18   1.00  11.00  .75787  -4.12995 1
84  316.00    1.00    88.00    2.00     2.00   .38  12.00  11.00  .01142  -1.01155 2
85  318.00    1.00    88.00    3.00     2.00   .03   5.00   5.00  .01142  -1.01155 3
86  319.00    2.00    18.00    2.00     3.00   .30  15.00  16.00  .77245   1.29458 1
87  321.00    2.00    15.00    2.00     2.00   .63  15.00  18.00  .81241   1.23090 1
88  322.00    1.00    88.00    3.00     2.00   .40  18.00  15.00  .01142  -1.01155 1
89  325.00    2.00    18.00    2.00     3.00  1.00  28.00  18.00  .77245   1.29458 1
90  329.00    1.00    88.00    3.00     2.00   .03   7.00  11.00  .01142  -1.01155 4
91  332.00    2.00     2.00    2.00     2.00   .05   8.00   9.00  .92562   1.08036 1
92 )])
93
94 dnl  Note: In the above data cases 305, 316 318 and 329 have identical values
95 dnl of the 2nd and 3rd variables.  We use this for weight testing.
96
97 AT_SETUP([LOGISTIC REGRESSION basic test])
98
99 LOGIT_TEST_DATA
100
101 AT_DATA([lr-data.sps], [dnl
102 set format = F12.3.
103 set decimal dot.
104 data list notable file='lr-data.txt'
105  list /id outcome survrate prognos amttreat   gsi  avoid intrus   pre_1     lre_1  w *.
106
107 logistic regression
108           variables = outcome with survrate
109         .
110 ])
111
112 AT_CHECK([pspp -O format=csv lr-data.sps], [0],
113   [dnl
114 Table: Dependent Variable Encoding
115 Original Value,Internal Value
116 1.000,0
117 2.000,1
118
119 Table: Case Processing Summary
120 Unweighted Cases,N,Percent
121 Included in Analysis,66,100.000
122 Missing Cases,0,.000
123 Total,66,100.000
124
125 note: Estimation terminated at iteration number 6 because parameter estimates changed by less than 0.001
126
127 Table: Model Summary
128 Step 1,-2 Log likelihood,Cox & Snell R Square,Nagelkerke R Square
129 ,37.323,.455,.659
130
131 Table: Classification Table
132 ,,,Predicted,,
133 ,,,outcome,,"Percentage
134 Correct"
135 ,Observed,,1.000,2.000,
136 Step 1,outcome,1.000,43,5,89.583
137 ,,2.000,4,14,77.778
138 ,Overall Percentage,,,,86.364
139
140 Table: Variables in the Equation
141 ,,B,S.E.,Wald,df,Sig.,Exp(B)
142 Step 1,survrate,-.081,.019,17.756,1,.000,.922
143 ,Constant,2.684,.811,10.941,1,.001,14.639
144 ])
145
146
147 AT_CLEANUP
148
149 AT_SETUP([LOGISTIC REGRESSION missing values])
150
151 LOGIT_TEST_DATA
152
153 AT_DATA([lr-data.sps], [dnl
154 set format = F12.3.
155 set decimal dot.
156 data list notable file='lr-data.txt'
157  list /id outcome survrate prognos amttreat   gsi  avoid intrus   pre_1     lre_1  w *.
158
159 missing values survrate (999) avoid (44444) outcome (99).
160
161 logistic regression
162           variables = outcome with survrate avoid
163         .
164 ])
165
166 AT_CHECK([pspp -O format=csv lr-data.sps > run0], [0], [ignore])
167
168 dnl Append some cases with missing values into the data.
169 cat >> lr-data.txt << HERE
170  105.00    1.00    999.00    3.00     2.00   .35  17.00  20.00  .50110  -2.00440 1
171  106.00    1.00    999.00    2.00     3.00   .38   7.00  15.00  .20168  -1.25264 1
172  107.00    1.00    5.00      3.00     2.00   .28  44444  34     .00897  -1.00905 1
173  108.00    99      5.00      3.00     2.00   .28  4      34     .00897  -1.00905 1
174 HERE
175
176 AT_CHECK([pspp -O format=csv lr-data.sps > run1], [0], [ignore])
177
178 dnl Only the summary information should be different
179 AT_CHECK([diff run0 run1], [1], [dnl
180 8,10c8,10
181 < Included in Analysis,66,100.000
182 < Missing Cases,0,.000
183 < Total,66,100.000
184 ---
185 > Included in Analysis,66,94.286
186 > Missing Cases,4,5.714
187 > Total,70,100.000
188 ])
189
190 AT_CLEANUP
191
192
193
194 dnl Check that a weighted dataset is interpreted correctly
195 dnl To do this, the same data set is used, one weighted, one not.
196 dnl The weighted dataset omits certain cases which are identical
197 AT_SETUP([LOGISTIC REGRESSION weights])
198
199 LOGIT_TEST_DATA
200
201 AT_DATA([lr-data-unweighted.sps], [dnl
202 set format = F12.3.
203 set decimal dot.
204 data list notable file='lr-data.txt'
205  list /id outcome survrate prognos amttreat   gsi  avoid intrus   pre_1     lre_1  w *.
206
207 logistic regression
208           variables = outcome with survrate
209         .
210 ])
211
212 AT_DATA([lr-data-weighted.sps], [dnl
213 set format = F12.3.
214 set decimal dot.
215 data list notable file='lr-data.txt'
216  list /id outcome survrate prognos amttreat   gsi  avoid intrus   pre_1     lre_1  w *.
217
218 weight by w.
219
220 * Omit duplicate cases.
221 select if id <> 305 and id <> 316 and id <> 318.
222
223 logistic regression
224           variables = outcome with survrate
225         .
226 ])
227
228
229 AT_CHECK([pspp -O format=csv lr-data-unweighted.sps > unweighted-result], [0], [ignore])
230 AT_CHECK([pspp -O format=csv lr-data-weighted.sps > weighted-result], [0], [ignore])
231
232 dnl The only difference should be the summary information, since
233 dnl this displays the unweighted totals.
234 AT_CHECK([diff unweighted-result weighted-result], [1], [dnl
235 8c8
236 < Included in Analysis,66,100.000
237 ---
238 > Included in Analysis,63,100.000
239 10c10
240 < Total,66,100.000
241 ---
242 > Total,63,100.000
243 23,24c23,24
244 < Step 1,outcome,1.000,43,5,89.583
245 < ,,2.000,4,14,77.778
246 ---
247 > Step 1,outcome,1.000,43.000,5.000,89.583
248 > ,,2.000,4.000,14.000,77.778
249 ])
250
251
252 AT_CLEANUP
253
254
255 dnl Check that the /NOCONST option works as intended.
256 dnl The results this produces are very similar to those
257 dnl at the example in http://www.ats.ucla.edu/stat/SPSS/faq/logregconst.htm
258 AT_SETUP([LOGISTIC REGRESSION without constant])
259
260 AT_DATA([non-const.sps], [dnl
261 set format=F20.3.
262
263 input program.
264  loop #i = 1 to 200.
265   compute female = (#i > 91).
266   end case.
267  end loop.
268 end file.
269 end input program.
270
271 compute constant = 1.
272
273 logistic regression female with constant /noconst.
274 ])
275
276 AT_CHECK([pspp -O format=csv non-const.sps], [0],
277  [dnl
278 Table: Dependent Variable Encoding
279 Original Value,Internal Value
280 .00,0
281 1.00,1
282
283 Table: Case Processing Summary
284 Unweighted Cases,N,Percent
285 Included in Analysis,200,100.000
286 Missing Cases,0,.000
287 Total,200,100.000
288
289 note: Estimation terminated at iteration number 2 because parameter estimates changed by less than 0.001
290
291 Table: Model Summary
292 Step 1,-2 Log likelihood,Cox & Snell R Square,Nagelkerke R Square
293 ,275.637,.008,.011
294
295 Table: Classification Table
296 ,,,Predicted,,
297 ,,,female,,"Percentage
298 Correct"
299 ,Observed,,.00,1.00,
300 Step 1,female,.00,0,91,.000
301 ,,1.00,0,109,100.000
302 ,Overall Percentage,,,,54.500
303
304 Table: Variables in the Equation
305 ,,B,S.E.,Wald,df,Sig.,Exp(B)
306 Step 1,constant,.180,.142,1.616,1,.204,1.198
307 ])
308
309 AT_CLEANUP
310
311
312
313 dnl Check that if somebody passes a dependent variable which is not dichtomous,
314 dnl then an error is raised.
315 AT_SETUP([LOGISTIC REGRESSION non-dichotomous dep var])
316
317 AT_DATA([non-dich.sps], [dnl
318 data list notable list /y x1 x2 x3 x4.
319 begin data.
320 1 2 3 4 5
321 0 2 3 4 8
322 2 3 4 5 6
323 end data.
324
325 logistic regression y with x1 x2 x3 x4.
326 ])
327
328 AT_CHECK([pspp -O format=csv non-dich.sps], [1],
329  [dnl
330 error: Dependent variable's values are not dichotomous.
331 ])
332
333 AT_CLEANUP
334
335
336
337 dnl An example to check the behaviour of LOGISTIC REGRESSION with a categorical
338 dnl variable.  This examṕle was inspired from that at:
339 dnl http://www.ats.ucla.edu/stat/spss/dae/logit.htm 
340 AT_SETUP([LOGISTIC REGRESSION with categorical])
341
342 AT_DATA([lr-cat.data], [dnl
343  620 3.07 2 4 
344  800 4.00 3 9 
345  580 3.40 2 4 
346  600 3.13 2 4 
347  540 2.70 2 4 
348  660 3.31 4 4 
349  480 3.58 1 9 
350  620 4.00 1 9 
351  680 3.98 2 9 
352  580 3.40 4 4 
353  760 3.35 3 4 
354  700 3.72 2 4 
355  460 3.64 1 9 
356  540 3.28 3 4 
357  680 3.48 3 4 
358  740 3.31 1 4 
359  460 3.77 3 4 
360  740 3.54 1 4 
361  600 3.63 3 4 
362  620 3.05 2 4 
363  560 3.04 3 4 
364  520 2.70 3 4 
365  640 3.35 3 4 
366  620 3.58 2 4 
367  660 3.70 4 9 
368  500 2.86 4 4 
369  640 3.50 2 4 
370  720 4.00 3 4 
371  720 3.94 3 4 
372  400 3.65 2 4 
373  800 2.90 2 4 
374  520 2.90 3 4 
375  440 3.24 4 4 
376  580 3.51 2 4 
377  500 3.31 3 4 
378  440 3.22 1 4 
379  540 3.17 1 9 
380  420 3.02 1 4 
381  780 3.22 2 9 
382  440 3.13 4 4 
383  800 3.66 1 9 
384  580 3.32 2 9 
385  480 2.67 2 9 
386  700 4.00 1 9 
387  740 2.97 2 9 
388  700 3.83 2 4 
389  640 3.93 2 4 
390  800 3.90 2 4 
391  400 3.38 2 4 
392  700 3.52 2 4 
393  680 3.00 4 9 
394  540 3.20 1 4 
395  580 4.00 2 4 
396  780 4.00 2 9 
397  220 2.83 3 4 
398  580 3.20 2 9 
399  580 3.50 2 4 
400  620 3.30 1 4 
401  520 3.65 4 9 
402  600 3.38 3 9 
403  660 3.77 3 4 
404  580 2.86 4 9 
405  580 3.46 2 9 
406  560 3.36 3 4 
407  740 4.00 3 9 
408  480 3.44 3 4 
409  640 3.19 4 9 
410  600 3.54 1 9 
411  540 3.38 4 4 
412  500 2.81 3 4 
413  360 2.56 3 4 
414  460 3.15 4 4 
415  460 2.63 2 4 
416  440 2.76 2 4 
417  740 3.62 4 4 
418  380 3.38 2 4 
419  640 3.63 1 9 
420  800 3.73 1 4 
421  660 3.67 2 4 
422  760 3.00 2 9 
423  420 2.96 1 4 
424  740 3.74 4 4 
425  800 3.75 2 4 
426  620 3.40 2 4 
427  660 3.67 3 9 
428  400 3.35 3 4 
429  680 3.14 2 4 
430  660 3.47 3 9 
431  660 3.63 2 9 
432  420 3.41 4 4 
433  660 4.00 1 4 
434  680 3.70 2 4 
435  620 3.23 3 9 
436  520 3.35 3 4 
437  500 4.00 3 4 
438  400 3.36 2 4 
439  700 3.56 1 9 
440  540 3.81 1 9 
441  520 2.68 3 9 
442  540 3.50 2 4 
443  700 4.00 2 4 
444  600 3.64 3 9 
445  800 3.31 3 4 
446  520 3.29 1 4 
447  580 3.69 1 4 
448  380 3.43 3 4 
449  560 3.19 3 4 
450  760 2.81 1 9 
451  540 3.13 2 4 
452  660 3.14 2 9 
453  520 3.81 1 9 
454  680 3.19 4 4 
455  540 3.78 4 4 
456  500 3.57 3 4 
457  660 3.49 2 4 
458  340 3.00 2 9 
459  400 3.15 2 9 
460  420 3.92 4 4 
461  760 3.35 2 9 
462  700 2.94 2 4 
463  540 3.04 1 4 
464  780 3.87 4 4 
465  560 3.78 2 4 
466  700 3.82 3 4 
467  400 2.93 3 4 
468  440 3.45 2 9 
469  800 3.47 3 4 
470  340 3.15 3 4 
471  520 4.00 1 9 
472  520 3.15 3 4 
473  600 2.98 2 9 
474  420 2.69 2 4 
475  460 3.44 2 4 
476  620 3.71 1 9 
477  480 3.13 2 4 
478  580 3.40 3 4 
479  540 3.39 3 9 
480  540 3.94 3 4 
481  440 2.98 3 4 
482  380 3.59 4 4 
483  500 2.97 4 4 
484  340 2.92 3 4 
485  440 3.15 2 4 
486  600 3.48 2 4 
487  420 2.67 3 4 
488  460 3.07 2 4 
489  460 3.45 3 9 
490  480 3.39 4 4 
491  480 2.78 3 4 
492  720 3.42 2 9 
493  680 3.67 2 9 
494  800 3.89 2 4 
495  360 3.00 3 4 
496  620 3.17 2 9 
497  700 3.52 4 9 
498  540 3.19 2 4 
499  580 3.30 2 4 
500  800 4.00 3 9 
501  660 3.33 2 4 
502  380 3.34 3 4 
503  720 3.84 3 4 
504  600 3.59 2 4 
505  500 3.03 3 4 
506  640 3.81 2 4 
507  540 3.49 1 9 
508  680 3.85 3 9 
509  540 3.84 2 9 
510  460 2.93 3 4 
511  380 2.94 3 4 
512  620 3.22 2 4 
513  740 3.37 4 4 
514  620 4.00 2 4 
515  800 3.74 1 9 
516  400 3.31 3 4 
517  540 3.46 4 4 
518  620 3.18 2 9 
519  480 2.91 1 9 
520  300 2.84 2 9 
521  440 2.48 4 4 
522  640 2.79 2 4 
523  400 3.23 4 9 
524  680 3.46 2 9 
525  620 3.37 1 9 
526  700 3.92 2 4 
527  620 3.37 2 9 
528  620 3.63 2 4 
529  620 3.95 3 9 
530  560 2.52 2 4 
531  520 2.62 2 4 
532  600 3.35 2 4 
533  700 4.00 1 4 
534  640 3.67 3 4 
535  640 4.00 3 4 
536  520 2.93 4 4 
537  620 3.21 4 4 
538  680 3.99 3 4 
539  660 3.34 3 4 
540  700 3.45 3 4 
541  560 3.36 1 9 
542  800 2.78 2 4 
543  500 3.88 4 4 
544  700 3.65 2 4 
545  680 3.76 3 9 
546  660 3.07 3 4 
547  580 3.46 4 4 
548  460 2.87 2 4 
549  600 3.31 4 4 
550  620 3.94 4 4 
551  400 3.05 2 4 
552  800 3.43 2 9 
553  600 3.58 1 9 
554  580 3.36 2 4 
555  540 3.16 3 4 
556  500 2.71 2 4 
557  600 3.28 3 4 
558  600 2.82 4 4 
559  460 3.58 2 4 
560  520 2.85 3 4 
561  740 3.52 4 9 
562  500 3.95 4 4 
563  560 3.61 3 4 
564  620 3.45 2 9 
565  640 3.51 2 4 
566  660 3.44 2 9 
567  660 2.91 3 9 
568  540 3.28 1 4 
569  560 2.98 1 9 
570  800 3.97 1 4 
571  720 3.77 3 4 
572  720 3.64 1 9 
573  480 3.71 4 9 
574  680 3.34 2 4 
575  680 3.11 2 4 
576  540 2.81 3 4 
577  620 3.75 2 9 
578  540 3.12 1 4 
579  560 3.48 2 9 
580  720 3.40 3 4 
581  680 3.90 1 4 
582  640 3.76 3 4 
583  560 3.16 1 4 
584  520 3.30 2 9 
585  640 3.12 3 4 
586  580 3.57 3 4 
587  540 3.55 4 9 
588  780 3.63 4 9 
589  600 3.89 1 9 
590  800 4.00 1 9 
591  580 3.29 4 4 
592  360 3.27 3 4 
593  800 4.00 2 9 
594  640 3.52 4 4 
595  720 3.45 4 4 
596  580 3.06 2 4 
597  580 3.02 2 4 
598  500 3.60 3 9 
599  580 3.12 3 9 
600  600 2.82 4 4 
601  620 3.99 3 4 
602  700 4.00 3 4 
603  480 4.00 2 4 
604  560 2.95 2 4 
605  560 4.00 3 4 
606  560 2.65 3 9 
607  400 3.08 2 4 
608  480 2.62 2 9 
609  640 3.86 3 4 
610  480 3.57 2 4 
611  540 3.51 2 4 
612  380 3.33 4 4 
613  680 3.64 3 4 
614  400 3.51 3 4 
615  340 2.90 1 4 
616  700 3.08 2 4 
617  480 3.02 1 9 
618  600 3.15 2 9 
619  780 3.80 3 9 
620  520 3.74 2 9 
621  520 3.51 2 4 
622  640 3.73 3 4 
623  560 3.32 4 4 
624  620 2.85 2 4 
625  700 3.28 1 4 
626  760 4.00 1 9 
627  800 3.60 2 4 
628  580 3.34 2 4 
629  540 3.77 2 9 
630  640 3.17 2 4 
631  540 3.02 4 4 
632  680 3.08 4 4 
633  680 3.31 2 4 
634  680 2.96 3 9 
635  700 2.88 2 4 
636  580 3.77 4 4 
637  540 3.49 2 9 
638  700 3.56 2 9 
639  600 3.56 2 9 
640  560 3.59 2 4 
641  640 2.94 2 9 
642  560 3.33 4 4 
643  620 3.69 3 4 
644  680 3.27 2 9 
645  460 3.14 3 4 
646  500 3.53 4 4 
647  620 3.33 3 4 
648  600 3.62 3 4 
649  500 3.01 4 4 
650  740 3.34 4 4 
651  560 3.69 3 9 
652  620 3.95 3 9 
653  740 3.86 2 9 
654  800 3.53 1 9 
655  620 3.78 3 4 
656  700 3.27 2 4 
657  540 3.78 2 9 
658  700 3.65 2 4 
659  800 3.22 1 9 
660  560 3.59 2 9 
661  800 3.15 4 4 
662  520 3.90 3 9 
663  520 3.74 4 9 
664  480 2.55 1 4 
665  800 4.00 4 4 
666  620 3.09 4 4 
667  560 3.49 4 4 
668  500 3.17 3 4 
669  480 3.40 2 4 
670  460 2.98 1 4 
671  580 3.58 1 9 
672  640 3.30 2 4 
673  480 3.45 2 4 
674  440 3.17 2 4 
675  660 3.32 1 4 
676  500 3.08 3 4 
677  660 3.94 2 4 
678  720 3.31 1 4 
679  460 3.64 3 9 
680  500 2.93 4 4 
681  800 3.54 3 4 
682  580 2.93 2 4 
683  620 3.61 1 9 
684  500 2.98 3 4 
685  660 4.00 2 9 
686  560 3.24 4 4 
687  560 2.42 2 4 
688  580 3.80 2 4 
689  500 3.23 4 4 
690  680 2.42 1 9 
691  580 3.46 3 4 
692  800 3.91 3 4 
693  700 2.90 4 4 
694  520 3.12 2 4 
695  300 2.92 4 4 
696  560 3.43 3 4 
697  620 3.63 3 4 
698  500 2.79 4 4 
699  360 3.14 1 4 
700  640 3.94 2 9 
701  460 3.99 3 9 
702  300 3.01 3 4 
703  520 2.73 2 4 
704  600 3.47 2 9 
705  580 3.25 1 4 
706  520 3.10 4 4 
707  620 3.43 3 4 
708  380 2.91 4 4 
709  660 3.59 3 4 
710  660 3.95 2 9 
711  540 3.33 3 4 
712  740 4.00 3 4 
713  640 3.38 3 4 
714  600 3.89 3 4 
715  720 3.88 3 4 
716  580 4.00 3 4 
717  420 2.26 4 4 
718  520 4.00 2 9 
719  800 3.70 1 9 
720  700 4.00 1 9 
721  480 3.43 2 4 
722  660 3.45 4 4 
723  520 3.25 3 4 
724  560 2.71 3 4 
725  600 3.32 2 4 
726  580 2.88 2 4 
727  660 3.88 2 9 
728  600 3.22 1 4 
729  580 4.00 1 4 
730  660 3.60 3 9 
731  500 3.35 2 4 
732  520 2.98 2 4 
733  660 3.49 2 9 
734  560 3.07 2 4 
735  500 3.13 2 9 
736  720 3.50 3 9 
737  440 3.39 2 9 
738  640 3.95 2 9 
739  380 3.61 3 4 
740  800 3.05 2 9 
741  520 3.19 3 9 
742  600 3.40 3 4 
743 ])
744
745 AT_DATA([lr-cat.sps], [dnl
746 set format=F20.3.
747
748 data list notable list file='lr-cat.data' /b1 b2 bcat y.
749
750 logistic regression
751           y with b1 b2 bcat
752            /categorical = bcat
753            .
754 ])
755
756 AT_CHECK([pspp -O format=csv lr-cat.sps], [0],
757  [dnl
758 Table: Dependent Variable Encoding
759 Original Value,Internal Value
760 4.000,0
761 9.000,1
762
763 Table: Case Processing Summary
764 Unweighted Cases,N,Percent
765 Included in Analysis,400,100.000
766 Missing Cases,0,.000
767 Total,400,100.000
768
769 note: Estimation terminated at iteration number 4 because parameter estimates changed by less than 0.001
770
771 Table: Model Summary
772 Step 1,-2 Log likelihood,Cox & Snell R Square,Nagelkerke R Square
773 ,458.517,.098,.138
774
775 Table: Categorical Variables' Codings
776 ,,,Parameter coding,,
777 ,,Frequency,(1),(2),(3)
778 bcat,1.000,61,1,0,0
779 ,2.000,151,0,1,0
780 ,3.000,121,0,0,1
781 ,4.000,67,0,0,0
782
783 Table: Classification Table
784 ,,,Predicted,,
785 ,,,y,,"Percentage
786 Correct"
787 ,Observed,,4.000,9.000,
788 Step 1,y,4.000,254,19,93.040
789 ,,9.000,97,30,23.622
790 ,Overall Percentage,,,,71.000
791
792 Table: Variables in the Equation
793 ,,B,S.E.,Wald,df,Sig.,Exp(B)
794 Step 1,b1,.002,.001,4.284,1,.038,1.002
795 ,b2,.804,.332,5.872,1,.015,2.235
796 ,bcat,,,20.895,3,.000,
797 ,bcat(1),1.551,.418,13.788,1,.000,4.718
798 ,bcat(2),.876,.367,5.706,1,.017,2.401
799 ,bcat(3),.211,.393,.289,1,.591,1.235
800 ,Constant,-5.541,1.138,23.709,1,.000,.004
801 ])
802
803 AT_CLEANUP
804
805
806
807 dnl  This example is inspired by http://www.ats.ucla.edu/stat/spss/output/logistic.htm
808 AT_SETUP([LOGISTIC REGRESSION with cat var 2])
809
810 AT_DATA([lr-cat2.data], [dnl
811      60.00     1.00      8.00     50.00 
812      47.00      .00      9.00     42.00 
813      57.00     1.00      7.00     53.00 
814      60.00      .00      8.00     53.00 
815      68.00      .00      8.00     66.00 
816      63.00      .00      8.00     55.00 
817      65.00      .00      8.00     63.00 
818      52.00      .00      8.00     61.00 
819      34.00      .00      9.00     42.00 
820      37.00      .00      8.00     39.00 
821      68.00     1.00      9.00     69.00 
822      60.00      .00      9.00     61.00 
823      44.00      .00      9.00     58.00 
824      42.00      .00      8.00     47.00 
825      57.00     1.00      7.00     61.00 
826      55.00     1.00      8.00     50.00 
827      55.00      .00      9.00     58.00 
828      44.00      .00      8.00     63.00 
829      50.00     1.00      9.00     66.00 
830      44.00      .00      8.00     39.00 
831      55.00      .00      8.00     58.00 
832      44.00      .00      8.00     50.00 
833      47.00     1.00      7.00     34.00 
834      48.00      .00      8.00     44.00 
835      45.00      .00      7.00     31.00 
836      43.00      .00      8.00     50.00 
837      39.00      .00      8.00     42.00 
838      63.00      .00      9.00     50.00 
839      47.00      .00      8.00     58.00 
840      42.00      .00      7.00     50.00 
841      50.00      .00      9.00     36.00 
842      47.00      .00      7.00     33.00 
843      60.00      .00      9.00     61.00 
844      47.00      .00      7.00     42.00 
845      68.00     1.00      9.00     69.00 
846      52.00      .00      8.00     54.00 
847      63.00     1.00      9.00     61.00 
848      65.00     1.00      9.00     61.00 
849      63.00     1.00      9.00     53.00 
850      57.00      .00      8.00     51.00 
851      34.00      .00      8.00     36.00 
852      50.00      .00      8.00     39.00 
853      52.00     1.00      7.00     56.00 
854      45.00      .00      7.00     34.00 
855      47.00     1.00      7.00     53.00 
856      34.00      .00      7.00     39.00 
857      50.00     1.00      8.00     55.00 
858      60.00      .00      9.00     58.00 
859      63.00      .00      8.00     58.00 
860      35.00      .00      7.00     51.00 
861      50.00      .00      8.00     58.00 
862      68.00      .00      8.00     63.00 
863      41.00      .00      9.00     34.00 
864      47.00      .00      8.00     47.00 
865      76.00      .00      9.00     64.00 
866      44.00      .00      8.00     44.00 
867      36.00      .00      9.00     50.00 
868      68.00     1.00      9.00     55.00 
869      47.00     1.00      8.00     50.00 
870      50.00      .00      7.00     53.00 
871      68.00      .00      8.00     74.00 
872      39.00      .00      7.00     44.00 
873      50.00      .00      8.00     55.00 
874      52.00      .00      9.00     61.00 
875      47.00      .00      8.00     53.00 
876      39.00      .00      7.00     47.00 
877      55.00     1.00      9.00     49.00 
878      68.00     1.00      8.00     50.00 
879      52.00     1.00      9.00     63.00 
880      55.00      .00      8.00     58.00 
881      57.00      .00      8.00     55.00 
882      66.00     1.00      9.00     61.00 
883      65.00     1.00      7.00     58.00 
884      42.00      .00      7.00     42.00 
885      68.00     1.00      7.00     59.00 
886      60.00     1.00      9.00     61.00 
887      52.00      .00      8.00     55.00 
888      57.00     1.00      7.00     54.00 
889      42.00      .00      9.00     50.00 
890      42.00      .00      8.00     47.00 
891      57.00      .00      8.00     50.00 
892      47.00      .00      7.00     45.00 
893      44.00      .00      7.00     40.00 
894      43.00      .00      9.00     55.00 
895      31.00      .00      8.00     39.00 
896      37.00      .00      7.00     33.00 
897      63.00     1.00      7.00     63.00 
898      47.00      .00      8.00     39.00 
899      57.00     1.00      8.00     63.00 
900      52.00      .00      8.00     44.00 
901      44.00      .00      7.00     35.00 
902      52.00      .00      7.00     55.00 
903      55.00      .00      7.00     69.00 
904      52.00      .00      8.00     53.00 
905      55.00      .00      9.00     61.00 
906      65.00     1.00      9.00     63.00 
907      55.00      .00      8.00     44.00 
908      63.00      .00      7.00     65.00 
909      44.00      .00      7.00     39.00 
910      47.00      .00      7.00     36.00 
911      63.00     1.00      9.00     55.00 
912      68.00      .00      8.00     66.00 
913      34.00      .00      8.00     39.00 
914      47.00      .00      9.00     50.00 
915      50.00      .00      9.00     58.00 
916      63.00      .00      8.00     66.00 
917      44.00      .00      7.00     34.00 
918      44.00      .00      8.00     50.00 
919      50.00      .00      8.00     53.00 
920      47.00     1.00      9.00     69.00 
921      65.00      .00      9.00     58.00 
922      57.00      .00      8.00     47.00 
923      39.00      .00      8.00     39.00 
924      47.00      .00      8.00     53.00 
925      50.00     1.00      7.00     63.00 
926      50.00      .00      8.00     50.00 
927      63.00      .00      9.00     53.00 
928      73.00     1.00      9.00     61.00 
929      44.00      .00      7.00     47.00 
930      47.00      .00      8.00     42.00 
931      47.00      .00      8.00     58.00 
932      36.00      .00      7.00     61.00 
933      57.00     1.00      8.00     55.00 
934      53.00     1.00      8.00     57.00 
935      63.00      .00      7.00     66.00 
936      50.00      .00      8.00     34.00 
937      47.00      .00      9.00     48.00 
938      57.00     1.00      8.00     58.00 
939      39.00      .00      8.00     53.00 
940      42.00      .00      8.00     42.00 
941      42.00      .00      9.00     31.00 
942      42.00      .00      8.00     72.00 
943      46.00      .00      8.00     44.00 
944      55.00      .00      8.00     42.00 
945      42.00      .00      8.00     47.00 
946      50.00      .00      8.00     44.00 
947      44.00      .00      9.00     39.00 
948      73.00     1.00      8.00     69.00 
949      71.00     1.00      9.00     58.00 
950      50.00      .00      9.00     49.00 
951      63.00     1.00      7.00     54.00 
952      42.00      .00      8.00     36.00 
953      47.00      .00      7.00     42.00 
954      39.00      .00      9.00     26.00 
955      63.00      .00      8.00     58.00 
956      50.00      .00      8.00     55.00 
957      65.00     1.00      8.00     55.00 
958      76.00     1.00      9.00     67.00 
959      71.00     1.00      8.00     66.00 
960      39.00      .00      9.00     47.00 
961      47.00     1.00      9.00     63.00 
962      60.00      .00      7.00     50.00 
963      63.00      .00      9.00     55.00 
964      54.00     1.00      9.00     55.00 
965      55.00     1.00      8.00     58.00 
966      57.00      .00      8.00     61.00 
967      55.00     1.00      9.00     63.00 
968      42.00      .00      7.00     50.00 
969      50.00      .00      8.00     44.00 
970      55.00      .00      8.00     42.00 
971      42.00      .00      7.00     50.00 
972      34.00      .00      8.00     39.00 
973      65.00      .00      9.00     46.00 
974      52.00      .00      7.00     58.00 
975      44.00      .00      8.00     39.00 
976      65.00     1.00      9.00     66.00 
977      47.00      .00      8.00     42.00 
978      41.00      .00      7.00     39.00 
979      68.00      .00      9.00     63.00 
980      63.00     1.00      8.00     72.00 
981      52.00      .00      8.00     53.00 
982      57.00      .00      8.00     50.00 
983      68.00      .00      8.00     55.00 
984      42.00      .00      8.00     56.00 
985      47.00      .00      8.00     48.00 
986      73.00     1.00      9.00     58.00 
987      39.00      .00      8.00     50.00 
988      63.00     1.00      9.00     69.00 
989      60.00      .00      8.00     55.00 
990      65.00     1.00      9.00     66.00 
991      73.00     1.00      8.00     63.00 
992      52.00      .00      8.00     55.00 
993      36.00      .00      8.00     42.00 
994      28.00      .00      7.00     44.00 
995      47.00      .00      8.00     44.00 
996      57.00      .00      7.00     47.00 
997      34.00      .00      7.00     29.00 
998      47.00      .00      9.00     66.00 
999      57.00      .00      8.00     58.00 
1000      60.00     1.00      9.00     50.00 
1001      50.00      .00      9.00     47.00 
1002      73.00     1.00      9.00     55.00 
1003      52.00     1.00      8.00     47.00 
1004      55.00      .00      8.00     53.00 
1005      47.00      .00      8.00     53.00 
1006      50.00      .00      8.00     61.00 
1007      61.00      .00      7.00     44.00 
1008      52.00      .00      9.00     53.00 
1009      47.00      .00      7.00     40.00 
1010      47.00      .00      7.00     50.00 
1011 ])
1012
1013 AT_DATA([stringcat.sps], [dnl
1014 set format=F20.3.
1015 data list notable file='lr-cat2.data' list /read honcomp wiz science *.
1016
1017 string ses(a1).
1018 recode wiz (7 = "a") (8 = "b") (9 = "c") into ses.
1019
1020 logistic regression honcomp with read science ses
1021          /categorical = ses.
1022
1023 ])
1024
1025 AT_CHECK([pspp -O format=csv stringcat.sps], [0],
1026  [dnl
1027 Table: Dependent Variable Encoding
1028 Original Value,Internal Value
1029 .000,0
1030 1.000,1
1031
1032 Table: Case Processing Summary
1033 Unweighted Cases,N,Percent
1034 Included in Analysis,200,100.000
1035 Missing Cases,0,.000
1036 Total,200,100.000
1037
1038 note: Estimation terminated at iteration number 5 because parameter estimates changed by less than 0.001
1039
1040 Table: Model Summary
1041 Step 1,-2 Log likelihood,Cox & Snell R Square,Nagelkerke R Square
1042 ,165.701,.280,.408
1043
1044 Table: Categorical Variables' Codings
1045 ,,,Parameter coding,
1046 ,,Frequency,(1),(2)
1047 ses,a,47,1,0
1048 ,b,95,0,1
1049 ,c,58,0,0
1050
1051 Table: Classification Table
1052 ,,,Predicted,,
1053 ,,,honcomp,,"Percentage
1054 Correct"
1055 ,Observed,,.000,1.000,
1056 Step 1,honcomp,.000,132,15,89.796
1057 ,,1.000,26,27,50.943
1058 ,Overall Percentage,,,,79.500
1059
1060 Table: Variables in the Equation
1061 ,,B,S.E.,Wald,df,Sig.,Exp(B)
1062 Step 1,read,.098,.025,15.199,1,.000,1.103
1063 ,science,.066,.027,5.867,1,.015,1.068
1064 ,ses,,,6.690,2,.035,
1065 ,ses(1),.058,.532,.012,1,.913,1.060
1066 ,ses(2),-1.013,.444,5.212,1,.022,.363
1067 ,Constant,-9.561,1.662,33.113,1,.000,.000
1068 ])
1069
1070 AT_CLEANUP
1071
1072
1073 dnl Check that it doesn't crash if a categorical variable
1074 dnl has only one distinct value
1075 AT_SETUP([LOGISTIC REGRESSION identical categories])
1076
1077 AT_DATA([crash.sps], [dnl
1078 data list notable list /y x1 x2*.
1079 begin data
1080 0 1 1
1081 1 2 1
1082 end data.
1083
1084 logistic regression y with x1 x2
1085         /categorical = x2.
1086 ])
1087
1088 AT_CHECK([pspp -O format=csv crash.sps], [1], [ignore])
1089
1090 AT_CLEANUP
1091
1092
1093 dnl Test that missing values on the categorical predictors are treated
1094 dnl properly.
1095 AT_SETUP([LOGISTIC REGRESSION missing categoricals])
1096
1097 AT_DATA([data.txt], [dnl
1098       .00     3.69      .00 
1099       .00     1.16     1.00 
1100      1.00   -12.99      .00 
1101       .00     2.97     1.00 
1102       .00    20.48      .00 
1103       .00     4.90      .00 
1104      1.00    -4.38      .00 
1105       .00    -1.69     1.00 
1106      1.00    -5.71      .00 
1107      1.00   -14.28      .00 
1108       .00     9.00      .00 
1109       .00     2.89     1.00 
1110       .00    13.51     1.00 
1111       .00    23.32     1.00 
1112       .00     2.31     1.00 
1113       .00    -2.07     1.00 
1114      1.00    -4.52     1.00 
1115      1.00    -5.83      .00 
1116      1.00    -1.91      .00 
1117      1.00   -11.12     1.00 
1118       .00    -1.51      .00 
1119       .00     6.59     1.00 
1120       .00    19.28     1.00 
1121       .00     5.94      .00 
1122       .00     8.21     1.00 
1123       .00     8.11     1.00 
1124       .00     2.49      .00 
1125       .00     9.62      .00 
1126      1.00   -20.74     1.00 
1127       .00    -1.41     1.00 
1128       .00    15.15     1.00 
1129       .00     9.39      .00 
1130      1.00   -15.14     1.00 
1131      1.00    -5.86      .00 
1132      1.00   -11.64     1.00 
1133      1.00   -14.36      .00 
1134      1.00    -8.95     1.00 
1135      1.00   -16.42     1.00 
1136      1.00    -1.04     1.00 
1137       .00    12.89     1.00 
1138       .00    -7.08     1.00 
1139       .00     4.87     1.00 
1140       .00    11.53     1.00 
1141      1.00    -6.24     1.00 
1142       .00     1.25     1.00 
1143       .00     4.39     1.00 
1144       .00     3.17      .00 
1145       .00    19.39     1.00 
1146       .00    13.03     1.00 
1147       .00     2.43      .00 
1148      1.00   -14.73     1.00 
1149       .00     8.25     1.00 
1150      1.00   -13.28     1.00 
1151       .00     5.27     1.00 
1152      1.00    -3.46     1.00 
1153       .00    13.81     1.00 
1154       .00     1.35     1.00 
1155      1.00    -3.94     1.00 
1156       .00    20.73     1.00 
1157      1.00   -15.40      .00 
1158      1.00   -11.01     1.00 
1159       .00     4.56      .00 
1160      1.00   -15.35     1.00 
1161       .00    15.21      .00 
1162       .00     5.34     1.00 
1163      1.00   -21.55     1.00 
1164       .00    10.12     1.00 
1165       .00     -.73     1.00 
1166       .00    15.28     1.00 
1167       .00    11.08     1.00 
1168      1.00    -8.24      .00 
1169       .00     2.46      .00 
1170       .00     9.60      .00 
1171       .00    11.24      .00 
1172       .00    14.13     1.00 
1173       .00    19.72     1.00 
1174       .00     5.58      .00 
1175       .00    26.23     1.00 
1176       .00     7.25      .00 
1177      1.00     -.79      .00 
1178       .00     6.24      .00 
1179      1.00     1.16      .00 
1180      1.00    -7.89     1.00 
1181      1.00    -1.86     1.00 
1182      1.00   -10.80     1.00 
1183      1.00    -5.51      .00 
1184       .00     7.51      .00 
1185       .00    11.18      .00 
1186       .00     8.73      .00 
1187      1.00   -11.21     1.00 
1188      1.00   -13.24      .00 
1189       .00    19.34      .00 
1190       .00     9.32     1.00 
1191       .00    17.97     1.00 
1192      1.00    -1.56     1.00 
1193      1.00    -3.13      .00 
1194       .00     3.98      .00 
1195       .00    -1.21     1.00 
1196       .00     2.37      .00 
1197      1.00   -18.03     1.00 
1198 ])
1199
1200 AT_DATA([miss.sps], [dnl
1201 data list notable  file='data.txt'  list /y x1 cat0*.
1202
1203 logistic regression y with x1 cat0
1204         /categorical = cat0.
1205 ])
1206
1207 AT_CHECK([pspp -O format=csv miss.sps > file1], [0], [ignore])
1208
1209 dnl Append a case with a missing categorical.
1210 AT_CHECK([echo '1  34   .' >> data.txt], [0], [ignore])
1211
1212 AT_CHECK([pspp -O format=csv miss.sps > file2], [0], [ignore])
1213
1214 AT_CHECK([diff file1 file2], [1], [dnl
1215 8,10c8,10
1216 < Included in Analysis,100,100.00
1217 < Missing Cases,0,.00
1218 < Total,100,100.00
1219 ---
1220 > Included in Analysis,100,99.01
1221 > Missing Cases,1,.99
1222 > Total,101,100.00
1223 ])
1224
1225 AT_CLEANUP
1226
1227
1228 dnl Check that the confidence intervals are properly reported.
1229 dnl Use an example with categoricals, because that was buggy at
1230 dnl one point.  The data in this example comes from:
1231 dnl  http://people.ysu.edu/~gchang/SPSSE/SPSS_lab2Regression.pdf
1232 AT_SETUP([LOGISTIC REGRESSION confidence interval])
1233
1234 AT_DATA([ci.sps], [dnl
1235 set FORMAT=F20.3
1236 data list notable list /disease age sciostat sector savings *.
1237 begin data.
1238 0       33        1        1        1 
1239 0       35        1        1        1 
1240 0        6        1        1        0 
1241 0       60        1        1        1 
1242 1       18        3        1        0 
1243 0       26        3        1        0 
1244 0        6        3        1        0 
1245 1       31        2        1        1 
1246 1       26        2        1        0 
1247 0       37        2        1        0 
1248 0       23        1        1        0 
1249 0       23        1        1        0 
1250 0       27        1        1        1 
1251 1        9        1        1        1 
1252 1       37        1        2        1 
1253 1       22        1        2        1 
1254 1       67        1        2        1 
1255 0        8        1        2        1 
1256 1        6        1        2        1 
1257 1       15        1        2        1 
1258 1       21        2        2        1 
1259 1       32        2        2        1 
1260 1       16        1        2        1 
1261 0       11        2        2        0 
1262 0       14        3        2        0 
1263 0        9        2        2        0 
1264 0       18        2        2        0 
1265 0        2        3        1        0 
1266 0       61        3        1        1 
1267 0       20        3        1        0 
1268 0       16        3        1        0 
1269 0        9        2        1        0 
1270 0       35        2        1        1 
1271 0        4        1        1        1 
1272 0       44        3        2        0 
1273 1       11        3        2        0 
1274 0        3        2        2        1 
1275 0        6        3        2        0 
1276 1       17        2        2        0 
1277 0        1        3        2        1 
1278 1       53        2        2        1 
1279 1       13        1        2        0 
1280 0       24        1        2        0 
1281 1       70        1        2        1 
1282 1       16        3        2        1 
1283 0       12        2        2        1 
1284 1       20        3        2        1 
1285 0       65        3        2        1 
1286 1       40        2        2        0 
1287 1       38        2        2        1 
1288 1       68        2        2        1 
1289 1       74        1        2        1 
1290 1       14        1        2        1 
1291 1       27        1        2        1 
1292 0       31        1        2        1 
1293 0       18        1        2        1 
1294 0       39        1        2        0 
1295 0       50        1        2        1 
1296 0       31        1        2        1 
1297 0       61        1        2        1 
1298 0       18        3        1        0 
1299 0        5        3        1        0 
1300 0        2        3        1        1 
1301 0       16        3        1        0 
1302 1       59        3        1        1 
1303 0       22        3        1        0 
1304 0       24        1        1        1 
1305 0       30        1        1        1 
1306 0       46        1        1        1 
1307 0       28        1        1        0 
1308 0       27        1        1        1 
1309 1       27        1        1        0 
1310 0       28        1        1        1 
1311 1       52        1        1        1 
1312 0       11        3        1        1 
1313 0        6        2        1        1 
1314 0       46        3        1        0 
1315 1       20        2        1        1 
1316 0        3        1        1        1 
1317 0       18        2        1        0 
1318 0       25        2        1        0 
1319 0        6        3        1        1 
1320 1       65        3        1        1 
1321 0       51        3        1        1 
1322 0       39        2        1        1 
1323 0        8        1        1        1 
1324 0        8        2        1        0 
1325 0       14        3        1        0 
1326 0        6        3        1        0 
1327 0        6        3        1        1 
1328 0        7        3        1        0 
1329 0        4        3        1        0 
1330 0        8        3        1        0 
1331 0        9        2        1        0 
1332 1       32        3        1        0 
1333 0       19        3        1        0 
1334 0       11        3        1        0 
1335 0       35        3        1        0 
1336 0       16        1        1        0 
1337 0        1        1        1        1 
1338 0        6        1        1        1 
1339 0       27        1        1        1 
1340 0       25        1        1        1 
1341 0       18        1        1        0 
1342 0       37        3        1        0 
1343 1       33        3        1        0 
1344 0       27        2        1        0 
1345 0        2        1        1        0 
1346 0        8        2        1        0 
1347 0        5        1        1        0 
1348 0        1        1        1        1 
1349 0       32        1        1        0 
1350 1       25        1        1        1 
1351 0       15        1        2        0 
1352 0       15        1        2        1 
1353 0       26        1        2        1 
1354 1       42        1        2        1 
1355 0        7        1        2        1 
1356 0        2        1        2        0 
1357 1       65        1        2        1 
1358 0       33        2        2        1 
1359 1        8        2        2        0 
1360 0       30        2        2        0 
1361 0        5        3        2        0 
1362 0       15        3        2        0 
1363 1       60        3        2        1 
1364 1       13        3        2        1 
1365 0       70        3        1        1 
1366 0        5        3        1        0 
1367 0        3        3        1        1 
1368 0       50        2        1        1 
1369 0        6        2        1        0 
1370 0       12        2        1        1 
1371 1       39        3        2        0 
1372 0       15        2        2        1 
1373 1       35        2        2        0 
1374 0        2        2        2        1 
1375 0       17        3        2        0 
1376 1       43        3        2        1 
1377 0       30        2        2        1 
1378 0       11        1        2        1 
1379 1       39        1        2        1 
1380 0       32        1        2        1 
1381 0       17        1        2        1 
1382 0        3        3        2        1 
1383 0        7        3        2        0 
1384 0        2        2        2        0 
1385 1       64        2        2        1 
1386 1       13        1        2        2 
1387 1       15        2        2        1 
1388 0       48        2        2        1 
1389 0       23        1        2        1 
1390 1       48        1        2        0 
1391 0       25        1        2        1 
1392 0       12        1        2        1 
1393 1       46        1        2        1 
1394 0       79        1        2        1 
1395 0       56        1        2        1 
1396 0        8        1        2        1 
1397 1       29        3        1        0 
1398 1       35        3        1        0 
1399 1       11        3        1        0 
1400 0       69        3        1        1 
1401 1       21        3        1        0 
1402 0       13        3        1        0 
1403 0       21        1        1        1 
1404 1       32        1        1        1 
1405 1       24        1        1        0 
1406 0       24        1        1        1 
1407 0       73        1        1        1 
1408 0       42        1        1        1 
1409 1       34        1        1        1 
1410 0       30        2        1        0 
1411 0        7        2        1        0 
1412 1       29        3        1        0 
1413 1       22        3        1        0 
1414 0       38        2        1        1 
1415 0       13        2        1        1 
1416 0       12        2        1        1 
1417 0       42        3        1        0 
1418 1       17        3        1        0 
1419 0       21        3        1        1 
1420 0       34        1        1        1 
1421 0        1        3        1        0 
1422 0       14        2        1        0 
1423 0       16        2        1        0 
1424 0        9        3        1        0 
1425 0       53        3        1        0 
1426 0       27        3        1        0 
1427 0       15        3        1        0 
1428 0        9        3        1        0 
1429 0        4        2        1        1 
1430 0       10        3        1        1 
1431 0       31        3        1        0 
1432 0       85        3        1        1 
1433 0       24        2        1        0 
1434 end data.
1435
1436 logistic regression 
1437     disease WITH age sciostat sector savings
1438     /categorical = sciostat sector
1439     /print = ci(95).
1440 ])
1441
1442 AT_CHECK([pspp -O format=csv ci.sps], [0], [dnl
1443 Table: Dependent Variable Encoding
1444 Original Value,Internal Value
1445 .000,0
1446 1.000,1
1447
1448 Table: Case Processing Summary
1449 Unweighted Cases,N,Percent
1450 Included in Analysis,196,100.000
1451 Missing Cases,0,.000
1452 Total,196,100.000
1453
1454 note: Estimation terminated at iteration number 4 because parameter estimates changed by less than 0.001
1455
1456 Table: Model Summary
1457 Step 1,-2 Log likelihood,Cox & Snell R Square,Nagelkerke R Square
1458 ,211.195,.120,.172
1459
1460 Table: Categorical Variables' Codings
1461 ,,,Parameter coding,
1462 ,,Frequency,(1),(2)
1463 sciostat,1.000,77,1,0
1464 ,2.000,49,0,1
1465 ,3.000,70,0,0
1466 sector,1.000,117,1,
1467 ,2.000,79,0,
1468
1469 Table: Classification Table
1470 ,,,Predicted,,
1471 ,,,disease,,"Percentage
1472 Correct"
1473 ,Observed,,.000,1.000,
1474 Step 1,disease,.000,131,8,94.245
1475 ,,1.000,41,16,28.070
1476 ,Overall Percentage,,,,75.000
1477
1478 Table: Variables in the Equation
1479 ,,,,,,,,95% CI for Exp(B),
1480 ,,B,S.E.,Wald,df,Sig.,Exp(B),Lower,Upper
1481 Step 1,age,.027,.009,8.647,1,.003,1.027,1.009,1.045
1482 ,savings,.061,.386,.025,1,.874,1.063,.499,2.264
1483 ,sciostat,,,.440,2,.803,,,
1484 ,sciostat(1),-.278,.434,.409,1,.522,.757,.323,1.775
1485 ,sciostat(2),-.219,.459,.227,1,.634,.803,.327,1.976
1486 ,sector,,,11.974,1,.001,,,
1487 ,sector(1),-1.235,.357,11.974,1,.001,.291,.145,.586
1488 ,Constant,-.814,.452,3.246,1,.072,.443,,
1489 ])
1490
1491 AT_CLEANUP
1492