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., 51 Franklin Street, Fifth Floor, 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);
155 short *bad_contrast ;
157 bad_contrast = xmalloc ( sizeof (short) * cmd.sbc_contrast );
159 /* Check the sanity of the given contrast values */
160 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
166 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
167 ostensible_number_of_groups )
170 _("Number of contrast coefficients must equal the number of groups"));
175 for (j=0; j < ostensible_number_of_groups ; ++j )
176 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
179 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
182 if ( stat_tables & STAT_DESC )
185 if ( stat_tables & STAT_HOMO )
190 if (cmd.sbc_contrast )
192 show_contrast_coeffs(bad_contrast);
193 show_contrast_tests(bad_contrast);
200 for (i = 0 ; i < n_vars ; ++i )
202 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
204 hsh_destroy(group_hash);
207 hsh_destroy(global_group_hash);
214 /* Parser for the variables sub command */
216 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
221 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
226 if (!parse_variables (default_dict, &vars, &n_vars,
228 | PV_NUMERIC | PV_NO_SCRATCH) )
236 if ( ! lex_match(T_BY))
240 indep_var = parse_variable();
244 msg(SE,_("`%s' is not a variable name"),tokid);
253 /* Show the ANOVA table */
255 show_anova_table(void)
259 int n_rows = n_vars * 3 + 1;
264 t = tab_create (n_cols,n_rows,0);
265 tab_headers (t, 2, 0, 1, 0);
266 tab_dim (t, tab_natural_dimensions);
273 n_cols - 1, n_rows - 1);
275 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
276 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
277 tab_vline (t, TAL_0, 1, 0, 0);
279 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
280 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
281 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
282 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
283 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
286 for ( i=0 ; i < n_vars ; ++i )
288 struct group_statistics *totals = &group_proc_get (vars[i])->ugs;
289 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
290 struct hsh_iterator g;
291 struct group_statistics *gs;
295 for (gs = hsh_first (group_hash,&g);
297 gs = hsh_next(group_hash,&g))
299 ssa += (gs->sum * gs->sum)/gs->n;
302 ssa -= ( totals->sum * totals->sum ) / totals->n ;
304 const char *s = var_to_string(vars[i]);
306 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
307 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
308 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
309 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
312 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
315 struct group_proc *gp = group_proc_get (vars[i]);
316 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
317 const double df1 = gp->n_groups - 1;
318 const double df2 = totals->n - gp->n_groups ;
319 const double msa = ssa / df1;
321 gp->mse = (sst - ssa) / df2;
324 /* Sums of Squares */
325 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
326 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
327 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
330 /* Degrees of freedom */
331 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
332 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
333 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
336 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
337 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
341 const double F = msa/gp->mse ;
344 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
346 /* The significance */
347 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
355 tab_title (t, 0, _("ANOVA"));
361 /* Show the descriptives table */
363 show_descriptives(void)
370 const double confidence=0.95;
371 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 group_statistics *gs;
424 struct group_statistics *totals = &gp->ugs;
426 const char *s = var_to_string(vars[v]);
428 struct group_statistics **gs_array = hsh_sort(gp->group_hash);
431 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
433 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
435 for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
437 gs = gs_array[count];
439 tab_text (t, 1, row + count,
440 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
442 /* Now fill in the numbers ... */
444 tab_float (t, 2, row + count, 0, gs->n, 8,0);
446 tab_float (t, 3, row + count, 0, gs->mean,8,2);
448 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
450 std_error = gs->std_dev/sqrt(gs->n) ;
451 tab_float (t, 5, row + count, 0,
454 /* Now the confidence interval */
456 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
458 tab_float(t, 6, row + count, 0,
459 gs->mean - T * std_error, 8, 2);
461 tab_float(t, 7, row + count, 0,
462 gs->mean + T * std_error, 8, 2);
466 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
467 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
471 tab_text (t, 1, row + count,
472 TAB_LEFT | TAT_TITLE ,_("Total"));
474 tab_float (t, 2, row + count, 0, totals->n, 8,0);
476 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
478 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
480 std_error = totals->std_dev/sqrt(totals->n) ;
482 tab_float (t, 5, row + count, 0, std_error, 8,2);
484 /* Now the confidence interval */
486 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
488 tab_float(t, 6, row + count, 0,
489 totals->mean - T * std_error, 8, 2);
491 tab_float(t, 7, row + count, 0,
492 totals->mean + T * std_error, 8, 2);
496 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
497 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
499 row += gp->n_groups + 1;
508 /* Show the homogeneity table */
510 show_homogeneity(void)
514 int n_rows = n_vars + 1;
519 t = tab_create (n_cols,n_rows,0);
520 tab_headers (t, 1, 0, 1, 0);
521 tab_dim (t, tab_natural_dimensions);
523 /* Put a frame around the entire box, and vertical lines inside */
528 n_cols - 1, n_rows - 1);
531 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
532 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
535 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
536 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
537 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
538 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
541 tab_title (t, 0, _("Test of Homogeneity of Variances"));
543 for ( v=0 ; v < n_vars ; ++v )
546 const struct variable *var = vars[v];
547 const struct group_proc *gp = group_proc_get (vars[v]);
548 const char *s = var_to_string(var);
549 const struct group_statistics *totals = &gp->ugs;
551 const double df1 = gp->n_groups - 1;
552 const double df2 = totals->n - gp->n_groups ;
554 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
557 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
558 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
559 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
561 /* Now the significance */
562 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
571 /* Show the contrast coefficients table */
573 show_contrast_coeffs(short *bad_contrast)
575 int n_cols = 2 + ostensible_number_of_groups;
576 int n_rows = 2 + cmd.sbc_contrast;
577 union value *group_value;
579 void **group_values ;
583 t = tab_create (n_cols,n_rows,0);
584 tab_headers (t, 2, 0, 2, 0);
585 tab_dim (t, tab_natural_dimensions);
587 /* Put a frame around the entire box, and vertical lines inside */
592 n_cols - 1, n_rows - 1);
606 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
607 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
609 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
611 tab_title (t, 0, _("Contrast Coefficients"));
613 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
616 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
617 var_to_string(indep_var));
619 group_values = hsh_sort(global_group_hash);
621 count < hsh_count(global_group_hash) ;
625 group_value = group_values[count];
627 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
628 value_to_string(group_value, indep_var));
630 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
632 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
634 if ( bad_contrast[i] )
635 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
637 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
638 subc_list_double_at(&cmd.dl_contrast[i], count)
647 /* Show the results of the contrast tests */
649 show_contrast_tests(short *bad_contrast)
653 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
657 t = tab_create (n_cols,n_rows,0);
658 tab_headers (t, 3, 0, 1, 0);
659 tab_dim (t, tab_natural_dimensions);
661 /* Put a frame around the entire box, and vertical lines inside */
666 n_cols - 1, n_rows - 1);
674 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
675 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
678 tab_title (t, 0, _("Contrast Tests"));
680 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
681 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
682 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
683 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
684 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
685 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
687 for ( v = 0 ; v < n_vars ; ++v )
690 int lines_per_variable = 2 * cmd.sbc_contrast;
693 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
694 var_to_string(vars[v]));
696 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
699 double contrast_value = 0.0;
700 double coef_msq = 0.0;
701 struct group_proc *grp_data = group_proc_get (vars[v]);
702 struct hsh_table *group_hash = grp_data->group_hash;
703 struct group_statistics *gs;
704 void **group_stat_array;
707 double std_error_contrast ;
712 /* Note: The calculation of the degrees of freedom in the
713 "variances not equal" case is painfull!!
714 The following formula may help to understand it:
715 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
718 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
723 double df_denominator = 0.0;
724 double df_numerator = 0.0;
727 tab_text (t, 1, (v * lines_per_variable) + i + 1,
728 TAB_LEFT | TAT_TITLE,
729 _("Assume equal variances"));
731 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
732 TAB_LEFT | TAT_TITLE,
733 _("Does not assume equal"));
736 tab_text (t, 2, (v * lines_per_variable) + i + 1,
737 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
740 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
741 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
744 if ( bad_contrast[i])
747 group_stat_array = hsh_sort(group_hash);
749 for (ci = 0 ; ci < hsh_count(group_hash) ; ++ci)
751 gs = group_stat_array[ci];
753 const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
754 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
756 contrast_value += coef * gs->mean;
758 coef_msq += (coef * coef) / gs->n ;
760 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
762 df_numerator += (coef * coef) * winv;
763 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
765 sec_vneq = sqrt(sec_vneq);
767 df_numerator = pow2(df_numerator);
769 tab_float (t, 3, (v * lines_per_variable) + i + 1,
770 TAB_RIGHT, contrast_value, 8,2);
772 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
774 TAB_RIGHT, contrast_value, 8,2);
776 std_error_contrast = sqrt(grp_data->mse * coef_msq);
779 tab_float (t, 4, (v * lines_per_variable) + i + 1,
780 TAB_RIGHT, std_error_contrast,
783 T = fabs(contrast_value / std_error_contrast) ;
787 tab_float (t, 5, (v * lines_per_variable) + i + 1,
791 df = grp_data->ugs.n - grp_data->n_groups;
793 /* Degrees of Freedom */
794 tab_float (t, 6, (v * lines_per_variable) + i + 1,
799 /* Significance TWO TAILED !!*/
800 tab_float (t, 7, (v * lines_per_variable) + i + 1,
801 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
805 /* Now for the Variances NOT Equal case */
809 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
814 T = contrast_value / sec_vneq;
816 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
821 df = df_numerator / df_denominator;
824 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
828 /* The Significance */
830 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
831 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
838 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
846 /* ONEWAY ANOVA Calculations */
848 static void postcalc ( struct cmd_oneway *cmd UNUSED );
850 static void precalc ( struct cmd_oneway *cmd UNUSED );
854 /* Pre calculations */
856 precalc ( struct cmd_oneway *cmd UNUSED )
860 for(i=0; i< n_vars ; ++i)
862 struct group_proc *gp = group_proc_get (vars[i]);
863 struct group_statistics *totals = &gp->ugs;
865 /* Create a hash for each of the dependent variables.
866 The hash contains a group_statistics structure,
867 and is keyed by value of the independent variable */
871 (hsh_compare_func *) compare_group,
872 (hsh_hash_func *) hash_group,
873 (hsh_free_func *) free_group,
874 (void *) indep_var->width );
881 totals->maximum = - DBL_MAX;
882 totals->minimum = DBL_MAX;
888 run_oneway(const struct casefile *cf, void *cmd_)
890 struct casereader *r;
893 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
895 global_group_hash = hsh_create(4,
896 (hsh_compare_func *) compare_values,
897 (hsh_hash_func *) hash_value,
899 (void *) indep_var->width );
902 for(r = casefile_get_reader (cf);
903 casereader_read (r, &c) ;
908 const double weight =
909 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
911 const union value *indep_val = case_data (&c, indep_var->fv);
913 /* Deal with missing values */
914 if ( value_is_missing(indep_val,indep_var) )
917 /* Skip the entire case if /MISSING=LISTWISE is set */
918 if ( cmd->miss == ONEWAY_LISTWISE )
920 for(i = 0; i < n_vars ; ++i)
922 const struct variable *v = vars[i];
923 const union value *val = case_data (&c, v->fv);
925 if (value_is_missing(val,v) )
934 hsh_insert ( global_group_hash, (void *) indep_val );
936 for ( i = 0 ; i < n_vars ; ++i )
938 const struct variable *v = vars[i];
940 const union value *val = case_data (&c, v->fv);
942 struct group_proc *gp = group_proc_get (vars[i]);
943 struct hsh_table *group_hash = gp->group_hash;
945 struct group_statistics *gs;
947 gs = hsh_find(group_hash, (void *) indep_val );
951 gs = (struct group_statistics *)
952 xmalloc (sizeof(struct group_statistics));
959 gs->minimum = DBL_MAX;
960 gs->maximum = -DBL_MAX;
962 hsh_insert ( group_hash, (void *) gs );
965 if (! value_is_missing(val,v) )
967 struct group_statistics *totals = &gp->ugs;
970 totals->sum+=weight * val->f;
971 totals->ssq+=weight * val->f * val->f;
973 if ( val->f * weight < totals->minimum )
974 totals->minimum = val->f * weight;
976 if ( val->f * weight > totals->maximum )
977 totals->maximum = val->f * weight;
980 gs->sum+=weight * val->f;
981 gs->ssq+=weight * val->f * val->f;
983 if ( val->f * weight < gs->minimum )
984 gs->minimum = val->f * weight;
986 if ( val->f * weight > gs->maximum )
987 gs->maximum = val->f * weight;
990 gp->n_groups = hsh_count ( group_hash );
994 casereader_destroy (r);
999 if ( stat_tables & STAT_HOMO )
1000 levene(cf, indep_var, n_vars, vars,
1001 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1004 ostensible_number_of_groups = hsh_count (global_group_hash);
1013 /* Post calculations for the ONEWAY command */
1015 postcalc ( struct cmd_oneway *cmd UNUSED )
1020 for(i = 0; i < n_vars ; ++i)
1022 struct group_proc *gp = group_proc_get (vars[i]);
1023 struct hsh_table *group_hash = gp->group_hash;
1024 struct group_statistics *totals = &gp->ugs;
1026 struct hsh_iterator g;
1027 struct group_statistics *gs;
1029 for (gs = hsh_first (group_hash,&g);
1031 gs = hsh_next(group_hash,&g))
1033 gs->mean=gs->sum / gs->n;
1034 gs->s_std_dev= sqrt(
1035 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1040 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1043 gs->se_mean = gs->std_dev / sqrt(gs->n);
1044 gs->mean_diff= gs->sum_diff / gs->n;
1050 totals->mean = totals->sum / totals->n;
1051 totals->std_dev= sqrt(
1052 totals->n/(totals->n-1) *
1053 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1056 totals->se_mean = totals->std_dev / sqrt(totals->n);