3 # This program tests the chisquare subcommand of the NPAR command.
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_srcdir and top_builddir are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
60 activity="create file 1"
62 DATA LIST NOTABLE LIST /x * y * w *.
90 if [ $? -ne 0 ] ; then no_result ; fi
93 activity="run program 1"
94 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
95 if [ $? -ne 0 ] ; then no_result ; fi
97 activity="compare output 1"
98 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
99 diff $TEMPDIR/pspp.list - << EOF
101 +--------#----------+----------+--------+
102 | #Observed N|Expected N|Residual|
103 +--------#----------+----------+--------+
104 | 1.00# 3| 2.33| .67|
105 | 2.00# 3| 2.33| .67|
106 | 3.10# 4| 2.33| 1.67|
107 | 3.20# 1| 2.33| -1.33|
108 | 4.00# 2| 2.33| -.33|
109 | 5.00# 1| 2.33| -1.33|
111 +--------#----------+----------+--------+
113 +--------#----------+----------+--------+
114 | #Observed N|Expected N|Residual|
115 +--------#----------+----------+--------+
116 | 1.00# 7| 3.50| 3.50|
117 | 2.00# 4| 3.50| .50|
118 | 3.00# 1| 3.50| -2.50|
119 | 4.00# 2| 3.50| -1.50|
121 +--------#----------+----------+--------+
122 1.3 NPAR TESTS. Test Statistics
123 +-----------#-----+-----+
125 +-----------#-----+-----+
126 |Chi-Square #3.143|6.000|
128 |Asymp. Sig.# .678| .112|
129 +-----------#-----+-----+
131 +--------#----------+----------+--------+
132 | #Observed N|Expected N|Residual|
133 +--------#----------+----------+--------+
134 | 1.00# 7| 2.63| 4.38|
135 | 2.00# 4| 3.50| .50|
136 | 3.00# 1| 4.38| -3.38|
137 | 4.00# 2| 3.50| -1.50|
139 +--------#----------+----------+--------+
140 2.2 NPAR TESTS. Test Statistics
148 3.1 NPAR TESTS. Frequencies
149 +-----#---------------------------------------#---------------------------------------+
151 | #--------+----------+----------+--------#--------+----------+----------+--------+
152 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
153 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
154 |1 # 2.00| 3| 3.16| -.16# 2.00| 4| 2.21| 1.79|
155 |2 # 3.00| 5| 5.26| -.26# 3.00| 1| 3.68| -2.68|
156 |3 # 4.00| 2| 1.58| .42# 4.00| 2| 1.11| .89|
157 |Total# | 10| | # | 7| | |
158 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
159 3.2 NPAR TESTS. Test Statistics
160 +-----------#----+-----+
162 +-----------#----+-----+
163 |Chi-Square #.133|4.129|
165 |Asymp. Sig.#.936| .127|
166 +-----------#----+-----+
168 if [ $? -ne 0 ] ; then fail ; fi
171 activity="create file 2"
172 cat <<EOF > $TESTFILE
173 DATA LIST NOTABLE LIST /x * y * w *.
188 /EXPECTED = 3 4 5 4 3 1
191 if [ $? -ne 0 ] ; then no_result ; fi
194 activity="run program 2"
195 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/output
196 if [ $? -eq 0 ] ; then no_result ; fi
198 activity="compare errors 2"
199 perl -pi -e 's/^\s*$//g' $TEMPDIR/output
200 diff $TEMPDIR/output - << EOF
201 error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y.
203 if [ $? -ne 0 ] ; then fail ; fi
206 activity="create file 3"
207 cat <<EOF > $TESTFILE
208 DATA LIST NOTABLE LIST /x * y * w * .
222 MISSING VALUES x (4).
227 /STATISTICS=DESCRIPTIVES
230 if [ $? -ne 0 ] ; then no_result ; fi
233 activity="run program 3"
234 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
235 if [ $? -ne 0 ] ; then no_result ; fi
238 activity="compare output 3"
239 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
240 diff $TEMPDIR/pspp.list - <<EOF
241 1.1 NPAR TESTS. Frequencies
242 +-----#---------------------------------------#---------------------------------------+
244 | #--------+----------+----------+--------#--------+----------+----------+--------+
245 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
246 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
247 |1 # -2.00| 0| 1.50| -1.50# -2.00| 0| 1.88| -1.88|
248 |2 # -1.00| 0| 1.50| -1.50# -1.00| 0| 1.88| -1.88|
249 |3 # .00| 0| 1.50| -1.50# .00| 0| 1.88| -1.88|
250 |4 # 1.00| 3| 1.50| 1.50# 1.00| 7| 1.88| 5.13|
251 |5 # 2.00| 3| 1.50| 1.50# 2.00| 4| 1.88| 2.13|
252 |6 # 3.00| 5| 1.50| 3.50# 3.00| 1| 1.88| -.88|
253 |7 # 4.00| 0| 1.50| -1.50# 4.00| 2| 1.88| .13|
254 |8 # 5.00| 1| 1.50| -.50# 5.00| 1| 1.88| -.88|
255 |Total# | 12| | # | 15| | |
256 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
257 1.2 NPAR TESTS. Test Statistics
258 +-----------#------+------+
260 +-----------#------+------+
261 |Chi-Square #17.333|22.867|
263 |Asymp. Sig.# .015| .002|
264 +-----------#------+------+
265 1.3 NPAR TESTS. Descriptive Statistics
266 +-#--+-----+-----+-----+-----+
267 | # N| Mean| Std.|Minim|Maxim|
268 | # | |Devia| um | um |
269 #=#==#=====#=====#=====#=====#
270 |x#12|2.467|1.193|1.000|5.000|
271 |y#15|2.067|1.335|1.000|5.000|
272 +-#--+-----+-----+-----+-----+
274 if [ $? -ne 0 ] ; then fail ; fi
277 activity="create file 4"
278 cat <<EOF > $TESTFILE
279 DATA LIST NOTABLE LIST /x * y * w * .
293 * MISSING VALUES x (4).
298 /STATISTICS=DESCRIPTIVES
301 if [ $? -ne 0 ] ; then no_result ; fi
304 activity="run program 4"
305 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
306 if [ $? -ne 0 ] ; then no_result ; fi
309 activity="compare output 4"
310 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
311 diff $TEMPDIR/pspp.list - <<EOF
312 1.1 NPAR TESTS. Frequencies
313 +-----#---------------------------------------#---------------------------------------+
315 | #--------+----------+----------+--------#--------+----------+----------+--------+
316 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
317 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
318 |1 # -2.00| 0| 1.75| -1.75# -2.00| 0| 1.75| -1.75|
319 |2 # -1.00| 0| 1.75| -1.75# -1.00| 0| 1.75| -1.75|
320 |3 # .00| 0| 1.75| -1.75# .00| 0| 1.75| -1.75|
321 |4 # 1.00| 3| 1.75| 1.25# 1.00| 7| 1.75| 5.25|
322 |5 # 2.00| 3| 1.75| 1.25# 2.00| 4| 1.75| 2.25|
323 |6 # 3.00| 5| 1.75| 3.25# 3.00| 1| 1.75| -.75|
324 |7 # 4.00| 2| 1.75| .25# 4.00| 2| 1.75| .25|
325 |8 # 5.00| 1| 1.75| -.75# 5.00| 0| 1.75| -1.75|
326 |Total# | 14| | # | 14| | |
327 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
328 1.2 NPAR TESTS. Test Statistics
329 +-----------#------+------+
331 +-----------#------+------+
332 |Chi-Square #13.429|26.000|
334 |Asymp. Sig.# .062| .001|
335 +-----------#------+------+
336 1.3 NPAR TESTS. Descriptive Statistics
337 +-#--+-----+-----+-----+-----+
338 | # N| Mean| Std.|Minim|Maxim|
339 | # | |Devia| um | um |
340 #=#==#=====#=====#=====#=====#
341 |x#14|2.686|1.231|1.000|5.000|
342 |y#14|1.857|1.099|1.000|4.000|
343 +-#--+-----+-----+-----+-----+
345 if [ $? -ne 0 ] ; then fail ; fi