263d399e64b8b9297cad668a08a6a4b4c5cd45a8
[pspp-builds.git] / tests / command / roc.sh
1 #!/bin/sh
2
3 # This program tests  the ROC command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 set format F10.3.
64 data list notable list /x * y * w * a *.
65 begin data.
66 1 1 2  1
67 1 2 28 0
68 2 3 4  1
69 2 4 14 0
70 3 5 10 1
71 3 1 5  0
72 4 2 14 1
73 4 3 2  0
74 5 4 20 1
75 5 5 1  0
76 end data.
77
78 weight by w.
79
80 roc x by a (1)
81         /plot = none
82         /print = se coordinates
83         /criteria = testpos(large) distribution(free) ci(99)
84         /missing = exclude .
85
86 roc x y by a (1)
87         /plot = curve(reference)
88         /print = se coordinates
89         /criteria = testpos(large) distribution(negexpo) ci(95)
90         /missing = exclude .
91 EOF
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94 activity="run program"
95 $SUPERVISOR $PSPP --testing-mode $TESTFILE
96 if [ $? -ne 0 ] ; then no_result ; fi
97
98
99 activity="compare results"
100 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
101 diff -b  $TEMPDIR/pspp.list - << EOF
102 1.1 ROC.  Case Summary
103 #========#===================#
104 #        # Valid N (listwise)#
105 #        #==========#========#
106 #a       #Unweighted|Weighted#
107 #========#==========#========#
108 #Positive#         5|  50.000#
109 #Negative#         5|  50.000#
110 #========#==========#========#
111 1.2 ROC.  Area Under the Curve (x)
112 #====#==========#===============#=======================#
113 #    |          |               | Asymp. 99% Confidence #
114 #    |          |               +-----------+-----------#
115 #Area|Std. Error|Asymptotic Sig.|Lower Bound|Upper Bound#
116 #====#==========#===============#===========#===========#
117 #.910|      .030|           .000|       .839|       .981#
118 #====#==========#===============#===========#===========#
119 1.3 ROC.  Coordinates of the Curve (x)
120 #====================================#===========#===============#
121 #Positive if greater than or equal to|Sensitivity|1 - Specificity#
122 #====================================#===========#===============#
123 #                                .000|      1.000|          1.000#
124 #                               1.500|       .960|           .440#
125 #                               2.500|       .880|           .160#
126 #                               3.500|       .680|           .060#
127 #                               4.500|       .400|           .020#
128 #                               6.000|       .000|           .000#
129 #====================================#===========#===============#
130 2.1 ROC.  Case Summary
131 #========#===================#
132 #        # Valid N (listwise)#
133 #        #==========#========#
134 #a       #Unweighted|Weighted#
135 #========#==========#========#
136 #Positive#         5|  50.000#
137 #Negative#         5|  50.000#
138 #========#==========#========#
139 See pspp-1.png for a chart.
140 2.2 ROC.  Area Under the Curve
141 #===================#====#==========#===============#=======================#
142 #                   #    |          |               | Asymp. 95%            #
143 #                   #    |          |               +-----------+-----------#
144 #Variable under test#Area|Std. Error|Asymptotic Sig.|Lower Bound|Upper Bound#
145 #===================#====#==========#===============#===========#===========#
146 #                  x#.910|      .030|           .000|       .860|       .960#
147 #                  y#.697|      .052|           .001|       .611|       .783#
148 #===================#====#==========#===============#===========#===========#
149 2.3 ROC.  Coordinates of the Curve
150 #=============#====================================#===========#===============#
151 #Test variable#Positive if greater than or equal to|Sensitivity|1 - Specificity#
152 #=============#====================================#===========#===============#
153 #            x#                                .000|      1.000|          1.000#
154 #             #                               1.500|       .960|           .440#
155 #             #                               2.500|       .880|           .160#
156 #             #                               3.500|       .680|           .060#
157 #             #                               4.500|       .400|           .020#
158 #             #                               6.000|       .000|           .000#
159 #-------------#------------------------------------+-----------+---------------#
160 #            y#                                .000|      1.000|          1.000#
161 #             #                               1.500|       .960|           .900#
162 #             #                               2.500|       .680|           .340#
163 #             #                               3.000|       .600|           .340#
164 #             #                               3.500|       .600|           .300#
165 #             #                               4.500|       .200|           .020#
166 #             #                               6.000|       .000|           .000#
167 #=============#====================================#===========#===============#
168 EOF
169 if [ $? -ne 0 ] ; then fail ; fi
170
171 pass