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