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;
293 const char *s = var_to_string(vars[i]);
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 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;
374 for ( v = 0 ; v < n_vars ; ++v )
375 n_rows += group_proc_get (vars[v])->n_groups + 1;
377 t = tab_create (n_cols,n_rows,0);
378 tab_headers (t, 2, 0, 2, 0);
379 tab_dim (t, tab_natural_dimensions);
382 /* Put a frame around the entire box, and vertical lines inside */
387 n_cols - 1, n_rows - 1);
389 /* Underline headers */
390 tab_hline (t, TAL_2, 0, n_cols - 1, 2 );
391 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
393 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
394 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
395 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
396 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
399 tab_vline(t, TAL_0, 7, 0, 0);
400 tab_hline(t, TAL_1, 6, 7, 1);
401 tab_joint_text (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, _("%g%% Confidence Interval for Mean"),confidence*100.0);
403 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
404 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
406 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
407 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
410 tab_title (t, 0, _("Descriptives"));
414 for ( v=0 ; v < n_vars ; ++v )
419 struct group_proc *gp = group_proc_get (vars[v]);
421 struct group_statistics *gs;
422 struct group_statistics *totals = &gp->ugs;
424 const char *s = var_to_string(vars[v]);
426 struct group_statistics **gs_array = hsh_sort(gp->group_hash);
429 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
431 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
433 for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
435 gs = gs_array[count];
437 tab_text (t, 1, row + count,
438 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
440 /* Now fill in the numbers ... */
442 tab_float (t, 2, row + count, 0, gs->n, 8,0);
444 tab_float (t, 3, row + count, 0, gs->mean,8,2);
446 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
448 std_error = gs->std_dev/sqrt(gs->n) ;
449 tab_float (t, 5, row + count, 0,
452 /* Now the confidence interval */
454 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
456 tab_float(t, 6, row + count, 0,
457 gs->mean - T * std_error, 8, 2);
459 tab_float(t, 7, row + count, 0,
460 gs->mean + T * std_error, 8, 2);
464 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
465 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
469 tab_text (t, 1, row + count,
470 TAB_LEFT | TAT_TITLE ,_("Total"));
472 tab_float (t, 2, row + count, 0, totals->n, 8,0);
474 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
476 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
478 std_error = totals->std_dev/sqrt(totals->n) ;
480 tab_float (t, 5, row + count, 0, std_error, 8,2);
482 /* Now the confidence interval */
484 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
486 tab_float(t, 6, row + count, 0,
487 totals->mean - T * std_error, 8, 2);
489 tab_float(t, 7, row + count, 0,
490 totals->mean + T * std_error, 8, 2);
494 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
495 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
497 row += gp->n_groups + 1;
506 /* Show the homogeneity table */
508 show_homogeneity(void)
512 int n_rows = n_vars + 1;
517 t = tab_create (n_cols,n_rows,0);
518 tab_headers (t, 1, 0, 1, 0);
519 tab_dim (t, tab_natural_dimensions);
521 /* Put a frame around the entire box, and vertical lines inside */
526 n_cols - 1, n_rows - 1);
529 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
530 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
533 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
534 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
535 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
536 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
539 tab_title (t, 0, _("Test of Homogeneity of Variances"));
541 for ( v=0 ; v < n_vars ; ++v )
544 const struct variable *var = vars[v];
545 const struct group_proc *gp = group_proc_get (vars[v]);
546 const char *s = var_to_string(var);
547 const struct group_statistics *totals = &gp->ugs;
549 const double df1 = gp->n_groups - 1;
550 const double df2 = totals->n - gp->n_groups ;
552 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
555 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
556 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
557 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
559 /* Now the significance */
560 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
569 /* Show the contrast coefficients table */
571 show_contrast_coeffs(short *bad_contrast)
573 int n_cols = 2 + ostensible_number_of_groups;
574 int n_rows = 2 + cmd.sbc_contrast;
575 union value *group_value;
577 void **group_values ;
581 t = tab_create (n_cols,n_rows,0);
582 tab_headers (t, 2, 0, 2, 0);
583 tab_dim (t, tab_natural_dimensions);
585 /* Put a frame around the entire box, and vertical lines inside */
590 n_cols - 1, n_rows - 1);
604 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
605 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
607 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
609 tab_title (t, 0, _("Contrast Coefficients"));
611 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
614 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
615 var_to_string(indep_var));
617 group_values = hsh_sort(global_group_hash);
619 count < hsh_count(global_group_hash) ;
623 group_value = group_values[count];
625 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
626 value_to_string(group_value, indep_var));
628 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
630 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
632 if ( bad_contrast[i] )
633 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
635 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
636 subc_list_double_at(&cmd.dl_contrast[i], count)
645 /* Show the results of the contrast tests */
647 show_contrast_tests(short *bad_contrast)
651 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
655 t = tab_create (n_cols,n_rows,0);
656 tab_headers (t, 3, 0, 1, 0);
657 tab_dim (t, tab_natural_dimensions);
659 /* Put a frame around the entire box, and vertical lines inside */
664 n_cols - 1, n_rows - 1);
672 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
673 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
676 tab_title (t, 0, _("Contrast Tests"));
678 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
679 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
680 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
681 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
682 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
683 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
685 for ( v = 0 ; v < n_vars ; ++v )
688 int lines_per_variable = 2 * cmd.sbc_contrast;
691 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
692 var_to_string(vars[v]));
694 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
697 double contrast_value = 0.0;
698 double coef_msq = 0.0;
699 struct group_proc *grp_data = group_proc_get (vars[v]);
700 struct hsh_table *group_hash = grp_data->group_hash;
702 void **group_stat_array;
705 double std_error_contrast ;
710 /* Note: The calculation of the degrees of freedom in the
711 "variances not equal" case is painfull!!
712 The following formula may help to understand it:
713 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
716 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
721 double df_denominator = 0.0;
722 double df_numerator = 0.0;
725 tab_text (t, 1, (v * lines_per_variable) + i + 1,
726 TAB_LEFT | TAT_TITLE,
727 _("Assume equal variances"));
729 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
730 TAB_LEFT | TAT_TITLE,
731 _("Does not assume equal"));
734 tab_text (t, 2, (v * lines_per_variable) + i + 1,
735 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
738 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
739 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
742 if ( bad_contrast[i])
745 group_stat_array = hsh_sort(group_hash);
747 for (ci = 0 ; ci < hsh_count(group_hash) ; ++ci)
749 const double coef = subc_list_double_at(&cmd.dl_contrast[i], ci);
750 struct group_statistics *gs = group_stat_array[ci];
752 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
754 contrast_value += coef * gs->mean;
756 coef_msq += (coef * coef) / gs->n ;
758 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
760 df_numerator += (coef * coef) * winv;
761 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
763 sec_vneq = sqrt(sec_vneq);
765 df_numerator = pow2(df_numerator);
767 tab_float (t, 3, (v * lines_per_variable) + i + 1,
768 TAB_RIGHT, contrast_value, 8,2);
770 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
772 TAB_RIGHT, contrast_value, 8,2);
774 std_error_contrast = sqrt(grp_data->mse * coef_msq);
777 tab_float (t, 4, (v * lines_per_variable) + i + 1,
778 TAB_RIGHT, std_error_contrast,
781 T = fabs(contrast_value / std_error_contrast) ;
785 tab_float (t, 5, (v * lines_per_variable) + i + 1,
789 df = grp_data->ugs.n - grp_data->n_groups;
791 /* Degrees of Freedom */
792 tab_float (t, 6, (v * lines_per_variable) + i + 1,
797 /* Significance TWO TAILED !!*/
798 tab_float (t, 7, (v * lines_per_variable) + i + 1,
799 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
803 /* Now for the Variances NOT Equal case */
807 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
812 T = contrast_value / sec_vneq;
814 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
819 df = df_numerator / df_denominator;
822 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
826 /* The Significance */
828 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
829 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
836 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
844 /* ONEWAY ANOVA Calculations */
846 static void postcalc ( struct cmd_oneway *cmd UNUSED );
848 static void precalc ( struct cmd_oneway *cmd UNUSED );
852 /* Pre calculations */
854 precalc ( struct cmd_oneway *cmd UNUSED )
858 for(i=0; i< n_vars ; ++i)
860 struct group_proc *gp = group_proc_get (vars[i]);
861 struct group_statistics *totals = &gp->ugs;
863 /* Create a hash for each of the dependent variables.
864 The hash contains a group_statistics structure,
865 and is keyed by value of the independent variable */
869 (hsh_compare_func *) compare_group,
870 (hsh_hash_func *) hash_group,
871 (hsh_free_func *) free_group,
872 (void *) indep_var->width );
879 totals->maximum = - DBL_MAX;
880 totals->minimum = DBL_MAX;
886 run_oneway(const struct casefile *cf, void *cmd_)
888 struct casereader *r;
891 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
893 global_group_hash = hsh_create(4,
894 (hsh_compare_func *) compare_values,
895 (hsh_hash_func *) hash_value,
897 (void *) indep_var->width );
900 for(r = casefile_get_reader (cf);
901 casereader_read (r, &c) ;
906 const double weight =
907 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
909 const union value *indep_val = case_data (&c, indep_var->fv);
911 /* Deal with missing values */
912 if ( value_is_missing(indep_val,indep_var) )
915 /* Skip the entire case if /MISSING=LISTWISE is set */
916 if ( cmd->miss == ONEWAY_LISTWISE )
918 for(i = 0; i < n_vars ; ++i)
920 const struct variable *v = vars[i];
921 const union value *val = case_data (&c, v->fv);
923 if (value_is_missing(val,v) )
932 hsh_insert ( global_group_hash, (void *) indep_val );
934 for ( i = 0 ; i < n_vars ; ++i )
936 const struct variable *v = vars[i];
938 const union value *val = case_data (&c, v->fv);
940 struct group_proc *gp = group_proc_get (vars[i]);
941 struct hsh_table *group_hash = gp->group_hash;
943 struct group_statistics *gs;
945 gs = hsh_find(group_hash, (void *) indep_val );
949 gs = (struct group_statistics *)
950 xmalloc (sizeof(struct group_statistics));
957 gs->minimum = DBL_MAX;
958 gs->maximum = -DBL_MAX;
960 hsh_insert ( group_hash, (void *) gs );
963 if (! value_is_missing(val,v) )
965 struct group_statistics *totals = &gp->ugs;
968 totals->sum+=weight * val->f;
969 totals->ssq+=weight * val->f * val->f;
971 if ( val->f * weight < totals->minimum )
972 totals->minimum = val->f * weight;
974 if ( val->f * weight > totals->maximum )
975 totals->maximum = val->f * weight;
978 gs->sum+=weight * val->f;
979 gs->ssq+=weight * val->f * val->f;
981 if ( val->f * weight < gs->minimum )
982 gs->minimum = val->f * weight;
984 if ( val->f * weight > gs->maximum )
985 gs->maximum = val->f * weight;
988 gp->n_groups = hsh_count ( group_hash );
992 casereader_destroy (r);
997 if ( stat_tables & STAT_HOMO )
998 levene(cf, indep_var, n_vars, vars,
999 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1002 ostensible_number_of_groups = hsh_count (global_group_hash);
1011 /* Post calculations for the ONEWAY command */
1013 postcalc ( struct cmd_oneway *cmd UNUSED )
1018 for(i = 0; i < n_vars ; ++i)
1020 struct group_proc *gp = group_proc_get (vars[i]);
1021 struct hsh_table *group_hash = gp->group_hash;
1022 struct group_statistics *totals = &gp->ugs;
1024 struct hsh_iterator g;
1025 struct group_statistics *gs;
1027 for (gs = hsh_first (group_hash,&g);
1029 gs = hsh_next(group_hash,&g))
1031 gs->mean=gs->sum / gs->n;
1032 gs->s_std_dev= sqrt(
1033 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1038 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1041 gs->se_mean = gs->std_dev / sqrt(gs->n);
1042 gs->mean_diff= gs->sum_diff / gs->n;
1048 totals->mean = totals->sum / totals->n;
1049 totals->std_dev= sqrt(
1050 totals->n/(totals->n-1) *
1051 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1054 totals->se_mean = totals->std_dev / sqrt(totals->n);