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"
48 #define _(msgid) gettext (msgid)
55 +missing=miss:!analysis/listwise,
56 incl:include/!exclude;
57 contrast= double list;
58 statistics[st_]=descriptives,homogeneity.
65 static int bad_weight_warn = 1;
68 static struct cmd_oneway cmd;
70 /* The independent variable */
71 static struct variable *indep_var;
73 /* Number of dependent variables */
76 /* The dependent variables */
77 static struct variable **vars;
80 /* A hash table containing all the distinct values of the independent
82 static struct hsh_table *global_group_hash ;
84 /* The number of distinct values of the independent variable, when all
85 missing values are disregarded */
86 static int ostensible_number_of_groups=-1;
89 /* Function to use for testing for missing values */
90 static is_missing_func *value_is_missing;
93 static void run_oneway(const struct casefile *cf, void *_mode);
96 /* Routines to show the output tables */
97 static void show_anova_table(void);
98 static void show_descriptives(void);
99 static void show_homogeneity(void);
101 static void show_contrast_coeffs(short *);
102 static void show_contrast_tests(short *);
105 enum stat_table_t {STAT_DESC = 1, STAT_HOMO = 2};
107 static enum stat_table_t stat_tables ;
109 void output_oneway(void);
117 if ( !parse_oneway(&cmd) )
120 /* If /MISSING=INCLUDE is set, then user missing values are ignored */
121 if (cmd.incl == ONEWAY_INCLUDE )
122 value_is_missing = mv_is_value_system_missing;
124 value_is_missing = mv_is_value_missing;
126 /* What statistics were requested */
127 if ( cmd.sbc_statistics )
130 for (i = 0 ; i < ONEWAY_ST_count ; ++i )
132 if ( ! cmd.a_statistics[i] ) continue;
135 case ONEWAY_ST_DESCRIPTIVES:
136 stat_tables |= STAT_DESC;
138 case ONEWAY_ST_HOMOGENEITY:
139 stat_tables |= STAT_HOMO;
145 multipass_procedure_with_splits (run_oneway, &cmd);
158 short *bad_contrast ;
160 bad_contrast = xnmalloc (cmd.sbc_contrast, sizeof *bad_contrast);
162 /* Check the sanity of the given contrast values */
163 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
169 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
170 ostensible_number_of_groups )
173 _("Number of contrast coefficients must equal the number of groups"));
178 for (j=0; j < ostensible_number_of_groups ; ++j )
179 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
182 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
185 if ( stat_tables & STAT_DESC )
188 if ( stat_tables & STAT_HOMO )
193 if (cmd.sbc_contrast )
195 show_contrast_coeffs(bad_contrast);
196 show_contrast_tests(bad_contrast);
203 for (i = 0 ; i < n_vars ; ++i )
205 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
207 hsh_destroy(group_hash);
210 hsh_destroy(global_group_hash);
217 /* Parser for the variables sub command */
219 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
224 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
229 if (!parse_variables (default_dict, &vars, &n_vars,
231 | PV_NUMERIC | PV_NO_SCRATCH) )
239 if ( ! lex_match(T_BY))
243 indep_var = parse_variable();
247 msg(SE,_("`%s' is not a variable name"),tokid);
256 /* Show the ANOVA table */
258 show_anova_table(void)
262 size_t n_rows = n_vars * 3 + 1;
267 t = tab_create (n_cols,n_rows,0);
268 tab_headers (t, 2, 0, 1, 0);
269 tab_dim (t, tab_natural_dimensions);
276 n_cols - 1, n_rows - 1);
278 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
279 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
280 tab_vline (t, TAL_0, 1, 0, 0);
282 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
283 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
284 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
285 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
286 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
289 for ( i=0 ; i < n_vars ; ++i )
291 struct group_statistics *totals = &group_proc_get (vars[i])->ugs;
292 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
293 struct hsh_iterator g;
294 struct group_statistics *gs;
296 const char *s = var_to_string(vars[i]);
298 for (gs = hsh_first (group_hash,&g);
300 gs = hsh_next(group_hash,&g))
302 ssa += (gs->sum * gs->sum)/gs->n;
305 ssa -= ( totals->sum * totals->sum ) / totals->n ;
307 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
308 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
309 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
310 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
313 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
316 struct group_proc *gp = group_proc_get (vars[i]);
317 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
318 const double df1 = gp->n_groups - 1;
319 const double df2 = totals->n - gp->n_groups ;
320 const double msa = ssa / df1;
322 gp->mse = (sst - ssa) / df2;
325 /* Sums of Squares */
326 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
327 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
328 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
331 /* Degrees of freedom */
332 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
333 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
334 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
337 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
338 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
342 const double F = msa/gp->mse ;
345 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
347 /* The significance */
348 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
356 tab_title (t, 0, _("ANOVA"));
362 /* Show the descriptives table */
364 show_descriptives(void)
371 const double confidence=0.95;
372 const double q = (1.0 - confidence) / 2.0;
377 for ( v = 0 ; v < n_vars ; ++v )
378 n_rows += group_proc_get (vars[v])->n_groups + 1;
380 t = tab_create (n_cols,n_rows,0);
381 tab_headers (t, 2, 0, 2, 0);
382 tab_dim (t, tab_natural_dimensions);
385 /* Put a frame around the entire box, and vertical lines inside */
390 n_cols - 1, n_rows - 1);
392 /* Underline headers */
393 tab_hline (t, TAL_2, 0, n_cols - 1, 2 );
394 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
396 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
397 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
398 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
399 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
402 tab_vline(t, TAL_0, 7, 0, 0);
403 tab_hline(t, TAL_1, 6, 7, 1);
404 tab_joint_text (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, _("%g%% Confidence Interval for Mean"),confidence*100.0);
406 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
407 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
409 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
410 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
413 tab_title (t, 0, _("Descriptives"));
417 for ( v=0 ; v < n_vars ; ++v )
422 struct group_proc *gp = group_proc_get (vars[v]);
424 struct group_statistics *gs;
425 struct group_statistics *totals = &gp->ugs;
427 const char *s = var_to_string(vars[v]);
429 struct group_statistics *const *gs_array = hsh_sort(gp->group_hash);
432 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
434 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
436 for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
438 gs = gs_array[count];
440 tab_text (t, 1, row + count,
441 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
443 /* Now fill in the numbers ... */
445 tab_float (t, 2, row + count, 0, gs->n, 8,0);
447 tab_float (t, 3, row + count, 0, gs->mean,8,2);
449 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
451 std_error = gs->std_dev/sqrt(gs->n) ;
452 tab_float (t, 5, row + count, 0,
455 /* Now the confidence interval */
457 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
459 tab_float(t, 6, row + count, 0,
460 gs->mean - T * std_error, 8, 2);
462 tab_float(t, 7, row + count, 0,
463 gs->mean + T * std_error, 8, 2);
467 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
468 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
472 tab_text (t, 1, row + count,
473 TAB_LEFT | TAT_TITLE ,_("Total"));
475 tab_float (t, 2, row + count, 0, totals->n, 8,0);
477 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
479 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
481 std_error = totals->std_dev/sqrt(totals->n) ;
483 tab_float (t, 5, row + count, 0, std_error, 8,2);
485 /* Now the confidence interval */
487 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
489 tab_float(t, 6, row + count, 0,
490 totals->mean - T * std_error, 8, 2);
492 tab_float(t, 7, row + count, 0,
493 totals->mean + T * std_error, 8, 2);
497 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
498 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
500 row += gp->n_groups + 1;
509 /* Show the homogeneity table */
511 show_homogeneity(void)
515 size_t n_rows = n_vars + 1;
520 t = tab_create (n_cols,n_rows,0);
521 tab_headers (t, 1, 0, 1, 0);
522 tab_dim (t, tab_natural_dimensions);
524 /* Put a frame around the entire box, and vertical lines inside */
529 n_cols - 1, n_rows - 1);
532 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
533 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
536 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
537 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
538 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
539 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
542 tab_title (t, 0, _("Test of Homogeneity of Variances"));
544 for ( v=0 ; v < n_vars ; ++v )
547 const struct variable *var = vars[v];
548 const struct group_proc *gp = group_proc_get (vars[v]);
549 const char *s = var_to_string(var);
550 const struct group_statistics *totals = &gp->ugs;
552 const double df1 = gp->n_groups - 1;
553 const double df2 = totals->n - gp->n_groups ;
555 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
558 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
559 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
560 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
562 /* Now the significance */
563 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
572 /* Show the contrast coefficients table */
574 show_contrast_coeffs(short *bad_contrast)
576 int n_cols = 2 + ostensible_number_of_groups;
577 int n_rows = 2 + cmd.sbc_contrast;
578 union value *group_value;
580 void *const *group_values ;
584 t = tab_create (n_cols,n_rows,0);
585 tab_headers (t, 2, 0, 2, 0);
586 tab_dim (t, tab_natural_dimensions);
588 /* Put a frame around the entire box, and vertical lines inside */
593 n_cols - 1, n_rows - 1);
607 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
608 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
610 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
612 tab_title (t, 0, _("Contrast Coefficients"));
614 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
617 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
618 var_to_string(indep_var));
620 group_values = hsh_sort(global_group_hash);
622 count < hsh_count(global_group_hash) ;
626 group_value = group_values[count];
628 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
629 value_to_string(group_value, indep_var));
631 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
633 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
635 if ( bad_contrast[i] )
636 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
638 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
639 subc_list_double_at(&cmd.dl_contrast[i], count)
648 /* Show the results of the contrast tests */
650 show_contrast_tests(short *bad_contrast)
654 size_t n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
658 t = tab_create (n_cols,n_rows,0);
659 tab_headers (t, 3, 0, 1, 0);
660 tab_dim (t, tab_natural_dimensions);
662 /* Put a frame around the entire box, and vertical lines inside */
667 n_cols - 1, n_rows - 1);
675 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
676 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
679 tab_title (t, 0, _("Contrast Tests"));
681 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
682 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
683 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
684 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
685 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
686 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
688 for ( v = 0 ; v < n_vars ; ++v )
691 int lines_per_variable = 2 * cmd.sbc_contrast;
694 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
695 var_to_string(vars[v]));
697 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
700 double contrast_value = 0.0;
701 double coef_msq = 0.0;
702 struct group_proc *grp_data = group_proc_get (vars[v]);
703 struct hsh_table *group_hash = grp_data->group_hash;
705 void *const *group_stat_array;
708 double std_error_contrast ;
713 /* Note: The calculation of the degrees of freedom in the
714 "variances not equal" case is painfull!!
715 The following formula may help to understand it:
716 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
719 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
724 double df_denominator = 0.0;
725 double df_numerator = 0.0;
728 tab_text (t, 1, (v * lines_per_variable) + i + 1,
729 TAB_LEFT | TAT_TITLE,
730 _("Assume equal variances"));
732 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
733 TAB_LEFT | TAT_TITLE,
734 _("Does not assume equal"));
737 tab_text (t, 2, (v * lines_per_variable) + i + 1,
738 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
741 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
742 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
745 if ( bad_contrast[i])
748 group_stat_array = hsh_sort(group_hash);
750 for (ci = 0 ; ci < hsh_count(group_hash) ; ++ci)
752 const double coef = subc_list_double_at(&cmd.dl_contrast[i], ci);
753 struct group_statistics *gs = group_stat_array[ci];
755 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
757 contrast_value += coef * gs->mean;
759 coef_msq += (coef * coef) / gs->n ;
761 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
763 df_numerator += (coef * coef) * winv;
764 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
766 sec_vneq = sqrt(sec_vneq);
768 df_numerator = pow2(df_numerator);
770 tab_float (t, 3, (v * lines_per_variable) + i + 1,
771 TAB_RIGHT, contrast_value, 8,2);
773 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
775 TAB_RIGHT, contrast_value, 8,2);
777 std_error_contrast = sqrt(grp_data->mse * coef_msq);
780 tab_float (t, 4, (v * lines_per_variable) + i + 1,
781 TAB_RIGHT, std_error_contrast,
784 T = fabs(contrast_value / std_error_contrast) ;
788 tab_float (t, 5, (v * lines_per_variable) + i + 1,
792 df = grp_data->ugs.n - grp_data->n_groups;
794 /* Degrees of Freedom */
795 tab_float (t, 6, (v * lines_per_variable) + i + 1,
800 /* Significance TWO TAILED !!*/
801 tab_float (t, 7, (v * lines_per_variable) + i + 1,
802 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
806 /* Now for the Variances NOT Equal case */
810 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
815 T = contrast_value / sec_vneq;
817 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
822 df = df_numerator / df_denominator;
825 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
829 /* The Significance */
831 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
832 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
839 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
847 /* ONEWAY ANOVA Calculations */
849 static void postcalc ( struct cmd_oneway *cmd UNUSED );
851 static void precalc ( struct cmd_oneway *cmd UNUSED );
855 /* Pre calculations */
857 precalc ( struct cmd_oneway *cmd UNUSED )
861 for(i=0; i< n_vars ; ++i)
863 struct group_proc *gp = group_proc_get (vars[i]);
864 struct group_statistics *totals = &gp->ugs;
866 /* Create a hash for each of the dependent variables.
867 The hash contains a group_statistics structure,
868 and is keyed by value of the independent variable */
872 (hsh_compare_func *) compare_group,
873 (hsh_hash_func *) hash_group,
874 (hsh_free_func *) free_group,
875 (void *) indep_var->width );
882 totals->maximum = - DBL_MAX;
883 totals->minimum = DBL_MAX;
889 run_oneway(const struct casefile *cf, void *cmd_)
891 struct casereader *r;
894 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
896 global_group_hash = hsh_create(4,
897 (hsh_compare_func *) compare_values,
898 (hsh_hash_func *) hash_value,
900 (void *) indep_var->width );
903 for(r = casefile_get_reader (cf);
904 casereader_read (r, &c) ;
909 const double weight =
910 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
912 const union value *indep_val = case_data (&c, indep_var->fv);
914 /* Deal with missing values */
915 if ( value_is_missing(&indep_var->miss, indep_val) )
918 /* Skip the entire case if /MISSING=LISTWISE is set */
919 if ( cmd->miss == ONEWAY_LISTWISE )
921 for(i = 0; i < n_vars ; ++i)
923 const struct variable *v = vars[i];
924 const union value *val = case_data (&c, v->fv);
926 if (value_is_missing(&v->miss, val) )
935 hsh_insert ( global_group_hash, (void *) indep_val );
937 for ( i = 0 ; i < n_vars ; ++i )
939 const struct variable *v = vars[i];
941 const union value *val = case_data (&c, v->fv);
943 struct group_proc *gp = group_proc_get (vars[i]);
944 struct hsh_table *group_hash = gp->group_hash;
946 struct group_statistics *gs;
948 gs = hsh_find(group_hash, (void *) indep_val );
952 gs = xmalloc (sizeof *gs);
958 gs->minimum = DBL_MAX;
959 gs->maximum = -DBL_MAX;
961 hsh_insert ( group_hash, (void *) gs );
964 if (! value_is_missing(&v->miss, val) )
966 struct group_statistics *totals = &gp->ugs;
969 totals->sum+=weight * val->f;
970 totals->ssq+=weight * val->f * val->f;
972 if ( val->f * weight < totals->minimum )
973 totals->minimum = val->f * weight;
975 if ( val->f * weight > totals->maximum )
976 totals->maximum = val->f * weight;
979 gs->sum+=weight * val->f;
980 gs->ssq+=weight * val->f * val->f;
982 if ( val->f * weight < gs->minimum )
983 gs->minimum = val->f * weight;
985 if ( val->f * weight > gs->maximum )
986 gs->maximum = val->f * weight;
989 gp->n_groups = hsh_count ( group_hash );
993 casereader_destroy (r);
998 if ( stat_tables & STAT_HOMO )
999 levene(cf, indep_var, n_vars, vars,
1000 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1003 ostensible_number_of_groups = hsh_count (global_group_hash);
1012 /* Post calculations for the ONEWAY command */
1014 postcalc ( struct cmd_oneway *cmd UNUSED )
1019 for(i = 0; i < n_vars ; ++i)
1021 struct group_proc *gp = group_proc_get (vars[i]);
1022 struct hsh_table *group_hash = gp->group_hash;
1023 struct group_statistics *totals = &gp->ugs;
1025 struct hsh_iterator g;
1026 struct group_statistics *gs;
1028 for (gs = hsh_first (group_hash,&g);
1030 gs = hsh_next(group_hash,&g))
1032 gs->mean=gs->sum / gs->n;
1033 gs->s_std_dev= sqrt(
1034 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1039 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1042 gs->se_mean = gs->std_dev / sqrt(gs->n);
1043 gs->mean_diff= gs->sum_diff / gs->n;
1049 totals->mean = totals->sum / totals->n;
1050 totals->std_dev= sqrt(
1051 totals->n/(totals->n-1) *
1052 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1055 totals->se_mean = totals->std_dev / sqrt(totals->n);