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 diff $TEMPDIR/pspp.list - << EOF
100 +--------#----------+----------+--------+
101 | #Observed N|Expected N|Residual|
102 +--------#----------+----------+--------+
103 | 1.00# 3| 2.33| .67|
104 | 2.00# 3| 2.33| .67|
105 | 3.10# 4| 2.33| 1.67|
106 | 3.20# 1| 2.33| -1.33|
107 | 4.00# 2| 2.33| -.33|
108 | 5.00# 1| 2.33| -1.33|
110 +--------#----------+----------+--------+
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 +--------#----------+----------+--------+
123 1.3 NPAR TESTS. Test Statistics
124 +-----------#-----+-----+
126 +-----------#-----+-----+
127 |Chi-Square #3.143|6.000|
129 |Asymp. Sig.# .678| .112|
130 +-----------#-----+-----+
133 +--------#----------+----------+--------+
134 | #Observed N|Expected N|Residual|
135 +--------#----------+----------+--------+
136 | 1.00# 7| 2.63| 4.38|
137 | 2.00# 4| 3.50| .50|
138 | 3.00# 1| 4.38| -3.38|
139 | 4.00# 2| 3.50| -1.50|
141 +--------#----------+----------+--------+
143 2.2 NPAR TESTS. Test Statistics
152 3.1 NPAR TESTS. Frequencies
153 +-----#---------------------------------------#---------------------------------------+
155 | #--------+----------+----------+--------#--------+----------+----------+--------+
156 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
157 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
158 |1 # 2.00| 3| 3.16| -.16# 2.00| 4| 2.21| 1.79|
159 |2 # 3.00| 5| 5.26| -.26# 3.00| 1| 3.68| -2.68|
160 |3 # 4.00| 2| 1.58| .42# 4.00| 2| 1.11| .89|
161 |Total# | 10| | # | 7| | |
162 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
164 3.2 NPAR TESTS. Test Statistics
165 +-----------#----+-----+
167 +-----------#----+-----+
168 |Chi-Square #.133|4.129|
170 |Asymp. Sig.#.936| .127|
171 +-----------#----+-----+
174 if [ $? -ne 0 ] ; then fail ; fi
177 activity="create file 2"
178 cat <<EOF > $TESTFILE
179 DATA LIST NOTABLE LIST /x * y * w *.
194 /EXPECTED = 3 4 5 4 3 1
197 if [ $? -ne 0 ] ; then no_result ; fi
200 activity="run program 2"
201 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/output
202 if [ $? -eq 0 ] ; then no_result ; fi
204 activity="compare errors 2"
205 diff $TEMPDIR/output - << EOF
206 error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y.
208 if [ $? -ne 0 ] ; then fail ; fi
211 activity="create file 3"
212 cat <<EOF > $TESTFILE
213 DATA LIST NOTABLE LIST /x * y * w * .
227 MISSING VALUES x (4).
232 /STATISTICS=DESCRIPTIVES
235 if [ $? -ne 0 ] ; then no_result ; fi
238 activity="run program 3"
239 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
240 if [ $? -ne 0 ] ; then no_result ; fi
243 activity="compare output 3"
244 diff $TEMPDIR/pspp.list - <<EOF
245 1.1 NPAR TESTS. Frequencies
246 +-----#---------------------------------------#---------------------------------------+
248 | #--------+----------+----------+--------#--------+----------+----------+--------+
249 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
250 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
251 |1 # -2.00| 0| 1.50| -1.50# -2.00| 0| 1.88| -1.88|
252 |2 # -1.00| 0| 1.50| -1.50# -1.00| 0| 1.88| -1.88|
253 |3 # .00| 0| 1.50| -1.50# .00| 0| 1.88| -1.88|
254 |4 # 1.00| 3| 1.50| 1.50# 1.00| 7| 1.88| 5.13|
255 |5 # 2.00| 3| 1.50| 1.50# 2.00| 4| 1.88| 2.13|
256 |6 # 3.00| 5| 1.50| 3.50# 3.00| 1| 1.88| -.88|
257 |7 # 4.00| 0| 1.50| -1.50# 4.00| 2| 1.88| .13|
258 |8 # 5.00| 1| 1.50| -.50# 5.00| 1| 1.88| -.88|
259 |Total# | 12| | # | 15| | |
260 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
262 1.2 NPAR TESTS. Test Statistics
263 +-----------#------+------+
265 +-----------#------+------+
266 |Chi-Square #17.333|22.867|
268 |Asymp. Sig.# .015| .002|
269 +-----------#------+------+
271 1.3 NPAR TESTS. Descriptive Statistics
272 +-#--+-----+-----+-----+-----+
273 | # N| Mean| Std.|Minim|Maxim|
274 | # | |Devia| um | um |
275 #=#==#=====#=====#=====#=====#
276 |x#12|2.467|1.193|1.000|5.000|
277 |y#15|2.067|1.335|1.000|5.000|
278 +-#--+-----+-----+-----+-----+
281 if [ $? -ne 0 ] ; then fail ; fi
284 activity="create file 4"
285 cat <<EOF > $TESTFILE
286 DATA LIST NOTABLE LIST /x * y * w * .
300 * MISSING VALUES x (4).
305 /STATISTICS=DESCRIPTIVES
308 if [ $? -ne 0 ] ; then no_result ; fi
311 activity="run program 4"
312 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
313 if [ $? -ne 0 ] ; then no_result ; fi
316 activity="compare output 4"
317 diff $TEMPDIR/pspp.list - <<EOF
318 1.1 NPAR TESTS. Frequencies
319 +-----#---------------------------------------#---------------------------------------+
321 | #--------+----------+----------+--------#--------+----------+----------+--------+
322 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
323 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
324 |1 # -2.00| 0| 1.75| -1.75# -2.00| 0| 1.75| -1.75|
325 |2 # -1.00| 0| 1.75| -1.75# -1.00| 0| 1.75| -1.75|
326 |3 # .00| 0| 1.75| -1.75# .00| 0| 1.75| -1.75|
327 |4 # 1.00| 3| 1.75| 1.25# 1.00| 7| 1.75| 5.25|
328 |5 # 2.00| 3| 1.75| 1.25# 2.00| 4| 1.75| 2.25|
329 |6 # 3.00| 5| 1.75| 3.25# 3.00| 1| 1.75| -.75|
330 |7 # 4.00| 2| 1.75| .25# 4.00| 2| 1.75| .25|
331 |8 # 5.00| 1| 1.75| -.75# 5.00| 0| 1.75| -1.75|
332 |Total# | 14| | # | 14| | |
333 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
335 1.2 NPAR TESTS. Test Statistics
336 +-----------#------+------+
338 +-----------#------+------+
339 |Chi-Square #13.429|26.000|
341 |Asymp. Sig.# .062| .001|
342 +-----------#------+------+
344 1.3 NPAR TESTS. Descriptive Statistics
345 +-#--+-----+-----+-----+-----+
346 | # N| Mean| Std.|Minim|Maxim|
347 | # | |Devia| um | um |
348 #=#==#=====#=====#=====#=====#
349 |x#14|2.686|1.231|1.000|5.000|
350 |y#14|1.857|1.099|1.000|4.000|
351 +-#--+-----+-----+-----+-----+
354 if [ $? -ne 0 ] ; then fail ; fi