360115f2e400fe6d5b6300e9725a5058ce778d16
[pspp-builds.git] / tests / command / regression.sh
1 #!/bin/sh
2
3 # This program tests that the REGRESSION command works.
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
21 cleanup()
22 {
23     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
24         echo Not cleaning $TEMPDIR;
25         return ; 
26     fi
27     cd /
28     rm -rf $TEMPDIR
29 }
30
31
32 fail()
33 {
34     echo $activity
35     echo FAILED
36     cleanup;
37     exit 1;
38 }
39
40
41 no_result()
42 {
43     echo $activity
44     echo NO RESULT;
45     cleanup;
46     exit 2;
47 }
48
49 pass()
50 {
51     cleanup;
52     exit 0;
53 }
54
55 mkdir -p $TEMPDIR
56
57 cd $TEMPDIR
58
59 activity="create program"
60 cat > $TESTFILE <<EOF
61 data list list / v0 to v2.
62 begin data
63  0.65377128  7.735648 -23.97588
64 -0.13087553  6.142625 -19.63854
65  0.34880368  7.651430 -25.26557
66  0.69249021  6.125125 -16.57090
67 -0.07368178  8.245789 -25.80001
68 -0.34404919  6.031540 -17.56743
69  0.75981559  9.832291 -28.35977
70 -0.46958313  5.343832 -16.79548
71 -0.06108490  8.838262 -29.25689
72  0.56154863  6.200189 -18.58219
73 end data
74 regression /variables=v0 v1 v2 /statistics defaults /dependent=v2 /method=enter /save=pred resid.
75 list.
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="run program"
81 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84 diff -c $TEMPDIR/pspp.csv - << EOF
85 Table: Reading free-form data from INLINE.
86 Variable,Format
87 v0,F8.0
88 v1,F8.0
89 v2,F8.0
90
91 Table: Model Summary
92 ,R,R Square,Adjusted R Square,Std. Error of the Estimate
93 ,.97,.94,.93,1.34
94
95 Table: ANOVA
96 ,,Sum of Squares,df,Mean Square,F,Significance
97 ,Regression,202.75,2,101.38,56.75,.00
98 ,Residual,12.50,7,1.79,,
99 ,Total,215.26,9,,,
100
101 Table: Coefficients
102 ,,B,Std. Error,Beta,t,Significance
103 ,(Constant),2.19,2.36,.00,.93,.52
104 ,v0,1.81,1.05,.17,1.72,.12
105 ,v1,-3.43,.33,-1.03,-10.33,.00
106 ,,,,,,
107
108 Table: Data List
109 v0,v1,v2,RES1,PRED1
110 .65,7.74,-23.98,-.84,-23.13
111 -.13,6.14,-19.64,-.54,-19.10
112 .35,7.65,-25.27,-1.87,-23.40
113 .69,6.13,-16.57,.97,-17.54
114 -.07,8.25,-25.80,.40,-26.20
115 -.34,6.03,-17.57,1.53,-19.10
116 .76,9.83,-28.36,1.77,-30.13
117 -.47,5.34,-16.80,.18,-16.97
118 -.06,8.84,-29.26,-1.05,-28.21
119 .56,6.20,-18.58,-.54,-18.04
120 EOF
121 if [ $? -ne 0 ] ; then fail ; fi
122
123 pass