+Fri Dec 24 15:09:11 WST 2004 John Darrington <john@darrington.wattle.id.au>
+
+ * t-test.q Fixed bug #11227 Made t-test work when the independent
+ variable is alpha
+
Sat Dec 11 11:43:45 WST 2004 John Darrington <john@darrington.wattle.id.au>
* factor_stats.c Fixed calculation of trimmed mean under various
static int compare_group_binary(const struct group_statistics *a,
const struct group_statistics *b,
- struct group_properties *p);
+ const struct group_properties *p);
static unsigned hash_group_binary(const struct group_statistics *g,
- struct group_properties *p);
+ const struct group_properties *p);
}
else
{
- msg (SE, _("When applying GROUPS to a string variable, at "
- "least one value must be specified."));
+ msg (SE, _("When applying GROUPS to a string variable, two "
+ "values must be specified."));
return 0;
}
}
- if (!parse_value (&gp.v.g_value[0],indep_var->type))
+ if (!parse_value (&gp.v.g_value[0], indep_var->type))
return 0;
lex_match (',');
if (lex_match (')'))
{
+ if (indep_var->type != NUMERIC)
+ {
+
+ msg (SE, _("When applying GROUPS to a string variable, two "
+ "values must be specified."));
+ return 0;
+ }
gp.criterion = CMP_LE;
gp.v.critical_value = gp.v.g_value[0].f;
return 1;
}
- if (!parse_value (&gp.v.g_value[1],indep_var->type))
+ if (!parse_value (&gp.v.g_value[1], indep_var->type))
return 0;
n_group_values = 2;
static int
compare_group_binary(const struct group_statistics *a,
const struct group_statistics *b,
- struct group_properties *p)
+ const struct group_properties *p)
{
short flag_a;
short flag_b;
- assert(p->indep_width == 0 ) ;
-
if ( p->criterion == CMP_LE )
{
+ assert(p->indep_width == 0 ) ;
flag_a = ( a->id.f < p->v.critical_value ) ;
flag_b = ( b->id.f < p->v.critical_value ) ;
}
flag_a = ( a->id.f == p->v.critical_value ) ;
flag_b = ( b->id.f == p->v.critical_value ) ;
}
-
if ( flag_a == flag_b)
return 0 ;
return ( flag_a < flag_b);
}
+/* This is a degenerate case of a hash, since it can only return three possible
+ values. It's really a comparison, being used as a hash function */
+
static unsigned
-hash_group_binary(const struct group_statistics *g, struct group_properties *p)
+hash_group_binary(const struct group_statistics *g,
+ const struct group_properties *p)
{
short flag = -1;
- assert(p->indep_width == 0 ) ;
-
- /* FIXME: should compare union values */
if ( p->criterion == CMP_LE )
{
+ /* Not meaningfull to do a less than compare for alpha values ? */
+ assert(p->indep_width == 0 ) ;
flag = ( g->id.f < p->v.critical_value ) ;
}
else if ( p->criterion == CMP_EQ)
{
- if ( g->id.f == p->v.g_value[0].f )
+ if ( 0 == compare_values (&g->id, &p->v.g_value[0], p->indep_width ))
flag = 0 ;
- else if ( g->id.f == p->v.g_value[1].f )
- flag = 1;
+ else if ( 0 == compare_values (&g->id, &p->v.g_value[1], p->indep_width ))
+ flag = 1 ;
else
- flag = 2;
+ flag = 2 ;
}
else
assert(0);
bugs/random.sh \
bugs/t-test-with-temp.sh \
bugs/t-test.sh \
+ bugs/t-test-alpha.sh \
+ bugs/t-test-alpha2.sh \
bugs/temporary.sh \
bugs/val-labs.sh \
bugs/recode-copy-bug.sh \
--- /dev/null
+#!/bin/sh
+
+# This program tests that the T-TEST works when the independent
+# variable is alpha
+# BUG #11227
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+ rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+ echo $activity
+ echo FAILED
+ cleanup;
+ exit 1;
+}
+
+
+no_result()
+{
+ echo $activity
+ echo NO RESULT;
+ cleanup;
+ exit 2;
+}
+
+pass()
+{
+ cleanup;
+ exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/out.stat <<EOF
+data list list /id * indep (a1) dep1 * dep2 *.
+begin data.
+1 'a' 1 3
+2 'a' 2 4
+3 'a' 2 4
+4 'a' 2 4
+5 'a' 3 5
+6 'b' 3 1
+7 'b' 4 2
+8 'b' 4 2
+9 'b' 4 2
+10 'b' 5 3
+11 'c' 2 2
+end data.
+
+
+t-test /GROUPS=indep('a','b') /var=dep1 dep2.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST. Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|ID |F8.0 |
+|INDEP |A1 |
+|DEP1 |F8.0 |
+|DEP2 |F8.0 |
++--------+------+
+
+2.1 T-TEST. Group Statistics
+#==========#=#====#==============#========#
+# INDEP|N|Mean|Std. Deviation|SE. Mean#
+#==========#=#====#==============#========#
+#DEP1 a |5|2.00| .707| .316#
+# b |5|4.00| .707| .316#
+#DEP2 a |5|4.00| .707| .316#
+# b |5|2.00| .707| .316#
+#==========#=#====#==============#========#
+
+2.2 T-TEST. Independent Samples Test
+#===============================#==========#===============================================================================#
+# # Levene's | t-test for Equality of Means #
+# #----+-----+------+-----+---------------+---------------+---------------------+------------#
+# # | | | | | | | 95% #
+# # | | | | | | +------+-----#
+# # F | Sig.| t | df |Sig. (2-tailed)|Mean Difference|Std. Error Difference| Lower|Upper#
+#===============================#====#=====#======#=====#===============#===============#=====================#======#=====#
+#DEP1Equal variances assumed #.000|1.000|-4.472| 8| .002| -2.000| .447|-3.031|-.969#
+# Equal variances not assumed# | |-4.472|8.000| .002| -2.000| .447|-3.031|-.969#
+#DEP2Equal variances assumed #.000|1.000| 4.472| 8| .002| 2.000| .447| .969|3.031#
+# Equal variances not assumed# | | 4.472|8.000| .002| 2.000| .447| .969|3.031#
+#===============================#====#=====#======#=====#===============#===============#=====================#======#=====#
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass
--- /dev/null
+#!/bin/sh
+
+# This program tests that the T-TEST fails gracefully when
+# a single alpha variable is specified for the independent variable
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+ rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+ echo $activity
+ echo FAILED
+ cleanup;
+ exit 1;
+}
+
+
+no_result()
+{
+ echo $activity
+ echo NO RESULT;
+ cleanup;
+ exit 2;
+}
+
+pass()
+{
+ cleanup;
+ exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/out.stat <<EOF
+data list list /id * indep (a1) dep1 * dep2 *.
+begin data.
+1 'a' 1 3
+2 'a' 2 4
+3 'a' 2 4
+4 'a' 2 4
+5 'a' 3 5
+6 'b' 3 1
+7 'b' 4 2
+8 'b' 4 2
+9 'b' 4 2
+10 'b' 5 3
+11 'c' 2 2
+end data.
+
+
+t-test /GROUPS=indep('a') /var=dep1 dep2.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat > /dev/null
+#invert v
+if [ $? -eq 0 ] ; then fail ; fi
+
+
+pass