#include "libpspp/misc.h"
#include "libpspp/hmap.h"
#include "data/value.h"
+#include "data/val-type.h"
#include <gl/xalloc.h>
#include <assert.h>
/* Width of the categorical variable */
int gvw ;
- /* The value deviding the the groups. Valid only for dichotomous categorical variable.*/
+ /* The value dividing the groups. Valid only for dichotomous categorical variable.*/
const union value *cutpoint;
{
if (nl->cmp (nl, &l->group, target))
break;
- l = NULL;
}
return l;
}
/* Data accumulation. First pass */
-void
+void
levene_pass_one (struct levene *nl, double value, double weight, const union value *gv)
{
struct lev *lev = find_group (nl, gv);
- if ( nl->pass == 0 )
+ if ( nl->pass == 0 )
{
nl->pass = 1;
}
}
/* Data accumulation. Second pass */
-void
+void
levene_pass_two (struct levene *nl, double value, double weight, const union value *gv)
{
struct lev *lev = NULL;
}
/* Data accumulation. Third pass */
-void
+void
levene_pass_three (struct levene *nl, double value, double weight, const union value *gv)
{
double z;
double numerator = 0.0;
double nn = 0.0;
- if ( nl->pass == 3 )
- {
- nl->pass = 4;
- }
- assert (nl->pass == 4);
+ /* The Levene calculation requires three passes.
+ Normally this should have been done prior to calling this function.
+ However, in abnormal circumstances (eg. the dataset is empty) there
+ will have been no passes.
+ */
+ assert (nl->pass == 0 || nl->pass == 3);
+
+ if ( nl->pass == 0 )
+ return SYSMIS;
nl->denominator *= hmap_count (&nl->hmap) - 1;
}
numerator *= nn - hmap_count (&nl->hmap);
-
+
return numerator / nl->denominator;
}