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 = is_system_missing;
124 value_is_missing = is_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);
159 short *bad_contrast ;
161 bad_contrast = xmalloc ( sizeof (short) * cmd.sbc_contrast );
163 /* Check the sanity of the given contrast values */
164 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
170 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
171 ostensible_number_of_groups )
174 _("Number of contrast coefficients must equal the number of groups"));
179 for (j=0; j < ostensible_number_of_groups ; ++j )
180 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
183 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
186 if ( stat_tables & STAT_DESC )
189 if ( stat_tables & STAT_HOMO )
194 if (cmd.sbc_contrast )
196 show_contrast_coeffs(bad_contrast);
197 show_contrast_tests(bad_contrast);
204 for (i = 0 ; i < n_vars ; ++i )
206 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
208 hsh_destroy(group_hash);
211 hsh_destroy(global_group_hash);
218 /* Parser for the variables sub command */
220 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
225 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
230 if (!parse_variables (default_dict, &vars, &n_vars,
232 | PV_NUMERIC | PV_NO_SCRATCH) )
240 if ( ! lex_match(T_BY))
244 indep_var = parse_variable();
248 msg(SE,_("`%s' is not a variable name"),tokid);
257 /* Show the ANOVA table */
259 show_anova_table(void)
263 int n_rows = n_vars * 3 + 1;
268 t = tab_create (n_cols,n_rows,0);
269 tab_headers (t, 2, 0, 1, 0);
270 tab_dim (t, tab_natural_dimensions);
277 n_cols - 1, n_rows - 1);
279 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
280 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
281 tab_vline (t, TAL_0, 1, 0, 0);
283 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
284 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
285 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
286 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
287 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
290 for ( i=0 ; i < n_vars ; ++i )
292 struct group_statistics *totals = &group_proc_get (vars[i])->ugs;
293 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
294 struct hsh_iterator g;
295 struct group_statistics *gs;
297 const char *s = var_to_string(vars[i]);
299 for (gs = hsh_first (group_hash,&g);
301 gs = hsh_next(group_hash,&g))
303 ssa += (gs->sum * gs->sum)/gs->n;
306 ssa -= ( totals->sum * totals->sum ) / totals->n ;
308 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
309 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
310 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
311 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
314 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
317 struct group_proc *gp = group_proc_get (vars[i]);
318 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
319 const double df1 = gp->n_groups - 1;
320 const double df2 = totals->n - gp->n_groups ;
321 const double msa = ssa / df1;
323 gp->mse = (sst - ssa) / df2;
326 /* Sums of Squares */
327 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
328 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
329 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
332 /* Degrees of freedom */
333 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
334 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
335 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
338 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
339 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
343 const double F = msa/gp->mse ;
346 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
348 /* The significance */
349 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
357 tab_title (t, 0, _("ANOVA"));
363 /* Show the descriptives table */
365 show_descriptives(void)
372 const double confidence=0.95;
373 const double q = (1.0 - confidence) / 2.0;
378 for ( v = 0 ; v < n_vars ; ++v )
379 n_rows += group_proc_get (vars[v])->n_groups + 1;
381 t = tab_create (n_cols,n_rows,0);
382 tab_headers (t, 2, 0, 2, 0);
383 tab_dim (t, tab_natural_dimensions);
386 /* Put a frame around the entire box, and vertical lines inside */
391 n_cols - 1, n_rows - 1);
393 /* Underline headers */
394 tab_hline (t, TAL_2, 0, n_cols - 1, 2 );
395 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
397 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
398 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
399 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
400 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
403 tab_vline(t, TAL_0, 7, 0, 0);
404 tab_hline(t, TAL_1, 6, 7, 1);
405 tab_joint_text (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF, _("%g%% Confidence Interval for Mean"),confidence*100.0);
407 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
408 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
410 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
411 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
414 tab_title (t, 0, _("Descriptives"));
418 for ( v=0 ; v < n_vars ; ++v )
423 struct group_proc *gp = group_proc_get (vars[v]);
425 struct group_statistics *gs;
426 struct group_statistics *totals = &gp->ugs;
428 const char *s = var_to_string(vars[v]);
430 struct group_statistics *const *gs_array = hsh_sort(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);
437 for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
439 gs = gs_array[count];
441 tab_text (t, 1, row + count,
442 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
444 /* Now fill in the numbers ... */
446 tab_float (t, 2, row + count, 0, gs->n, 8,0);
448 tab_float (t, 3, row + count, 0, gs->mean,8,2);
450 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
452 std_error = gs->std_dev/sqrt(gs->n) ;
453 tab_float (t, 5, row + count, 0,
456 /* Now the confidence interval */
458 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
460 tab_float(t, 6, row + count, 0,
461 gs->mean - T * std_error, 8, 2);
463 tab_float(t, 7, row + count, 0,
464 gs->mean + T * std_error, 8, 2);
468 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
469 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
473 tab_text (t, 1, row + count,
474 TAB_LEFT | TAT_TITLE ,_("Total"));
476 tab_float (t, 2, row + count, 0, totals->n, 8,0);
478 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
480 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
482 std_error = totals->std_dev/sqrt(totals->n) ;
484 tab_float (t, 5, row + count, 0, std_error, 8,2);
486 /* Now the confidence interval */
488 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
490 tab_float(t, 6, row + count, 0,
491 totals->mean - T * std_error, 8, 2);
493 tab_float(t, 7, row + count, 0,
494 totals->mean + T * std_error, 8, 2);
498 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
499 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
501 row += gp->n_groups + 1;
510 /* Show the homogeneity table */
512 show_homogeneity(void)
516 int n_rows = n_vars + 1;
521 t = tab_create (n_cols,n_rows,0);
522 tab_headers (t, 1, 0, 1, 0);
523 tab_dim (t, tab_natural_dimensions);
525 /* Put a frame around the entire box, and vertical lines inside */
530 n_cols - 1, n_rows - 1);
533 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
534 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
537 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
538 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
539 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
540 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
543 tab_title (t, 0, _("Test of Homogeneity of Variances"));
545 for ( v=0 ; v < n_vars ; ++v )
548 const struct variable *var = vars[v];
549 const struct group_proc *gp = group_proc_get (vars[v]);
550 const char *s = var_to_string(var);
551 const struct group_statistics *totals = &gp->ugs;
553 const double df1 = gp->n_groups - 1;
554 const double df2 = totals->n - gp->n_groups ;
556 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
559 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
560 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
561 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
563 /* Now the significance */
564 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
573 /* Show the contrast coefficients table */
575 show_contrast_coeffs(short *bad_contrast)
577 int n_cols = 2 + ostensible_number_of_groups;
578 int n_rows = 2 + cmd.sbc_contrast;
579 union value *group_value;
581 void *const *group_values ;
585 t = tab_create (n_cols,n_rows,0);
586 tab_headers (t, 2, 0, 2, 0);
587 tab_dim (t, tab_natural_dimensions);
589 /* Put a frame around the entire box, and vertical lines inside */
594 n_cols - 1, n_rows - 1);
608 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
609 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
611 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
613 tab_title (t, 0, _("Contrast Coefficients"));
615 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
618 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
619 var_to_string(indep_var));
621 group_values = hsh_sort(global_group_hash);
623 count < hsh_count(global_group_hash) ;
627 group_value = group_values[count];
629 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
630 value_to_string(group_value, indep_var));
632 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
634 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
636 if ( bad_contrast[i] )
637 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
639 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
640 subc_list_double_at(&cmd.dl_contrast[i], count)
649 /* Show the results of the contrast tests */
651 show_contrast_tests(short *bad_contrast)
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 var_to_string(vars[v]));
698 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
701 double contrast_value = 0.0;
702 double coef_msq = 0.0;
703 struct group_proc *grp_data = group_proc_get (vars[v]);
704 struct hsh_table *group_hash = grp_data->group_hash;
706 void *const *group_stat_array;
709 double std_error_contrast ;
714 /* Note: The calculation of the degrees of freedom in the
715 "variances not equal" case is painfull!!
716 The following formula may help to understand it:
717 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
720 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
725 double df_denominator = 0.0;
726 double df_numerator = 0.0;
729 tab_text (t, 1, (v * lines_per_variable) + i + 1,
730 TAB_LEFT | TAT_TITLE,
731 _("Assume equal variances"));
733 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
734 TAB_LEFT | TAT_TITLE,
735 _("Does not assume equal"));
738 tab_text (t, 2, (v * lines_per_variable) + i + 1,
739 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
742 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
743 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
746 if ( bad_contrast[i])
749 group_stat_array = hsh_sort(group_hash);
751 for (ci = 0 ; ci < hsh_count(group_hash) ; ++ci)
753 const double coef = subc_list_double_at(&cmd.dl_contrast[i], ci);
754 struct group_statistics *gs = group_stat_array[ci];
756 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
758 contrast_value += coef * gs->mean;
760 coef_msq += (coef * coef) / gs->n ;
762 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
764 df_numerator += (coef * coef) * winv;
765 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
767 sec_vneq = sqrt(sec_vneq);
769 df_numerator = pow2(df_numerator);
771 tab_float (t, 3, (v * lines_per_variable) + i + 1,
772 TAB_RIGHT, contrast_value, 8,2);
774 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
776 TAB_RIGHT, contrast_value, 8,2);
778 std_error_contrast = sqrt(grp_data->mse * coef_msq);
781 tab_float (t, 4, (v * lines_per_variable) + i + 1,
782 TAB_RIGHT, std_error_contrast,
785 T = fabs(contrast_value / std_error_contrast) ;
789 tab_float (t, 5, (v * lines_per_variable) + i + 1,
793 df = grp_data->ugs.n - grp_data->n_groups;
795 /* Degrees of Freedom */
796 tab_float (t, 6, (v * lines_per_variable) + i + 1,
801 /* Significance TWO TAILED !!*/
802 tab_float (t, 7, (v * lines_per_variable) + i + 1,
803 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
807 /* Now for the Variances NOT Equal case */
811 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
816 T = contrast_value / sec_vneq;
818 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
823 df = df_numerator / df_denominator;
826 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
830 /* The Significance */
832 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
833 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
840 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
848 /* ONEWAY ANOVA Calculations */
850 static void postcalc ( struct cmd_oneway *cmd UNUSED );
852 static void precalc ( struct cmd_oneway *cmd UNUSED );
856 /* Pre calculations */
858 precalc ( struct cmd_oneway *cmd UNUSED )
862 for(i=0; i< n_vars ; ++i)
864 struct group_proc *gp = group_proc_get (vars[i]);
865 struct group_statistics *totals = &gp->ugs;
867 /* Create a hash for each of the dependent variables.
868 The hash contains a group_statistics structure,
869 and is keyed by value of the independent variable */
873 (hsh_compare_func *) compare_group,
874 (hsh_hash_func *) hash_group,
875 (hsh_free_func *) free_group,
876 (void *) indep_var->width );
883 totals->maximum = - DBL_MAX;
884 totals->minimum = DBL_MAX;
890 run_oneway(const struct casefile *cf, void *cmd_)
892 struct casereader *r;
895 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
897 global_group_hash = hsh_create(4,
898 (hsh_compare_func *) compare_values,
899 (hsh_hash_func *) hash_value,
901 (void *) indep_var->width );
904 for(r = casefile_get_reader (cf);
905 casereader_read (r, &c) ;
910 const double weight =
911 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
913 const union value *indep_val = case_data (&c, indep_var->fv);
915 /* Deal with missing values */
916 if ( value_is_missing(indep_val,indep_var) )
919 /* Skip the entire case if /MISSING=LISTWISE is set */
920 if ( cmd->miss == ONEWAY_LISTWISE )
922 for(i = 0; i < n_vars ; ++i)
924 const struct variable *v = vars[i];
925 const union value *val = case_data (&c, v->fv);
927 if (value_is_missing(val,v) )
936 hsh_insert ( global_group_hash, (void *) indep_val );
938 for ( i = 0 ; i < n_vars ; ++i )
940 const struct variable *v = vars[i];
942 const union value *val = case_data (&c, v->fv);
944 struct group_proc *gp = group_proc_get (vars[i]);
945 struct hsh_table *group_hash = gp->group_hash;
947 struct group_statistics *gs;
949 gs = hsh_find(group_hash, (void *) indep_val );
953 gs = (struct group_statistics *)
954 xmalloc (sizeof(struct group_statistics));
961 gs->minimum = DBL_MAX;
962 gs->maximum = -DBL_MAX;
964 hsh_insert ( group_hash, (void *) gs );
967 if (! value_is_missing(val,v) )
969 struct group_statistics *totals = &gp->ugs;
972 totals->sum+=weight * val->f;
973 totals->ssq+=weight * val->f * val->f;
975 if ( val->f * weight < totals->minimum )
976 totals->minimum = val->f * weight;
978 if ( val->f * weight > totals->maximum )
979 totals->maximum = val->f * weight;
982 gs->sum+=weight * val->f;
983 gs->ssq+=weight * val->f * val->f;
985 if ( val->f * weight < gs->minimum )
986 gs->minimum = val->f * weight;
988 if ( val->f * weight > gs->maximum )
989 gs->maximum = val->f * weight;
992 gp->n_groups = hsh_count ( group_hash );
996 casereader_destroy (r);
1001 if ( stat_tables & STAT_HOMO )
1002 levene(cf, indep_var, n_vars, vars,
1003 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1006 ostensible_number_of_groups = hsh_count (global_group_hash);
1015 /* Post calculations for the ONEWAY command */
1017 postcalc ( struct cmd_oneway *cmd UNUSED )
1022 for(i = 0; i < n_vars ; ++i)
1024 struct group_proc *gp = group_proc_get (vars[i]);
1025 struct hsh_table *group_hash = gp->group_hash;
1026 struct group_statistics *totals = &gp->ugs;
1028 struct hsh_iterator g;
1029 struct group_statistics *gs;
1031 for (gs = hsh_first (group_hash,&g);
1033 gs = hsh_next(group_hash,&g))
1035 gs->mean=gs->sum / gs->n;
1036 gs->s_std_dev= sqrt(
1037 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1042 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1045 gs->se_mean = gs->std_dev / sqrt(gs->n);
1046 gs->mean_diff= gs->sum_diff / gs->n;
1052 totals->mean = totals->sum / totals->n;
1053 totals->std_dev= sqrt(
1054 totals->n/(totals->n-1) *
1055 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1058 totals->se_mean = totals->std_dev / sqrt(totals->n);