1 /* PSPP - One way ANOVA. -*-c-*-
3 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 Author: John Darrington 2004
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #include <gsl/gsl_cdf.h>
30 #include "dictionary.h"
38 #include "value-labels.h"
43 #include "group_proc.h"
51 +missing=miss:!analysis/listwise,
52 incl:include/!exclude;
53 contrast= double list;
54 statistics[st_]=descriptives,homogeneity.
61 static int bad_weight_warn = 1;
64 static struct cmd_oneway cmd;
66 /* The independent variable */
67 static struct variable *indep_var;
69 /* Number of dependent variables */
72 /* The dependent variables */
73 static struct variable **vars;
76 /* A hash table containing all the distinct values of the independent
78 static struct hsh_table *global_group_hash ;
80 /* The number of distinct values of the independent variable, when all
81 missing values are disregarded */
82 static int ostensible_number_of_groups=-1;
85 /* Function to use for testing for missing values */
86 static is_missing_func value_is_missing;
89 static void run_oneway(const struct casefile *cf, void *_mode);
92 /* Routines to show the output tables */
93 static void show_anova_table(void);
94 static void show_descriptives(void);
95 static void show_homogeneity(void);
97 static void show_contrast_coeffs(short *);
98 static void show_contrast_tests(short *);
101 enum stat_table_t {STAT_DESC = 1, STAT_HOMO = 2};
103 static enum stat_table_t stat_tables ;
105 void output_oneway(void);
113 if ( !parse_oneway(&cmd) )
116 /* If /MISSING=INCLUDE is set, then user missing values are ignored */
117 if (cmd.incl == ONEWAY_INCLUDE )
118 value_is_missing = is_system_missing;
120 value_is_missing = is_missing;
122 /* What statistics were requested */
123 if ( cmd.sbc_statistics )
126 for (i = 0 ; i < ONEWAY_ST_count ; ++i )
128 if ( ! cmd.a_statistics[i] ) continue;
131 case ONEWAY_ST_DESCRIPTIVES:
132 stat_tables |= STAT_DESC;
134 case ONEWAY_ST_HOMOGENEITY:
135 stat_tables |= STAT_HOMO;
141 multipass_procedure_with_splits (run_oneway, &cmd);
153 short *bad_contrast ;
155 bad_contrast = xmalloc ( sizeof (short) * cmd.sbc_contrast );
157 /* Check the sanity of the given contrast values */
158 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
164 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
165 ostensible_number_of_groups )
168 _("Number of contrast coefficients must equal the number of groups"));
173 for (j=0; j < ostensible_number_of_groups ; ++j )
174 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
177 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
180 if ( stat_tables & STAT_DESC )
183 if ( stat_tables & STAT_HOMO )
188 if (cmd.sbc_contrast )
190 show_contrast_coeffs(bad_contrast);
191 show_contrast_tests(bad_contrast);
198 for (i = 0 ; i < n_vars ; ++i )
200 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
202 hsh_destroy(group_hash);
205 hsh_destroy(global_group_hash);
212 /* Parser for the variables sub command */
214 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
219 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
224 if (!parse_variables (default_dict, &vars, &n_vars,
226 | PV_NUMERIC | PV_NO_SCRATCH) )
234 if ( ! lex_match(T_BY))
238 indep_var = parse_variable();
242 msg(SE,_("`%s' is not a variable name"),tokid);
251 /* Show the ANOVA table */
253 show_anova_table(void)
257 int n_rows = n_vars * 3 + 1;
262 t = tab_create (n_cols,n_rows,0);
263 tab_headers (t, 2, 0, 1, 0);
264 tab_dim (t, tab_natural_dimensions);
271 n_cols - 1, n_rows - 1);
273 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
274 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
275 tab_vline (t, TAL_0, 1, 0, 0);
277 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
278 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
279 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
280 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
281 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
284 for ( i=0 ; i < n_vars ; ++i )
286 struct group_statistics *totals = &group_proc_get (vars[i])->ugs;
287 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
288 struct hsh_iterator g;
289 struct group_statistics *gs;
293 for (gs = hsh_first (group_hash,&g);
295 gs = hsh_next(group_hash,&g))
297 ssa += (gs->sum * gs->sum)/gs->n;
300 ssa -= ( totals->sum * totals->sum ) / totals->n ;
302 const char *s = var_to_string(vars[i]);
304 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
305 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
306 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
307 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
310 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
313 struct group_proc *gp = group_proc_get (vars[i]);
314 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
315 const double df1 = gp->n_groups - 1;
316 const double df2 = totals->n - gp->n_groups ;
317 const double msa = ssa / df1;
319 gp->mse = (sst - ssa) / df2;
322 /* Sums of Squares */
323 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
324 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
325 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
328 /* Degrees of freedom */
329 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
330 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
331 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
334 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
335 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
339 const double F = msa/gp->mse ;
342 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
344 /* The significance */
345 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
353 tab_title (t, 0, _("ANOVA"));
359 /* Show the descriptives table */
361 show_descriptives(void)
368 const double confidence=0.95;
369 const double q = (1.0 - confidence) / 2.0;
376 for ( v = 0 ; v < n_vars ; ++v )
377 n_rows += group_proc_get (vars[v])->n_groups + 1;
379 t = tab_create (n_cols,n_rows,0);
380 tab_headers (t, 2, 0, 2, 0);
381 tab_dim (t, tab_natural_dimensions);
384 /* Put a frame around the entire box, and vertical lines inside */
389 n_cols - 1, n_rows - 1);
391 /* Underline headers */
392 tab_hline (t, TAL_2, 0, n_cols - 1, 2 );
393 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
395 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
396 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
397 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
398 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
401 tab_vline(t, TAL_0, 7, 0, 0);
402 tab_hline(t, TAL_1, 6, 7, 1);
403 tab_joint_text (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, _("%g%% Confidence Interval for Mean"),confidence*100.0);
405 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
406 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
408 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
409 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
412 tab_title (t, 0, _("Descriptives"));
416 for ( v=0 ; v < n_vars ; ++v )
421 struct group_proc *gp = group_proc_get (vars[v]);
423 struct hsh_iterator g;
424 struct group_statistics *gs;
425 struct group_statistics *totals = &gp->ugs;
428 const char *s = var_to_string(vars[v]);
430 struct hsh_table *group_hash = gp->group_hash;
433 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
435 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
438 for (gs = hsh_first (group_hash,&g);
440 gs = hsh_next(group_hash,&g))
442 tab_text (t, 1, row + count,
443 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
445 /* Now fill in the numbers ... */
447 tab_float (t, 2, row + count, 0, gs->n, 8,0);
449 tab_float (t, 3, row + count, 0, gs->mean,8,2);
451 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
453 std_error = gs->std_dev/sqrt(gs->n) ;
454 tab_float (t, 5, row + count, 0,
457 /* Now the confidence interval */
459 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
461 tab_float(t, 6, row + count, 0,
462 gs->mean - T * std_error, 8, 2);
464 tab_float(t, 7, row + count, 0,
465 gs->mean + T * std_error, 8, 2);
469 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
470 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
475 tab_text (t, 1, row + count,
476 TAB_LEFT | TAT_TITLE ,_("Total"));
478 tab_float (t, 2, row + count, 0, totals->n, 8,0);
480 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
482 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
484 std_error = totals->std_dev/sqrt(totals->n) ;
486 tab_float (t, 5, row + count, 0, std_error, 8,2);
488 /* Now the confidence interval */
490 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
492 tab_float(t, 6, row + count, 0,
493 totals->mean - T * std_error, 8, 2);
495 tab_float(t, 7, row + count, 0,
496 totals->mean + T * std_error, 8, 2);
500 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
501 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
503 row += gp->n_groups + 1;
512 /* Show the homogeneity table */
514 show_homogeneity(void)
518 int n_rows = n_vars + 1;
523 t = tab_create (n_cols,n_rows,0);
524 tab_headers (t, 1, 0, 1, 0);
525 tab_dim (t, tab_natural_dimensions);
527 /* Put a frame around the entire box, and vertical lines inside */
532 n_cols - 1, n_rows - 1);
535 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
536 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
539 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
540 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
541 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
542 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
545 tab_title (t, 0, _("Test of Homogeneity of Variances"));
547 for ( v=0 ; v < n_vars ; ++v )
550 const struct variable *var = vars[v];
551 const struct group_proc *gp = group_proc_get (vars[v]);
552 const char *s = var_to_string(var);
553 const struct group_statistics *totals = &gp->ugs;
555 const double df1 = gp->n_groups - 1;
556 const double df2 = totals->n - gp->n_groups ;
558 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
561 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
562 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
563 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
565 /* Now the significance */
566 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
575 /* Show the contrast coefficients table */
577 show_contrast_coeffs(short *bad_contrast)
579 int n_cols = 2 + ostensible_number_of_groups;
580 int n_rows = 2 + cmd.sbc_contrast;
581 struct hsh_iterator g;
582 union value *group_value;
589 t = tab_create (n_cols,n_rows,0);
590 tab_headers (t, 2, 0, 2, 0);
591 tab_dim (t, tab_natural_dimensions);
593 /* Put a frame around the entire box, and vertical lines inside */
598 n_cols - 1, n_rows - 1);
614 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
617 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
618 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
621 tab_title (t, 0, _("Contrast Coefficients"));
623 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
627 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
628 var_to_string(indep_var));
630 for (group_value = hsh_first (global_group_hash,&g);
632 group_value = hsh_next(global_group_hash,&g))
636 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
637 value_to_string(group_value,indep_var));
639 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
642 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
644 if ( bad_contrast[i] )
645 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
647 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
648 subc_list_double_at(&cmd.dl_contrast[i],count)
660 /* Show the results of the contrast tests */
662 show_contrast_tests(short *bad_contrast)
666 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
670 t = tab_create (n_cols,n_rows,0);
671 tab_headers (t, 3, 0, 1, 0);
672 tab_dim (t, tab_natural_dimensions);
674 /* Put a frame around the entire box, and vertical lines inside */
679 n_cols - 1, n_rows - 1);
687 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
688 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
691 tab_title (t, 0, _("Contrast Tests"));
693 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
694 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
695 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
696 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
697 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
698 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
700 for ( v = 0 ; v < n_vars ; ++v )
703 int lines_per_variable = 2 * cmd.sbc_contrast;
706 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
707 var_to_string(vars[v]));
709 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
712 double contrast_value = 0.0;
713 double coef_msq = 0.0;
714 struct group_proc *grp_data = group_proc_get (vars[v]);
715 struct hsh_table *group_hash = grp_data->group_hash;
716 struct hsh_iterator g;
717 struct group_statistics *gs;
720 double std_error_contrast ;
725 /* Note: The calculation of the degrees of freedom in the variances
726 not equal case is painfull!!
727 The following formula may help to understand it:
728 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
731 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
736 double df_denominator = 0.0;
737 double df_numerator = 0.0;
742 tab_text (t, 1, (v * lines_per_variable) + i + 1,
743 TAB_LEFT | TAT_TITLE,
744 _("Assume equal variances"));
746 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
747 TAB_LEFT | TAT_TITLE,
748 _("Does not assume equal"));
751 tab_text (t, 2, (v * lines_per_variable) + i + 1,
752 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
755 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
756 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
759 if ( bad_contrast[i])
762 /* FIXME: Potential danger here.
763 We're ASSUMING THE array is in the order corresponding to the
765 for (ci = 0, gs = hsh_first (group_hash,&g);
767 ++ci, gs = hsh_next(group_hash,&g))
770 const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
771 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
773 contrast_value += coef * gs->mean;
775 coef_msq += (coef * coef) / gs->n ;
777 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
779 df_numerator += (coef * coef) * winv;
780 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
783 sec_vneq = sqrt(sec_vneq);
785 df_numerator = pow2(df_numerator);
787 tab_float (t, 3, (v * lines_per_variable) + i + 1,
788 TAB_RIGHT, contrast_value, 8,2);
790 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
792 TAB_RIGHT, contrast_value, 8,2);
794 std_error_contrast = sqrt(grp_data->mse * coef_msq);
797 tab_float (t, 4, (v * lines_per_variable) + i + 1,
798 TAB_RIGHT, std_error_contrast,
801 T = fabs(contrast_value / std_error_contrast) ;
805 tab_float (t, 5, (v * lines_per_variable) + i + 1,
809 df = grp_data->ugs.n - grp_data->n_groups;
811 /* Degrees of Freedom */
812 tab_float (t, 6, (v * lines_per_variable) + i + 1,
817 /* Significance TWO TAILED !!*/
818 tab_float (t, 7, (v * lines_per_variable) + i + 1,
819 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
823 /* Now for the Variances NOT Equal case */
827 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
832 T = contrast_value / sec_vneq;
834 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
839 df = df_numerator / df_denominator;
842 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
846 /* The Significance */
848 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
849 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
856 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
864 /* ONEWAY ANOVA Calculations */
866 static void postcalc ( struct cmd_oneway *cmd UNUSED );
868 static void precalc ( struct cmd_oneway *cmd UNUSED );
872 /* Pre calculations */
874 precalc ( struct cmd_oneway *cmd UNUSED )
878 for(i=0; i< n_vars ; ++i)
880 struct group_proc *gp = group_proc_get (vars[i]);
881 struct group_statistics *totals = &gp->ugs;
883 /* Create a hash for each of the dependent variables.
884 The hash contains a group_statistics structure,
885 and is keyed by value of the independent variable */
889 (hsh_compare_func *) compare_group,
890 (hsh_hash_func *) hash_group,
891 (hsh_free_func *) free_group,
892 (void *) indep_var->width );
899 totals->maximum = - DBL_MAX;
900 totals->minimum = DBL_MAX;
906 run_oneway(const struct casefile *cf, void *cmd_)
908 struct casereader *r;
911 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
913 global_group_hash = hsh_create(4,
914 (hsh_compare_func *) compare_values,
915 (hsh_hash_func *) hash_value,
917 (void *) indep_var->width );
920 for(r = casefile_get_reader (cf);
921 casereader_read (r, &c) ;
926 const double weight =
927 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
929 const union value *indep_val = case_data (&c, indep_var->fv);
931 /* Deal with missing values */
932 if ( value_is_missing(indep_val,indep_var) )
935 /* Skip the entire case if /MISSING=LISTWISE is set */
936 if ( cmd->miss == ONEWAY_LISTWISE )
938 for(i = 0; i < n_vars ; ++i)
940 const struct variable *v = vars[i];
941 const union value *val = case_data (&c, v->fv);
943 if (value_is_missing(val,v) )
952 hsh_insert ( global_group_hash, (void *) indep_val );
954 for ( i = 0 ; i < n_vars ; ++i )
956 const struct variable *v = vars[i];
958 const union value *val = case_data (&c, v->fv);
960 struct group_proc *gp = group_proc_get (vars[i]);
961 struct hsh_table *group_hash = gp->group_hash;
963 struct group_statistics *gs;
965 gs = hsh_find(group_hash, (void *) indep_val );
969 gs = (struct group_statistics *)
970 xmalloc (sizeof(struct group_statistics));
977 gs->minimum = DBL_MAX;
978 gs->maximum = -DBL_MAX;
980 hsh_insert ( group_hash, (void *) gs );
983 if (! value_is_missing(val,v) )
985 struct group_statistics *totals = &gp->ugs;
988 totals->sum+=weight * val->f;
989 totals->ssq+=weight * val->f * val->f;
991 if ( val->f * weight < totals->minimum )
992 totals->minimum = val->f * weight;
994 if ( val->f * weight > totals->maximum )
995 totals->maximum = val->f * weight;
998 gs->sum+=weight * val->f;
999 gs->ssq+=weight * val->f * val->f;
1001 if ( val->f * weight < gs->minimum )
1002 gs->minimum = val->f * weight;
1004 if ( val->f * weight > gs->maximum )
1005 gs->maximum = val->f * weight;
1008 gp->n_groups = hsh_count ( group_hash );
1012 casereader_destroy (r);
1017 if ( stat_tables & STAT_HOMO )
1018 levene(cf, indep_var, n_vars, vars,
1019 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1022 ostensible_number_of_groups = hsh_count (global_group_hash);
1031 /* Post calculations for the ONEWAY command */
1033 postcalc ( struct cmd_oneway *cmd UNUSED )
1038 for(i = 0; i < n_vars ; ++i)
1040 struct group_proc *gp = group_proc_get (vars[i]);
1041 struct hsh_table *group_hash = gp->group_hash;
1042 struct group_statistics *totals = &gp->ugs;
1044 struct hsh_iterator g;
1045 struct group_statistics *gs;
1047 for (gs = hsh_first (group_hash,&g);
1049 gs = hsh_next(group_hash,&g))
1051 gs->mean=gs->sum / gs->n;
1052 gs->s_std_dev= sqrt(
1053 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1058 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1061 gs->se_mean = gs->std_dev / sqrt(gs->n);
1062 gs->mean_diff= gs->sum_diff / gs->n;
1068 totals->mean = totals->sum / totals->n;
1069 totals->std_dev= sqrt(
1070 totals->n/(totals->n-1) *
1071 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1074 totals->se_mean = totals->std_dev / sqrt(totals->n);