RELIABILITY: Convert tests to Autotest framework.
[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$EXEEXT
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 . . 1  0
72 3 1 5  0
73 4 2 14 1
74 4 3 2  0
75 5 4 20 1
76 5 4 20 .
77 5 5 1  0
78 end data.
79
80 weight by w.
81
82 roc x by a (1)
83         /plot = none
84         /print = se coordinates
85         /criteria = testpos(large) distribution(free) ci(99)
86         /missing = exclude .
87
88 roc x y by a (1)
89         /plot = curve(reference)
90         /print = se coordinates
91         /criteria = testpos(large) distribution(negexpo) ci(95)
92         /missing = exclude .
93 EOF
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96 activity="run program"
97 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
98 if [ $? -ne 0 ] ; then no_result ; fi
99
100
101 activity="compare results"
102 diff -c $TEMPDIR/pspp.csv - << EOF
103 Table: Case Summary
104 ,Valid N (listwise),
105 a,Unweighted,Weighted
106 Positive,5,50.000
107 Negative,5,50.000
108
109 Table: Area Under the Curve (x)
110 ,,,Asymp. 99% Confidence Interval,
111 Area,Std. Error,Asymptotic Sig.,Lower Bound,Upper Bound
112 .910,.030,.000,.839,.981
113
114 Table: Coordinates of the Curve (x)
115 Positive if greater than or equal to,Sensitivity,1 - Specificity
116 .000,1.000,1.000
117 1.500,.960,.440
118 2.500,.880,.160
119 3.500,.680,.060
120 4.500,.400,.020
121 6.000,.000,.000
122
123 Table: Case Summary
124 ,Valid N (listwise),
125 a,Unweighted,Weighted
126 Positive,5,50.000
127 Negative,5,50.000
128
129 Table: Area Under the Curve
130 ,,,,Asymp. 95% Confidence Interval,
131 Variable under test,Area,Std. Error,Asymptotic Sig.,Lower Bound,Upper Bound
132 x,.910,.030,.000,.860,.960
133 y,.697,.052,.001,.611,.783
134
135 Table: Coordinates of the Curve
136 Test variable,Positive if greater than or equal to,Sensitivity,1 - Specificity
137 x,.000,1.000,1.000
138 ,1.500,.960,.440
139 ,2.500,.880,.160
140 ,3.500,.680,.060
141 ,4.500,.400,.020
142 ,6.000,.000,.000
143 y,.000,1.000,1.000
144 ,1.500,.960,.900
145 ,2.500,.680,.340
146 ,3.000,.600,.340
147 ,3.500,.600,.300
148 ,4.500,.200,.020
149 ,6.000,.000,.000
150 EOF
151 if [ $? -ne 0 ] ; then fail ; fi
152
153 pass