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