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);
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;
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 const char *s = var_to_string(vars[i]);
306 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
307 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
308 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
309 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
312 tab_hline(t, TAL_1, 0, n_cols - 1 , i * 3 + 1);
315 struct group_proc *gp = group_proc_get (vars[i]);
316 const double sst = totals->ssq - ( totals->sum * totals->sum) / totals->n ;
317 const double df1 = gp->n_groups - 1;
318 const double df2 = totals->n - gp->n_groups ;
319 const double msa = ssa / df1;
321 gp->mse = (sst - ssa) / df2;
324 /* Sums of Squares */
325 tab_float (t, 2, i * 3 + 1, 0, ssa, 10, 2);
326 tab_float (t, 2, i * 3 + 3, 0, sst, 10, 2);
327 tab_float (t, 2, i * 3 + 2, 0, sst - ssa, 10, 2);
330 /* Degrees of freedom */
331 tab_float (t, 3, i * 3 + 1, 0, df1, 4, 0);
332 tab_float (t, 3, i * 3 + 2, 0, df2, 4, 0);
333 tab_float (t, 3, i * 3 + 3, 0, totals->n - 1, 4, 0);
336 tab_float (t, 4, i * 3 + 1, TAB_RIGHT, msa, 8, 3);
337 tab_float (t, 4, i * 3 + 2, TAB_RIGHT, gp->mse, 8, 3);
341 const double F = msa/gp->mse ;
344 tab_float (t, 5, i * 3 + 1, 0, F, 8, 3);
346 /* The significance */
347 tab_float (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
355 tab_title (t, 0, _("ANOVA"));
361 /* Show the descriptives table */
363 show_descriptives(void)
370 const double confidence=0.95;
371 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 hsh_iterator g;
426 struct group_statistics *gs;
427 struct group_statistics *totals = &gp->ugs;
430 const char *s = var_to_string(vars[v]);
432 struct hsh_table *group_hash = gp->group_hash;
435 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
437 tab_hline(t, TAL_1, 0, n_cols - 1 , row);
440 for (gs = hsh_first (group_hash,&g);
442 gs = hsh_next(group_hash,&g))
444 tab_text (t, 1, row + count,
445 TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
447 /* Now fill in the numbers ... */
449 tab_float (t, 2, row + count, 0, gs->n, 8,0);
451 tab_float (t, 3, row + count, 0, gs->mean,8,2);
453 tab_float (t, 4, row + count, 0, gs->std_dev,8,2);
455 std_error = gs->std_dev/sqrt(gs->n) ;
456 tab_float (t, 5, row + count, 0,
459 /* Now the confidence interval */
461 T = gsl_cdf_tdist_Qinv(q,gs->n - 1);
463 tab_float(t, 6, row + count, 0,
464 gs->mean - T * std_error, 8, 2);
466 tab_float(t, 7, row + count, 0,
467 gs->mean + T * std_error, 8, 2);
471 tab_float(t, 8, row + count, 0, gs->minimum, 8, 2);
472 tab_float(t, 9, row + count, 0, gs->maximum, 8, 2);
477 tab_text (t, 1, row + count,
478 TAB_LEFT | TAT_TITLE ,_("Total"));
480 tab_float (t, 2, row + count, 0, totals->n, 8,0);
482 tab_float (t, 3, row + count, 0, totals->mean, 8,2);
484 tab_float (t, 4, row + count, 0, totals->std_dev,8,2);
486 std_error = totals->std_dev/sqrt(totals->n) ;
488 tab_float (t, 5, row + count, 0, std_error, 8,2);
490 /* Now the confidence interval */
492 T = gsl_cdf_tdist_Qinv(q,totals->n - 1);
494 tab_float(t, 6, row + count, 0,
495 totals->mean - T * std_error, 8, 2);
497 tab_float(t, 7, row + count, 0,
498 totals->mean + T * std_error, 8, 2);
502 tab_float(t, 8, row + count, 0, totals->minimum, 8, 2);
503 tab_float(t, 9, row + count, 0, totals->maximum, 8, 2);
505 row += gp->n_groups + 1;
514 /* Show the homogeneity table */
516 show_homogeneity(void)
520 int n_rows = n_vars + 1;
525 t = tab_create (n_cols,n_rows,0);
526 tab_headers (t, 1, 0, 1, 0);
527 tab_dim (t, tab_natural_dimensions);
529 /* Put a frame around the entire box, and vertical lines inside */
534 n_cols - 1, n_rows - 1);
537 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
538 tab_vline(t, TAL_2, 1, 0, n_rows - 1);
541 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
542 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
543 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
544 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Significance"));
547 tab_title (t, 0, _("Test of Homogeneity of Variances"));
549 for ( v=0 ; v < n_vars ; ++v )
552 const struct variable *var = vars[v];
553 const struct group_proc *gp = group_proc_get (vars[v]);
554 const char *s = var_to_string(var);
555 const struct group_statistics *totals = &gp->ugs;
557 const double df1 = gp->n_groups - 1;
558 const double df2 = totals->n - gp->n_groups ;
560 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
563 tab_float (t, 1, v + 1, TAB_RIGHT, F, 8,3);
564 tab_float (t, 2, v + 1, TAB_RIGHT, df1 ,8,0);
565 tab_float (t, 3, v + 1, TAB_RIGHT, df2 ,8,0);
567 /* Now the significance */
568 tab_float (t, 4, v + 1, TAB_RIGHT,gsl_cdf_fdist_Q(F,df1,df2), 8, 3);
577 /* Show the contrast coefficients table */
579 show_contrast_coeffs(short *bad_contrast)
581 int n_cols = 2 + ostensible_number_of_groups;
582 int n_rows = 2 + cmd.sbc_contrast;
583 struct hsh_iterator g;
584 union value *group_value;
591 t = tab_create (n_cols,n_rows,0);
592 tab_headers (t, 2, 0, 2, 0);
593 tab_dim (t, tab_natural_dimensions);
595 /* Put a frame around the entire box, and vertical lines inside */
600 n_cols - 1, n_rows - 1);
616 tab_hline(t, TAL_1, 2, n_cols - 1, 1);
619 tab_hline(t, TAL_2, 0, n_cols - 1, 2);
620 tab_vline(t, TAL_2, 2, 0, n_rows - 1);
623 tab_title (t, 0, _("Contrast Coefficients"));
625 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
629 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
630 var_to_string(indep_var));
632 for (group_value = hsh_first (global_group_hash,&g);
634 group_value = hsh_next(global_group_hash,&g))
638 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
639 value_to_string(group_value,indep_var));
641 for (i = 0 ; i < cmd.sbc_contrast ; ++i )
644 tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
646 if ( bad_contrast[i] )
647 tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
649 tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
650 subc_list_double_at(&cmd.dl_contrast[i],count)
662 /* Show the results of the contrast tests */
664 show_contrast_tests(short *bad_contrast)
668 int n_rows = 1 + n_vars * 2 * cmd.sbc_contrast;
672 t = tab_create (n_cols,n_rows,0);
673 tab_headers (t, 3, 0, 1, 0);
674 tab_dim (t, tab_natural_dimensions);
676 /* Put a frame around the entire box, and vertical lines inside */
681 n_cols - 1, n_rows - 1);
689 tab_hline(t, TAL_2, 0, n_cols - 1, 1);
690 tab_vline(t, TAL_2, 3, 0, n_rows - 1);
693 tab_title (t, 0, _("Contrast Tests"));
695 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
696 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
697 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
698 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
699 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
700 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
702 for ( v = 0 ; v < n_vars ; ++v )
705 int lines_per_variable = 2 * cmd.sbc_contrast;
708 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
709 var_to_string(vars[v]));
711 for ( i = 0 ; i < cmd.sbc_contrast ; ++i )
714 double contrast_value = 0.0;
715 double coef_msq = 0.0;
716 struct group_proc *grp_data = group_proc_get (vars[v]);
717 struct hsh_table *group_hash = grp_data->group_hash;
718 struct hsh_iterator g;
719 struct group_statistics *gs;
722 double std_error_contrast ;
727 /* Note: The calculation of the degrees of freedom in the variances
728 not equal case is painfull!!
729 The following formula may help to understand it:
730 \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
733 \frac{\left(c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
738 double df_denominator = 0.0;
739 double df_numerator = 0.0;
744 tab_text (t, 1, (v * lines_per_variable) + i + 1,
745 TAB_LEFT | TAT_TITLE,
746 _("Assume equal variances"));
748 tab_text (t, 1, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
749 TAB_LEFT | TAT_TITLE,
750 _("Does not assume equal"));
753 tab_text (t, 2, (v * lines_per_variable) + i + 1,
754 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
757 tab_text (t, 2, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
758 TAB_CENTER | TAT_TITLE | TAT_PRINTF, "%d",i+1);
761 if ( bad_contrast[i])
764 /* FIXME: Potential danger here.
765 We're ASSUMING THE array is in the order corresponding to the
767 for (ci = 0, gs = hsh_first (group_hash,&g);
769 ++ci, gs = hsh_next(group_hash,&g))
772 const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
773 const double winv = (gs->std_dev * gs->std_dev) / gs->n;
775 contrast_value += coef * gs->mean;
777 coef_msq += (coef * coef) / gs->n ;
779 sec_vneq += (coef * coef) * (gs->std_dev * gs->std_dev ) /gs->n ;
781 df_numerator += (coef * coef) * winv;
782 df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
785 sec_vneq = sqrt(sec_vneq);
787 df_numerator = pow2(df_numerator);
789 tab_float (t, 3, (v * lines_per_variable) + i + 1,
790 TAB_RIGHT, contrast_value, 8,2);
792 tab_float (t, 3, (v * lines_per_variable) + i + 1 +
794 TAB_RIGHT, contrast_value, 8,2);
796 std_error_contrast = sqrt(grp_data->mse * coef_msq);
799 tab_float (t, 4, (v * lines_per_variable) + i + 1,
800 TAB_RIGHT, std_error_contrast,
803 T = fabs(contrast_value / std_error_contrast) ;
807 tab_float (t, 5, (v * lines_per_variable) + i + 1,
811 df = grp_data->ugs.n - grp_data->n_groups;
813 /* Degrees of Freedom */
814 tab_float (t, 6, (v * lines_per_variable) + i + 1,
819 /* Significance TWO TAILED !!*/
820 tab_float (t, 7, (v * lines_per_variable) + i + 1,
821 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
825 /* Now for the Variances NOT Equal case */
829 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
834 T = contrast_value / sec_vneq;
836 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
841 df = df_numerator / df_denominator;
844 (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
848 /* The Significance */
850 tab_float (t, 7, (v * lines_per_variable) + i + 1 + cmd.sbc_contrast,
851 TAB_RIGHT, 2 * gsl_cdf_tdist_Q(T,df),
858 tab_hline(t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
866 /* ONEWAY ANOVA Calculations */
868 static void postcalc ( struct cmd_oneway *cmd UNUSED );
870 static void precalc ( struct cmd_oneway *cmd UNUSED );
874 /* Pre calculations */
876 precalc ( struct cmd_oneway *cmd UNUSED )
880 for(i=0; i< n_vars ; ++i)
882 struct group_proc *gp = group_proc_get (vars[i]);
883 struct group_statistics *totals = &gp->ugs;
885 /* Create a hash for each of the dependent variables.
886 The hash contains a group_statistics structure,
887 and is keyed by value of the independent variable */
891 (hsh_compare_func *) compare_group,
892 (hsh_hash_func *) hash_group,
893 (hsh_free_func *) free_group,
894 (void *) indep_var->width );
901 totals->maximum = - DBL_MAX;
902 totals->minimum = DBL_MAX;
908 run_oneway(const struct casefile *cf, void *cmd_)
910 struct casereader *r;
913 struct cmd_oneway *cmd = (struct cmd_oneway *) cmd_;
915 global_group_hash = hsh_create(4,
916 (hsh_compare_func *) compare_values,
917 (hsh_hash_func *) hash_value,
919 (void *) indep_var->width );
922 for(r = casefile_get_reader (cf);
923 casereader_read (r, &c) ;
928 const double weight =
929 dict_get_case_weight(default_dict,&c,&bad_weight_warn);
931 const union value *indep_val = case_data (&c, indep_var->fv);
933 /* Deal with missing values */
934 if ( value_is_missing(indep_val,indep_var) )
937 /* Skip the entire case if /MISSING=LISTWISE is set */
938 if ( cmd->miss == ONEWAY_LISTWISE )
940 for(i = 0; i < n_vars ; ++i)
942 const struct variable *v = vars[i];
943 const union value *val = case_data (&c, v->fv);
945 if (value_is_missing(val,v) )
954 hsh_insert ( global_group_hash, (void *) indep_val );
956 for ( i = 0 ; i < n_vars ; ++i )
958 const struct variable *v = vars[i];
960 const union value *val = case_data (&c, v->fv);
962 struct group_proc *gp = group_proc_get (vars[i]);
963 struct hsh_table *group_hash = gp->group_hash;
965 struct group_statistics *gs;
967 gs = hsh_find(group_hash, (void *) indep_val );
971 gs = (struct group_statistics *)
972 xmalloc (sizeof(struct group_statistics));
979 gs->minimum = DBL_MAX;
980 gs->maximum = -DBL_MAX;
982 hsh_insert ( group_hash, (void *) gs );
985 if (! value_is_missing(val,v) )
987 struct group_statistics *totals = &gp->ugs;
990 totals->sum+=weight * val->f;
991 totals->ssq+=weight * val->f * val->f;
993 if ( val->f * weight < totals->minimum )
994 totals->minimum = val->f * weight;
996 if ( val->f * weight > totals->maximum )
997 totals->maximum = val->f * weight;
1000 gs->sum+=weight * val->f;
1001 gs->ssq+=weight * val->f * val->f;
1003 if ( val->f * weight < gs->minimum )
1004 gs->minimum = val->f * weight;
1006 if ( val->f * weight > gs->maximum )
1007 gs->maximum = val->f * weight;
1010 gp->n_groups = hsh_count ( group_hash );
1014 casereader_destroy (r);
1019 if ( stat_tables & STAT_HOMO )
1020 levene(cf, indep_var, n_vars, vars,
1021 (cmd->miss == ONEWAY_LISTWISE) ? LEV_LISTWISE : LEV_ANALYSIS ,
1024 ostensible_number_of_groups = hsh_count (global_group_hash);
1033 /* Post calculations for the ONEWAY command */
1035 postcalc ( struct cmd_oneway *cmd UNUSED )
1040 for(i = 0; i < n_vars ; ++i)
1042 struct group_proc *gp = group_proc_get (vars[i]);
1043 struct hsh_table *group_hash = gp->group_hash;
1044 struct group_statistics *totals = &gp->ugs;
1046 struct hsh_iterator g;
1047 struct group_statistics *gs;
1049 for (gs = hsh_first (group_hash,&g);
1051 gs = hsh_next(group_hash,&g))
1053 gs->mean=gs->sum / gs->n;
1054 gs->s_std_dev= sqrt(
1055 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1060 ( (gs->ssq / gs->n ) - gs->mean * gs->mean )
1063 gs->se_mean = gs->std_dev / sqrt(gs->n);
1064 gs->mean_diff= gs->sum_diff / gs->n;
1070 totals->mean = totals->sum / totals->n;
1071 totals->std_dev= sqrt(
1072 totals->n/(totals->n-1) *
1073 ( (totals->ssq / totals->n ) - totals->mean * totals->mean )
1076 totals->se_mean = totals->std_dev / sqrt(totals->n);