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