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>
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);
154 short *bad_contrast ;
156 bad_contrast = xmalloc ( sizeof (short) * cmd.sbc_contrast );
158 /* Check the sanity of the given contrast values */
159 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
165 if ( subc_list_double_count(&cmd.dl_contrast[i]) !=
166 ostensible_number_of_groups )
169 _("Number of contrast coefficients must equal the number of groups"));
174 for (j=0; j < ostensible_number_of_groups ; ++j )
175 sum += subc_list_double_at(&cmd.dl_contrast[i],j);
178 msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1);
181 if ( stat_tables & STAT_DESC )
184 if ( stat_tables & STAT_HOMO )
189 if (cmd.sbc_contrast )
191 show_contrast_coeffs(bad_contrast);
192 show_contrast_tests(bad_contrast);
199 for (i = 0 ; i < n_vars ; ++i )
201 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
203 hsh_destroy(group_hash);
206 hsh_destroy(global_group_hash);
213 /* Parser for the variables sub command */
215 oneway_custom_variables(struct cmd_oneway *cmd UNUSED)
220 if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
225 if (!parse_variables (default_dict, &vars, &n_vars,
227 | PV_NUMERIC | PV_NO_SCRATCH) )
235 if ( ! lex_match(T_BY))
239 indep_var = parse_variable();
243 msg(SE,_("`%s' is not a variable name"),tokid);
252 /* Show the ANOVA table */
254 show_anova_table(void)
258 int n_rows = n_vars * 3 + 1;
263 t = tab_create (n_cols,n_rows,0);
264 tab_headers (t, 2, 0, 1, 0);
265 tab_dim (t, tab_natural_dimensions);
272 n_cols - 1, n_rows - 1);
274 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
275 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
276 tab_vline (t, TAL_0, 1, 0, 0);
278 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
279 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
280 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
281 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
282 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
285 for ( i=0 ; i < n_vars ; ++i )
287 struct group_statistics *totals = &group_proc_get (vars[i])->ugs;
288 struct hsh_table *group_hash = group_proc_get (vars[i])->group_hash;
289 struct hsh_iterator g;
290 struct group_statistics *gs;
294 for (gs = hsh_first (group_hash,&g);
296 gs = hsh_next(group_hash,&g))
298 ssa += (gs->sum * gs->sum)/gs->n;
301 ssa -= ( totals->sum * totals->sum ) / totals->n ;
303 const char *s = var_to_string(vars[i]);
305 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
306 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
307 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
308 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
311 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
314 struct group_proc *gp = group_proc_get (vars[i]);
315 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
316 const double df1 = gp->n_groups - 1;
317 const double df2 = totals->n - gp->n_groups ;
318 const double msa = ssa / df1;
320 gp->mse = (sst - ssa) / df2;
323 /* Sums of Squares */
324 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
325 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
326 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
329 /* Degrees of freedom */
330 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
331 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
332 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
335 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
336 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
340 const double F = msa/gp->mse ;
343 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
345 /* The significance */
346 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
354 tab_title (t, 0, _("ANOVA"));
360 /* Show the descriptives table */
362 show_descriptives(void)
369 const double confidence=0.95;
370 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 hsh_iterator g;
425 struct group_statistics *gs;
426 struct group_statistics *totals = &gp->ugs;
429 const char *s = var_to_string(vars[v]);
431 struct hsh_table *group_hash = gp->group_hash;
434 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
436 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
439 for (gs = hsh_first (group_hash,&g);
441 gs = hsh_next(group_hash,&g))
443 tab_text (t, 1, row + count,
444 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
446 /* Now fill in the numbers ... */
448 tab_float (t, 2, row + count, 0, gs->n, 8,0);
450 tab_float (t, 3, row + count, 0, gs->mean,8,2);
452 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
454 std_error = gs->std_dev/sqrt(gs->n) ;
455 tab_float (t, 5, row + count, 0,
458 /* Now the confidence interval */
460 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
462 tab_float(t, 6, row + count, 0,
463 gs->mean - T * std_error, 8, 2);
465 tab_float(t, 7, row + count, 0,
466 gs->mean + T * std_error, 8, 2);
470 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
471 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
476 tab_text (t, 1, row + count,
477 TAB_LEFT | TAT_TITLE ,_("Total"));
479 tab_float (t, 2, row + count, 0, totals->n, 8,0);
481 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
483 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
485 std_error = totals->std_dev/sqrt(totals->n) ;
487 tab_float (t, 5, row + count, 0, std_error, 8,2);
489 /* Now the confidence interval */
491 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
493 tab_float(t, 6, row + count, 0,
494 totals->mean - T * std_error, 8, 2);
496 tab_float(t, 7, row + count, 0,
497 totals->mean + T * std_error, 8, 2);
501 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
502 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
504 row += gp->n_groups + 1;
513 /* Show the homogeneity table */
515 show_homogeneity(void)
519 int n_rows = n_vars + 1;
524 t = tab_create (n_cols,n_rows,0);
525 tab_headers (t, 1, 0, 1, 0);
526 tab_dim (t, tab_natural_dimensions);
528 /* Put a frame around the entire box, and vertical lines inside */
533 n_cols - 1, n_rows - 1);
536 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
537 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
540 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
541 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
542 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
543 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
546 tab_title (t, 0, _("Test of Homogeneity of Variances"));
548 for ( v=0 ; v < n_vars ; ++v )
551 const struct variable *var = vars[v];
552 const struct group_proc *gp = group_proc_get (vars[v]);
553 const char *s = var_to_string(var);
554 const struct group_statistics *totals = &gp->ugs;
556 const double df1 = gp->n_groups - 1;
557 const double df2 = totals->n - gp->n_groups ;
559 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
562 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
563 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
564 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
566 /* Now the significance */
567 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
576 /* Show the contrast coefficients table */
578 show_contrast_coeffs(short *bad_contrast)
580 int n_cols = 2 + ostensible_number_of_groups;
581 int n_rows = 2 + cmd.sbc_contrast;
582 struct hsh_iterator g;
583 union value *group_value;
590 t = tab_create (n_cols,n_rows,0);
591 tab_headers (t, 2, 0, 2, 0);
592 tab_dim (t, tab_natural_dimensions);
594 /* Put a frame around the entire box, and vertical lines inside */
599 n_cols - 1, n_rows - 1);
615 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
618 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
619 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
622 tab_title (t, 0, _("Contrast Coefficients"));
624 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
628 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
629 var_to_string(indep_var));
631 for (group_value = hsh_first (global_group_hash,&g);
633 group_value = hsh_next(global_group_hash,&g))
637 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
638 value_to_string(group_value,indep_var));
640 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
643 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
645 if ( bad_contrast[i] )
646 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
648 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
649 subc_list_double_at(&cmd.dl_contrast[i],count)
661 /* Show the results of the contrast tests */
663 show_contrast_tests(short *bad_contrast)
667 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
671 t = tab_create (n_cols,n_rows,0);
672 tab_headers (t, 3, 0, 1, 0);
673 tab_dim (t, tab_natural_dimensions);
675 /* Put a frame around the entire box, and vertical lines inside */
680 n_cols - 1, n_rows - 1);
688 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
689 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
692 tab_title (t, 0, _("Contrast Tests"));
694 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
695 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
696 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
697 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
698 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
699 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
701 for ( v = 0 ; v < n_vars ; ++v )
704 int lines_per_variable = 2 * cmd.sbc_contrast;
707 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
708 var_to_string(vars[v]));
710 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
713 double contrast_value = 0.0;
714 double coef_msq = 0.0;
715 struct group_proc *grp_data = group_proc_get (vars[v]);
716 struct hsh_table *group_hash = grp_data->group_hash;
717 struct hsh_iterator g;
718 struct group_statistics *gs;
721 double std_error_contrast ;
726 /* Note: The calculation of the degrees of freedom in the variances
727 not equal case is painfull!!
728 The following formula may help to understand it:
729 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
732 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
737 double df_denominator = 0.0;
738 double df_numerator = 0.0;
743 tab_text (t, 1, (v * lines_per_variable) + i + 1,
744 TAB_LEFT | TAT_TITLE,
745 _("Assume equal variances"));
747 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
748 TAB_LEFT | TAT_TITLE,
749 _("Does not assume equal"));
752 tab_text (t, 2, (v * lines_per_variable) + i + 1,
753 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
756 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
757 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
760 if ( bad_contrast[i])
763 /* FIXME: Potential danger here.
764 We're ASSUMING THE array is in the order corresponding to the
766 for (ci = 0, gs = hsh_first (group_hash,&g);
768 ++ci, gs = hsh_next(group_hash,&g))
771 const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
772 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
774 contrast_value += coef * gs->mean;
776 coef_msq += (coef * coef) / gs->n ;
778 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
780 df_numerator += (coef * coef) * winv;
781 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
784 sec_vneq = sqrt(sec_vneq);
786 df_numerator = pow2(df_numerator);
788 tab_float (t, 3, (v * lines_per_variable) + i + 1,
789 TAB_RIGHT, contrast_value, 8,2);
791 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
793 TAB_RIGHT, contrast_value, 8,2);
795 std_error_contrast = sqrt(grp_data->mse * coef_msq);
798 tab_float (t, 4, (v * lines_per_variable) + i + 1,
799 TAB_RIGHT, std_error_contrast,
802 T = fabs(contrast_value / std_error_contrast) ;
806 tab_float (t, 5, (v * lines_per_variable) + i + 1,
810 df = grp_data->ugs.n - grp_data->n_groups;
812 /* Degrees of Freedom */
813 tab_float (t, 6, (v * lines_per_variable) + i + 1,
818 /* Significance TWO TAILED !!*/
819 tab_float (t, 7, (v * lines_per_variable) + i + 1,
820 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
824 /* Now for the Variances NOT Equal case */
828 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
833 T = contrast_value / sec_vneq;
835 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
840 df = df_numerator / df_denominator;
843 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
847 /* The Significance */
849 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
850 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
857 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
865 /* ONEWAY ANOVA Calculations */
867 static void postcalc ( struct cmd_oneway *cmd UNUSED );
869 static void precalc ( struct cmd_oneway *cmd UNUSED );
873 /* Pre calculations */
875 precalc ( struct cmd_oneway *cmd UNUSED )
879 for(i=0; i< n_vars ; ++i)
881 struct group_proc *gp = group_proc_get (vars[i]);
882 struct group_statistics *totals = &gp->ugs;
884 /* Create a hash for each of the dependent variables.
885 The hash contains a group_statistics structure,
886 and is keyed by value of the independent variable */
890 (hsh_compare_func *) compare_group,
891 (hsh_hash_func *) hash_group,
892 (hsh_free_func *) free_group,
893 (void *) indep_var->width );
900 totals->maximum = - DBL_MAX;
901 totals->minimum = DBL_MAX;
907 run_oneway(const struct casefile *cf, void *cmd_)
909 struct casereader *r;
912 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
914 global_group_hash = hsh_create(4,
915 (hsh_compare_func *) compare_values,
916 (hsh_hash_func *) hash_value,
918 (void *) indep_var->width );
921 for(r = casefile_get_reader (cf);
922 casereader_read (r, &c) ;
927 const double weight =
928 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
930 const union value *indep_val = case_data (&c, indep_var->fv);
932 /* Deal with missing values */
933 if ( value_is_missing(indep_val,indep_var) )
936 /* Skip the entire case if /MISSING=LISTWISE is set */
937 if ( cmd->miss == ONEWAY_LISTWISE )
939 for(i = 0; i < n_vars ; ++i)
941 const struct variable *v = vars[i];
942 const union value *val = case_data (&c, v->fv);
944 if (value_is_missing(val,v) )
953 hsh_insert ( global_group_hash, (void *) indep_val );
955 for ( i = 0 ; i < n_vars ; ++i )
957 const struct variable *v = vars[i];
959 const union value *val = case_data (&c, v->fv);
961 struct group_proc *gp = group_proc_get (vars[i]);
962 struct hsh_table *group_hash = gp->group_hash;
964 struct group_statistics *gs;
966 gs = hsh_find(group_hash, (void *) indep_val );
970 gs = (struct group_statistics *)
971 xmalloc (sizeof(struct group_statistics));
978 gs->minimum = DBL_MAX;
979 gs->maximum = -DBL_MAX;
981 hsh_insert ( group_hash, (void *) gs );
984 if (! value_is_missing(val,v) )
986 struct group_statistics *totals = &gp->ugs;
989 totals->sum+=weight * val->f;
990 totals->ssq+=weight * val->f * val->f;
992 if ( val->f * weight < totals->minimum )
993 totals->minimum = val->f * weight;
995 if ( val->f * weight > totals->maximum )
996 totals->maximum = val->f * weight;
999 gs->sum+=weight * val->f;
1000 gs->ssq+=weight * val->f * val->f;
1002 if ( val->f * weight < gs->minimum )
1003 gs->minimum = val->f * weight;
1005 if ( val->f * weight > gs->maximum )
1006 gs->maximum = val->f * weight;
1009 gp->n_groups = hsh_count ( group_hash );
1013 casereader_destroy (r);
1018 if ( stat_tables & STAT_HOMO )
1019 levene(cf, indep_var, n_vars, vars,
1020 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1023 ostensible_number_of_groups = hsh_count (global_group_hash);
1032 /* Post calculations for the ONEWAY command */
1034 postcalc ( struct cmd_oneway *cmd UNUSED )
1039 for(i = 0; i < n_vars ; ++i)
1041 struct group_proc *gp = group_proc_get (vars[i]);
1042 struct hsh_table *group_hash = gp->group_hash;
1043 struct group_statistics *totals = &gp->ugs;
1045 struct hsh_iterator g;
1046 struct group_statistics *gs;
1048 for (gs = hsh_first (group_hash,&g);
1050 gs = hsh_next(group_hash,&g))
1052 gs->mean=gs->sum / gs->n;
1053 gs->s_std_dev= sqrt(
1054 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1059 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1062 gs->se_mean = gs->std_dev / sqrt(gs->n);
1063 gs->mean_diff= gs->sum_diff / gs->n;
1069 totals->mean = totals->sum / totals->n;
1070 totals->std_dev= sqrt(
1071 totals->n/(totals->n-1) *
1072 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1075 totals->se_mean = totals->std_dev / sqrt(totals->n);