projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Documented the EXAMINE subcommands. Fixed up the examine test. Fixed a problem...
[pspp]
/
src
/
levene.c
diff --git
a/src/levene.c
b/src/levene.c
index 4659f199ac018f98bd46886c2ad61d917ef24a88..11e7480acfc115f436d6a81e6d7c336a933f5352 100644
(file)
--- a/
src/levene.c
+++ b/
src/levene.c
@@
-24,6
+24,8
@@
#include "error.h"
#include "case.h"
#include "casefile.h"
#include "error.h"
#include "case.h"
#include "casefile.h"
+#include "dictionary.h"
+#include "group_proc.h"
#include "hash.h"
#include "str.h"
#include "var.h"
#include "hash.h"
#include "str.h"
#include "var.h"
@@
-159,13
+161,25
@@
levene_precalc (const struct levene_info *l)
lz = xmalloc (sizeof (struct lz_stats ) * l->n_dep ) ;
lz = xmalloc (sizeof (struct lz_stats ) * l->n_dep ) ;
- for(i
=
0; i < l->n_dep ; ++i )
+ for(i
=
0; i < l->n_dep ; ++i )
{
{
- struct variable *v = l->v_dep[i];
+ struct variable *var = l->v_dep[i];
+ struct group_proc *gp = group_proc_get (var);
+ struct group_statistics *gs;
+ struct hsh_iterator hi;
lz[i].grand_total = 0;
lz[i].total_n = 0;
lz[i].grand_total = 0;
lz[i].total_n = 0;
- lz[i].n_groups = v->p.grp_data.n_groups ;
+ lz[i].n_groups = gp->n_groups ;
+
+
+ for ( gs = hsh_first(gp->group_hash, &hi);
+ gs != 0;
+ gs = hsh_next(gp->group_hash, &hi))
+ {
+ gs->lz_total = 0;
+ }
+
}
}
}
}
@@
-201,11
+215,12
@@
levene_calc (const struct ccase *c, void *_l)
for (i = 0; i < l->n_dep; ++i)
{
struct variable *var = l->v_dep[i];
for (i = 0; i < l->n_dep; ++i)
{
struct variable *var = l->v_dep[i];
+ struct group_proc *gp = group_proc_get (var);
double levene_z;
const union value *v = case_data (c, var->fv);
struct group_statistics *gs;
double levene_z;
const union value *v = case_data (c, var->fv);
struct group_statistics *gs;
- gs = hsh_find(
var->p.grp_data.
group_hash,(void *) &key );
+ gs = hsh_find(
gp->
group_hash,(void *) &key );
if ( 0 == gs )
continue ;
if ( 0 == gs )
continue ;
@@
-218,6
+233,7
@@
levene_calc (const struct ccase *c, void *_l)
gs->lz_total += levene_z * weight;
}
gs->lz_total += levene_z * weight;
}
+
}
return 0;
}
}
return 0;
}
@@
-232,10
+248,11
@@
levene_postcalc (void *_l)
for (v = 0; v < l->n_dep; ++v)
{
for (v = 0; v < l->n_dep; ++v)
{
+ /* This is Z_LL */
lz[v].grand_mean = lz[v].grand_total / lz[v].total_n ;
lz[v].grand_mean = lz[v].grand_total / lz[v].total_n ;
-
}
}
+
}
}
@@
-258,14
+275,14
@@
levene2_precalc (void *_l)
struct group_statistics *g;
struct variable *var = l->v_dep[v] ;
struct group_statistics *g;
struct variable *var = l->v_dep[v] ;
- struct hsh_table *hash =
var->p.grp_data.
group_hash;
+ struct hsh_table *hash =
group_proc_get (var)->
group_hash;
for(g = (struct group_statistics *) hsh_first(hash,&hi);
g != 0 ;
g = (struct group_statistics *) hsh_next(hash,&hi) )
{
for(g = (struct group_statistics *) hsh_first(hash,&hi);
g != 0 ;
g = (struct group_statistics *) hsh_next(hash,&hi) )
{
- g->lz_mean = g->lz_total
/
g->n ;
+ g->lz_mean = g->lz_total
/
g->n ;
}
lz_denominator[v] = 0;
}
}
lz_denominator[v] = 0;
}
@@
-308,7
+325,7
@@
levene2_calc (const struct ccase *c, void *_l)
const union value *v = case_data (c, var->fv);
struct group_statistics *gs;
const union value *v = case_data (c, var->fv);
struct group_statistics *gs;
- gs = hsh_find(
var->p.grp_data.
group_hash,(void *) &key );
+ gs = hsh_find(
group_proc_get (var)->
group_hash,(void *) &key );
if ( 0 == gs )
continue;
if ( 0 == gs )
continue;
@@
-338,23
+355,21
@@
levene2_postcalc (void *_l)
struct group_statistics *g;
struct variable *var = l->v_dep[v] ;
struct group_statistics *g;
struct variable *var = l->v_dep[v] ;
- struct hsh_table *hash = var->p.grp_data.group_hash;
+ struct group_proc *gp = group_proc_get (var);
+ struct hsh_table *hash = gp->group_hash;
for(g = (struct group_statistics *) hsh_first(hash,&hi);
g != 0 ;
g = (struct group_statistics *) hsh_next(hash,&hi) )
{
for(g = (struct group_statistics *) hsh_first(hash,&hi);
g != 0 ;
g = (struct group_statistics *) hsh_next(hash,&hi) )
{
-
lz_numerator += g->n * pow2(g->lz_mean - lz[v].grand_mean );
lz_numerator += g->n * pow2(g->lz_mean - lz[v].grand_mean );
-
-
}
}
- lz_numerator *= ( l->v_dep[v]->p.grp_data.ugs.n -
- l->v_dep[v]->p.grp_data.n_groups );
+ lz_numerator *= ( gp->ugs.n - gp->n_groups );
+
+ lz_denominator[v] *= (gp->n_groups - 1);
+
+ gp->levene = lz_numerator / lz_denominator[v] ;
- lz_denominator[v] /= (l->v_dep[v]->p.grp_data.n_groups - 1);
-
- l->v_dep[v]->p.grp_data.levene = lz_numerator/lz_denominator[v] ;
}
/* Now clear up after ourselves */
}
/* Now clear up after ourselves */