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>
37 #include "value-labels.h"
42 #include "group_proc.h"
49 +missing=miss:!analysis/listwise,
50 incl:include/!exclude;
51 contrast= double list;
52 statistics[st_]=descriptives,homogeneity.
59 static int bad_weight_warn = 1;
62 static struct cmd_oneway cmd;
64 /* The independent variable */
65 static struct variable *indep_var;
67 /* Number of dependent variables */
70 /* The dependent variables */
71 static struct variable **vars;
74 /* A hash table containing all the distinct values of the independent
76 static struct hsh_table *global_group_hash ;
78 /* The number of distinct values of the independent variable, when all
79 missing values are disregarded */
80 static int ostensible_number_of_groups=-1;
83 /* Function to use for testing for missing values */
84 static is_missing_func value_is_missing;
87 static void calculate(const struct casefile *cf, void *_mode);
90 /* Routines to show the output tables */
91 static void show_anova_table(void);
92 static void show_descriptives(void);
93 static void show_homogeneity(void);
94 static void show_contrast_coeffs(void);
95 static void show_contrast_tests(void);
98 enum stat_table_t {STAT_DESC, STAT_HOMO};
100 static enum stat_table_t stat_tables ;
108 if ( !parse_oneway(&cmd) )
111 /* If /MISSING=INCLUDE is set, then user missing values are ignored */
112 if (cmd.incl == ONEWAY_INCLUDE )
113 value_is_missing = is_system_missing;
115 value_is_missing = is_missing;
117 /* What statistics were requested */
118 if ( cmd.sbc_statistics )
121 for (i = 0 ; i < ONEWAY_ST_count ; ++i )
123 if ( ! cmd.a_statistics[i] ) continue;
126 case ONEWAY_ST_DESCRIPTIVES:
127 stat_tables |= STAT_DESC;
129 case ONEWAY_ST_HOMOGENEITY:
130 stat_tables |= STAT_HOMO;
136 multipass_procedure_with_splits (calculate, &cmd);
138 /* Check the sanity of the given contrast values */
139 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
144 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
145 ostensible_number_of_groups )
148 _("Number of contrast coefficients must equal the number of groups"));
152 for (j=0; j < ostensible_number_of_groups ; ++j )
153 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
156 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
159 if ( stat_tables & STAT_DESC )
162 if ( stat_tables & STAT_HOMO )
167 if (cmd.sbc_contrast)
169 show_contrast_coeffs();
170 show_contrast_tests();
175 for (i = 0 ; i < n_vars ; ++i )
177 struct hsh_table *group_hash = vars[i]->p.grp_data.group_hash;
179 hsh_destroy(group_hash);
182 hsh_destroy(global_group_hash);
191 /* Parser for the variables sub command */
193 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
198 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
203 if (!parse_variables (default_dict, &vars, &n_vars,
205 | PV_NUMERIC | PV_NO_SCRATCH) )
213 if ( ! lex_match(T_BY))
217 indep_var = parse_variable();
221 msg(SE,_("`%s' is not a variable name"),tokid);
230 /* Show the ANOVA table */
232 show_anova_table(void)
236 int n_rows = n_vars * 3 + 1;
241 t = tab_create (n_cols,n_rows,0);
242 tab_headers (t, 2, 0, 1, 0);
243 tab_dim (t, tab_natural_dimensions);
250 n_cols - 1, n_rows - 1);
252 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
253 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
254 tab_vline (t, TAL_0, 1, 0, 0);
256 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
257 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
258 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
259 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
260 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
263 for ( i=0 ; i < n_vars ; ++i )
265 struct group_statistics *totals = &vars[i]->p.grp_data.ugs;
266 struct hsh_table *group_hash = vars[i]->p.grp_data.group_hash;
267 struct hsh_iterator g;
268 struct group_statistics *gs;
272 for (gs = hsh_first (group_hash,&g);
274 gs = hsh_next(group_hash,&g))
276 ssa += (gs->sum * gs->sum)/gs->n;
279 ssa -= ( totals->sum * totals->sum ) / totals->n ;
281 const char *s = (vars[i]->label) ? vars[i]->label : vars[i]->name;
284 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
285 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
286 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
287 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
290 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
293 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
294 const double df1 = vars[i]->p.grp_data.n_groups - 1;
295 const double df2 = totals->n - vars[i]->p.grp_data.n_groups ;
296 const double msa = ssa / df1;
298 vars[i]->p.grp_data.mse = (sst - ssa) / df2;
301 /* Sums of Squares */
302 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
303 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
304 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
307 /* Degrees of freedom */
308 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
309 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
310 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
313 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
314 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, vars[i]->p.grp_data.mse, 8, 3);
318 const double F = msa/vars[i]->p.grp_data.mse ;
321 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
323 /* The significance */
324 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
332 tab_title (t, 0, _("ANOVA"));
338 /* Show the descriptives table */
340 show_descriptives(void)
347 const double confidence=0.95;
348 const double q = (1.0 - confidence) / 2.0;
355 for ( v = 0 ; v < n_vars ; ++v )
356 n_rows += vars[v]->p.grp_data.n_groups + 1;
358 t = tab_create (n_cols,n_rows,0);
359 tab_headers (t, 2, 0, 2, 0);
360 tab_dim (t, tab_natural_dimensions);
363 /* Put a frame around the entire box, and vertical lines inside */
368 n_cols - 1, n_rows - 1);
370 /* Underline headers */
371 tab_hline (t, TAL_2, 0, n_cols - 1, 2 );
372 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
374 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
375 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
376 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
377 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
380 tab_vline(t, TAL_0, 7, 0, 0);
381 tab_hline(t, TAL_1, 6, 7, 1);
382 tab_joint_text (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, _("%g%% Confidence Interval for Mean"),confidence*100.0);
384 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
385 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
387 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
388 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
391 tab_title (t, 0, _("Descriptives"));
395 for ( v=0 ; v < n_vars ; ++v )
401 struct hsh_iterator g;
402 struct group_statistics *gs;
403 struct group_statistics *totals = &vars[v]->p.grp_data.ugs;
406 char *s = (vars[v]->label) ? vars[v]->label : vars[v]->name;
408 struct hsh_table *group_hash = vars[v]->p.grp_data.group_hash;
411 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
413 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
416 for (gs = hsh_first (group_hash,&g);
418 gs = hsh_next(group_hash,&g))
420 const char *s = val_labs_find(indep_var->val_labs, gs->id );
423 tab_text (t, 1, row + count,
424 TAB_LEFT | TAT_TITLE ,s);
425 else if ( indep_var->width != 0 )
426 tab_text (t, 1, row + count,
427 TAB_LEFT | TAT_TITLE, gs->id.s);
429 tab_text (t, 1, row + count,
430 TAB_LEFT | TAT_TITLE | TAT_PRINTF, "%g", gs->id.f);
433 /* Now fill in the numbers ... */
435 tab_float (t, 2, row + count, 0, gs->n, 8,0);
437 tab_float (t, 3, row + count, 0, gs->mean,8,2);
439 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
441 std_error = gs->std_dev/sqrt(gs->n) ;
442 tab_float (t, 5, row + count, 0,
445 /* Now the confidence interval */
447 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
449 tab_float(t, 6, row + count, 0,
450 gs->mean - T * std_error, 8, 2);
452 tab_float(t, 7, row + count, 0,
453 gs->mean + T * std_error, 8, 2);
457 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
458 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
463 tab_text (t, 1, row + count,
464 TAB_LEFT | TAT_TITLE ,_("Total"));
466 tab_float (t, 2, row + count, 0, totals->n, 8,0);
468 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
470 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
472 std_error = totals->std_dev/sqrt(totals->n) ;
474 tab_float (t, 5, row + count, 0, std_error, 8,2);
476 /* Now the confidence interval */
478 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
480 tab_float(t, 6, row + count, 0,
481 totals->mean - T * std_error, 8, 2);
483 tab_float(t, 7, row + count, 0,
484 totals->mean + T * std_error, 8, 2);
488 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
489 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
491 row += vars[v]->p.grp_data.n_groups + 1;
500 /* Show the homogeneity table */
502 show_homogeneity(void)
506 int n_rows = n_vars + 1;
511 t = tab_create (n_cols,n_rows,0);
512 tab_headers (t, 1, 0, 1, 0);
513 tab_dim (t, tab_natural_dimensions);
515 /* Put a frame around the entire box, and vertical lines inside */
520 n_cols - 1, n_rows - 1);
523 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
524 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
527 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
528 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
529 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
530 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
533 tab_title (t, 0, _("Test of Homogeneity of Variances"));
535 for ( v=0 ; v < n_vars ; ++v )
538 const struct variable *var = vars[v];
539 const char *s = (var->label) ? var->label : var->name;
540 const struct group_statistics *totals = &var->p.grp_data.ugs;
542 const double df1 = var->p.grp_data.n_groups - 1;
543 const double df2 = totals->n - var->p.grp_data.n_groups ;
545 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
547 F = var->p.grp_data.levene;
548 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
549 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
550 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
552 /* Now the significance */
553 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
562 /* Show the contrast coefficients table */
564 show_contrast_coeffs(void)
567 int n_cols = 2 + ostensible_number_of_groups;
568 int n_rows = 2 + cmd.sbc_contrast;
569 struct hsh_iterator g;
570 union value *group_value;
577 t = tab_create (n_cols,n_rows,0);
578 tab_headers (t, 2, 0, 2, 0);
579 tab_dim (t, tab_natural_dimensions);
581 /* Put a frame around the entire box, and vertical lines inside */
586 n_cols - 1, n_rows - 1);
602 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
605 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
606 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"));
613 s = (indep_var->label) ? indep_var->label : indep_var->name;
615 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE, s);
617 for (group_value = hsh_first (global_group_hash,&g);
619 group_value = hsh_next(global_group_hash,&g))
624 lab = val_labs_find(indep_var->val_labs,*group_value);
627 tab_text (t, count + 2, 1,
628 TAB_CENTER | TAT_TITLE ,lab);
630 tab_text (t, count + 2, 1,
631 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%g", group_value->f);
633 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
635 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
636 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
637 subc_list_double_at(&cmd.dl_contrast[i],count)
649 /* Show the results of the contrast tests */
651 show_contrast_tests(void)
655 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
659 t = tab_create (n_cols,n_rows,0);
660 tab_headers (t, 3, 0, 1, 0);
661 tab_dim (t, tab_natural_dimensions);
663 /* Put a frame around the entire box, and vertical lines inside */
668 n_cols - 1, n_rows - 1);
676 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
677 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
680 tab_title (t, 0, _("Contrast Tests"));
682 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
683 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
684 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
685 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
686 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
687 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
689 for ( v = 0 ; v < n_vars ; ++v )
692 int lines_per_variable = 2 * cmd.sbc_contrast;
695 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
696 vars[v]->label?vars[v]->label:vars[v]->name);
700 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
703 double contrast_value = 0.0;
704 double coef_msq = 0.0;
705 struct group_proc *grp_data = &vars[v]->p.grp_data ;
706 struct hsh_table *group_hash = grp_data->group_hash;
707 struct hsh_iterator g;
708 struct group_statistics *gs;
711 double std_error_contrast ;
716 /* Note: The calculation of the degrees of freedom in the variances
717 not equal case is painfull!!
718 The following formula may help to understand it:
719 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
722 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
727 double df_denominator = 0.0;
728 double df_numerator = 0.0;
733 tab_text (t, 1, (v * lines_per_variable) + i + 1,
734 TAB_LEFT | TAT_TITLE,
735 _("Assume equal variances"));
737 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
738 TAB_LEFT | TAT_TITLE,
739 _("Does not assume equal"));
742 tab_text (t, 2, (v * lines_per_variable) + i + 1,
743 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
746 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
747 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
749 /* FIXME: Potential danger here.
750 We're ASSUMING THE array is in the order corresponding to the
752 for (ci = 0, gs = hsh_first (group_hash,&g);
754 ++ci, gs = hsh_next(group_hash,&g))
757 const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
758 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
760 contrast_value += coef * gs->mean;
762 coef_msq += (coef * coef) / gs->n ;
764 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
766 df_numerator += (coef * coef) * winv;
767 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
770 sec_vneq = sqrt(sec_vneq);
773 df_numerator = pow2(df_numerator);
776 tab_float (t, 3, (v * lines_per_variable) + i + 1,
777 TAB_RIGHT, contrast_value, 8,2);
779 tab_float (t, 3, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
780 TAB_RIGHT, contrast_value, 8,2);
783 std_error_contrast = sqrt(vars[v]->p.grp_data.mse * coef_msq);
786 tab_float (t, 4, (v * lines_per_variable) + i + 1,
787 TAB_RIGHT, std_error_contrast,
790 T = fabs(contrast_value / std_error_contrast) ;
794 tab_float (t, 5, (v * lines_per_variable) + i + 1,
798 df = grp_data->ugs.n - grp_data->n_groups;
800 /* Degrees of Freedom */
801 tab_float (t, 6, (v * lines_per_variable) + i + 1,
806 /* Significance TWO TAILED !!*/
807 tab_float (t, 7, (v * lines_per_variable) + i + 1,
808 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
812 /* Now for the Variances NOT Equal case */
816 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
821 T = contrast_value / sec_vneq;
823 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
828 df = df_numerator / df_denominator;
831 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
835 /* The Significance */
837 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
838 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
845 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
853 /* ONEWAY ANOVA Calculations */
855 static void postcalc ( struct cmd_oneway *cmd UNUSED );
857 static void precalc ( struct cmd_oneway *cmd UNUSED );
861 /* Pre calculations */
863 precalc ( struct cmd_oneway *cmd UNUSED )
867 for(i=0; i< n_vars ; ++i)
869 struct group_statistics *totals = &vars[i]->p.grp_data.ugs;
871 /* Create a hash for each of the dependent variables.
872 The hash contains a group_statistics structure,
873 and is keyed by value of the independent variable */
875 vars[i]->p.grp_data.group_hash =
877 (hsh_compare_func *) compare_group,
878 (hsh_hash_func *) hash_group,
879 (hsh_free_func *) free_group,
880 (void *) indep_var->width );
887 totals->maximum = - DBL_MAX;
888 totals->minimum = DBL_MAX;
894 calculate(const struct casefile *cf, void *cmd_)
896 struct casereader *r;
899 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
901 global_group_hash = hsh_create(4,
902 (hsh_compare_func *) compare_values,
903 (hsh_hash_func *) hash_value,
905 (void *) indep_var->width );
912 for(r = casefile_get_reader (cf);
913 casereader_read (r, &c) ;
918 const double weight =
919 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
921 const union value *indep_val = case_data (&c, indep_var->fv);
923 hsh_insert ( global_group_hash, (void *) indep_val );
926 for ( i = 0 ; i < n_vars ; ++i )
928 const struct variable *v = vars[i];
930 const union value *val = case_data (&c, v->fv);
932 struct hsh_table *group_hash = vars[i]->p.grp_data.group_hash;
934 struct group_statistics *gs;
936 gs = hsh_find(group_hash, (void *) indep_val );
940 gs = (struct group_statistics *)
941 xmalloc (sizeof(struct group_statistics));
948 gs->minimum = DBL_MAX;
949 gs->maximum = -DBL_MAX;
951 hsh_insert ( group_hash, (void *) gs );
954 if (! value_is_missing(val,v) )
956 struct group_statistics *totals = &vars[i]->p.grp_data.ugs;
959 totals->sum+=weight * val->f;
960 totals->ssq+=weight * val->f * val->f;
962 if ( val->f * weight < totals->minimum )
963 totals->minimum = val->f * weight;
965 if ( val->f * weight > totals->maximum )
966 totals->maximum = val->f * weight;
969 gs->sum+=weight * val->f;
970 gs->ssq+=weight * val->f * val->f;
972 if ( val->f * weight < gs->minimum )
973 gs->minimum = val->f * weight;
975 if ( val->f * weight > gs->maximum )
976 gs->maximum = val->f * weight;
979 vars[i]->p.grp_data.n_groups = hsh_count ( group_hash );
983 casereader_destroy (r);
988 if ( stat_tables & STAT_HOMO )
989 levene(cf, indep_var, n_vars, vars, LEV_LISTWISE, value_is_missing);
991 ostensible_number_of_groups = hsh_count (global_group_hash);
996 /* Post calculations for the ONEWAY command */
998 postcalc ( struct cmd_oneway *cmd UNUSED )
1003 for(i = 0; i < n_vars ; ++i)
1005 struct hsh_table *group_hash = vars[i]->p.grp_data.group_hash;
1006 struct group_statistics *totals = &vars[i]->p.grp_data.ugs;
1008 struct hsh_iterator g;
1009 struct group_statistics *gs;
1011 for (gs = hsh_first (group_hash,&g);
1013 gs = hsh_next(group_hash,&g))
1015 gs->mean=gs->sum / gs->n;
1016 gs->s_std_dev= sqrt(
1017 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1022 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1025 gs->se_mean = gs->std_dev / sqrt(gs->n);
1026 gs->mean_diff= gs->sum_diff / gs->n;
1032 totals->mean = totals->sum / totals->n;
1033 totals->std_dev= sqrt(
1034 totals->n/(totals->n-1) *
1035 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1038 totals->se_mean = totals->std_dev / sqrt(totals->n);