1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include <gsl/gsl_cdf.h>
21 #include <gsl/gsl_matrix.h>
24 #include "data/case.h"
25 #include "data/casegrouper.h"
26 #include "data/casereader.h"
27 #include "data/dataset.h"
28 #include "data/dictionary.h"
29 #include "data/format.h"
30 #include "data/value.h"
31 #include "language/command.h"
32 #include "language/dictionary/split-file.h"
33 #include "language/lexer/lexer.h"
34 #include "language/lexer/value-parser.h"
35 #include "language/lexer/variable-parser.h"
36 #include "libpspp/ll.h"
37 #include "libpspp/message.h"
38 #include "libpspp/misc.h"
39 #include "libpspp/taint.h"
40 #include "linreg/sweep.h"
41 #include "tukey/tukey.h"
42 #include "math/categoricals.h"
43 #include "math/interaction.h"
44 #include "math/covariance.h"
45 #include "math/levene.h"
46 #include "math/moments.h"
47 #include "output/tab.h"
50 #define _(msgid) gettext (msgid)
51 #define N_(msgid) msgid
53 /* Workspace variable for each dependent variable */
56 struct interaction *iact;
57 struct categoricals *cat;
58 struct covariance *cov;
72 /* Per category data */
73 struct descriptive_data
75 const struct variable *var;
90 STATS_DESCRIPTIVES = 0x0001,
91 STATS_HOMOGENEITY = 0x0002
101 struct contrasts_node
104 struct ll_list coefficient_list;
110 typedef double df_func (const struct per_var_ws *pvw, const struct moments1 *mom_i, const struct moments1 *mom_j);
111 typedef double ts_func (int k, const struct moments1 *mom_i, const struct moments1 *mom_j, double std_err);
112 typedef double p1tail_func (double ts, double df1, double df2);
114 typedef double pinv_func (double std_err, double alpha, double df, int k, const struct moments1 *mom_i, const struct moments1 *mom_j);
132 const struct variable **vars;
134 const struct variable *indep_var;
136 enum statistics stats;
138 enum missing_type missing_type;
139 enum mv_class exclude;
141 /* List of contrasts */
142 struct ll_list contrast_list;
144 /* The weight variable */
145 const struct variable *wv;
147 /* The confidence level for multiple comparisons */
155 df_common (const struct per_var_ws *pvw, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
157 return pvw->n - pvw->n_groups;
161 df_individual (const struct per_var_ws *pvw UNUSED, const struct moments1 *mom_i, const struct moments1 *mom_j)
167 moments1_calculate (mom_i, &n_i, NULL, &var_i, 0, 0);
168 moments1_calculate (mom_j, &n_j, NULL, &var_j, 0, 0);
170 if ( n_i <= 1.0 || n_j <= 1.0)
173 nom = pow2 (var_i/n_i + var_j/n_j);
174 denom = pow2 (var_i/n_i) / (n_i - 1) + pow2 (var_j/n_j) / (n_j - 1);
179 static double lsd_pinv (double std_err, double alpha, double df, int k UNUSED, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
181 return std_err * gsl_cdf_tdist_Pinv (1.0 - alpha / 2.0, df);
184 static double bonferroni_pinv (double std_err, double alpha, double df, int k, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
186 const int m = k * (k - 1) / 2;
187 return std_err * gsl_cdf_tdist_Pinv (1.0 - alpha / (2.0 * m), df);
190 static double sidak_pinv (double std_err, double alpha, double df, int k, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
192 const double m = k * (k - 1) / 2;
193 double lp = 1.0 - exp (log (1.0 - alpha) / m ) ;
194 return std_err * gsl_cdf_tdist_Pinv (1.0 - lp / 2.0, df);
197 static double tukey_pinv (double std_err, double alpha, double df, int k, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
199 if ( k < 2 || df < 2)
202 return std_err / sqrt (2.0) * qtukey (1 - alpha, 1.0, k, df, 1, 0);
205 static double scheffe_pinv (double std_err, double alpha, double df, int k, const struct moments1 *mom_i UNUSED, const struct moments1 *mom_j UNUSED)
207 double x = (k - 1) * gsl_cdf_fdist_Pinv (1.0 - alpha, k - 1, df);
208 return std_err * sqrt (x);
211 static double gh_pinv (double std_err UNUSED, double alpha, double df, int k, const struct moments1 *mom_i, const struct moments1 *mom_j)
213 double n_i, mean_i, var_i;
214 double n_j, mean_j, var_j;
217 moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
218 moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
220 m = sqrt ((var_i/n_i + var_j/n_j) / 2.0);
222 if ( k < 2 || df < 2)
225 return m * qtukey (1 - alpha, 1.0, k, df, 1, 0);
230 multiple_comparison_sig (double std_err,
231 const struct per_var_ws *pvw,
232 const struct descriptive_data *dd_i, const struct descriptive_data *dd_j,
233 const struct posthoc *ph)
235 int k = pvw->n_groups;
236 double df = ph->dff (pvw, dd_i->mom, dd_j->mom);
237 double ts = ph->tsf (k, dd_i->mom, dd_j->mom, std_err);
240 return ph->p1f (ts, k - 1, df);
244 mc_half_range (const struct oneway_spec *cmd, const struct per_var_ws *pvw, double std_err, const struct descriptive_data *dd_i, const struct descriptive_data *dd_j, const struct posthoc *ph)
246 int k = pvw->n_groups;
247 double df = ph->dff (pvw, dd_i->mom, dd_j->mom);
251 return ph->pinv (std_err, cmd->alpha, df, k, dd_i->mom, dd_j->mom);
254 static double tukey_1tailsig (double ts, double df1, double df2)
258 if (df2 < 2 || df1 < 1)
261 twotailedsig = 1.0 - ptukey (ts, 1.0, df1 + 1, df2, 1, 0);
263 return twotailedsig / 2.0;
266 static double lsd_1tailsig (double ts, double df1 UNUSED, double df2)
268 return ts < 0 ? gsl_cdf_tdist_P (ts, df2) : gsl_cdf_tdist_Q (ts, df2);
271 static double sidak_1tailsig (double ts, double df1, double df2)
273 double ex = (df1 + 1.0) * df1 / 2.0;
274 double lsd_sig = 2 * lsd_1tailsig (ts, df1, df2);
276 return 0.5 * (1.0 - pow (1.0 - lsd_sig, ex));
279 static double bonferroni_1tailsig (double ts, double df1, double df2)
281 const int m = (df1 + 1) * df1 / 2;
283 double p = ts < 0 ? gsl_cdf_tdist_P (ts, df2) : gsl_cdf_tdist_Q (ts, df2);
286 return p > 0.5 ? 0.5 : p;
289 static double scheffe_1tailsig (double ts, double df1, double df2)
291 return 0.5 * gsl_cdf_fdist_Q (ts, df1, df2);
295 static double tukey_test_stat (int k UNUSED, const struct moments1 *mom_i, const struct moments1 *mom_j, double std_err)
298 double n_i, mean_i, var_i;
299 double n_j, mean_j, var_j;
301 moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
302 moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
304 ts = (mean_i - mean_j) / std_err;
305 ts = fabs (ts) * sqrt (2.0);
310 static double lsd_test_stat (int k UNUSED, const struct moments1 *mom_i, const struct moments1 *mom_j, double std_err)
312 double n_i, mean_i, var_i;
313 double n_j, mean_j, var_j;
315 moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
316 moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
318 return (mean_i - mean_j) / std_err;
321 static double scheffe_test_stat (int k, const struct moments1 *mom_i, const struct moments1 *mom_j, double std_err)
324 double n_i, mean_i, var_i;
325 double n_j, mean_j, var_j;
327 moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
328 moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
330 t = (mean_i - mean_j) / std_err;
337 static double gh_test_stat (int k UNUSED, const struct moments1 *mom_i, const struct moments1 *mom_j, double std_err UNUSED)
341 double n_i, mean_i, var_i;
342 double n_j, mean_j, var_j;
344 moments1_calculate (mom_i, &n_i, &mean_i, &var_i, 0, 0);
345 moments1_calculate (mom_j, &n_j, &mean_j, &var_j, 0, 0);
347 thing = var_i / n_i + var_j / n_j;
349 thing = sqrt (thing);
351 ts = (mean_i - mean_j) / thing;
358 static const struct posthoc ph_tests [] =
360 { "LSD", N_("LSD"), df_common, lsd_test_stat, lsd_1tailsig, lsd_pinv},
361 { "TUKEY", N_("Tukey HSD"), df_common, tukey_test_stat, tukey_1tailsig, tukey_pinv},
362 { "BONFERRONI", N_("Bonferroni"), df_common, lsd_test_stat, bonferroni_1tailsig, bonferroni_pinv},
363 { "SCHEFFE", N_("Scheffé"), df_common, scheffe_test_stat, scheffe_1tailsig, scheffe_pinv},
364 { "GH", N_("Games-Howell"), df_individual, gh_test_stat, tukey_1tailsig, gh_pinv},
365 { "SIDAK", N_("Šidák"), df_common, lsd_test_stat, sidak_1tailsig, sidak_pinv}
369 struct oneway_workspace
371 /* The number of distinct values of the independent variable, when all
372 missing values are disregarded */
373 int actual_number_of_groups;
375 struct per_var_ws *vws;
377 /* An array of descriptive data. One for each dependent variable */
378 struct descriptive_data **dd_total;
381 /* Routines to show the output tables */
382 static void show_anova_table (const struct oneway_spec *, const struct oneway_workspace *);
383 static void show_descriptives (const struct oneway_spec *, const struct oneway_workspace *);
384 static void show_homogeneity (const struct oneway_spec *, const struct oneway_workspace *);
386 static void output_oneway (const struct oneway_spec *, struct oneway_workspace *ws);
387 static void run_oneway (const struct oneway_spec *cmd, struct casereader *input, const struct dataset *ds);
391 destroy_coeff_list (struct contrasts_node *coeff_list)
393 struct coeff_node *cn = NULL;
394 struct coeff_node *cnx = NULL;
395 struct ll_list *cl = &coeff_list->coefficient_list;
397 ll_for_each_safe (cn, cnx, struct coeff_node, ll, cl)
406 oneway_cleanup (struct oneway_spec *cmd)
408 struct contrasts_node *coeff_list = NULL;
409 struct contrasts_node *coeff_next = NULL;
410 ll_for_each_safe (coeff_list, coeff_next, struct contrasts_node, ll, &cmd->contrast_list)
412 destroy_coeff_list (coeff_list);
421 cmd_oneway (struct lexer *lexer, struct dataset *ds)
423 const struct dictionary *dict = dataset_dict (ds);
424 struct oneway_spec oneway ;
427 oneway.indep_var = NULL;
429 oneway.missing_type = MISS_ANALYSIS;
430 oneway.exclude = MV_ANY;
431 oneway.wv = dict_get_weight (dict);
433 oneway.posthoc = NULL;
434 oneway.n_posthoc = 0;
436 ll_init (&oneway.contrast_list);
439 if ( lex_match (lexer, T_SLASH))
441 if (!lex_force_match_id (lexer, "VARIABLES"))
445 lex_match (lexer, T_EQUALS);
448 if (!parse_variables_const (lexer, dict,
449 &oneway.vars, &oneway.n_vars,
450 PV_NO_DUPLICATE | PV_NUMERIC))
453 if (!lex_force_match (lexer, T_BY))
456 oneway.indep_var = parse_variable_const (lexer, dict);
457 if (oneway.indep_var == NULL)
460 while (lex_token (lexer) != T_ENDCMD)
462 lex_match (lexer, T_SLASH);
464 if (lex_match_id (lexer, "STATISTICS"))
466 lex_match (lexer, T_EQUALS);
467 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
469 if (lex_match_id (lexer, "DESCRIPTIVES"))
471 oneway.stats |= STATS_DESCRIPTIVES;
473 else if (lex_match_id (lexer, "HOMOGENEITY"))
475 oneway.stats |= STATS_HOMOGENEITY;
479 lex_error (lexer, NULL);
484 else if (lex_match_id (lexer, "POSTHOC"))
486 lex_match (lexer, T_EQUALS);
487 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
491 for (p = 0 ; p < sizeof (ph_tests) / sizeof (struct posthoc); ++p)
493 if (lex_match_id (lexer, ph_tests[p].syntax))
496 oneway.posthoc = xrealloc (oneway.posthoc, sizeof (*oneway.posthoc) * oneway.n_posthoc);
497 oneway.posthoc[oneway.n_posthoc - 1] = p;
502 if ( method == false)
504 if (lex_match_id (lexer, "ALPHA"))
506 if ( !lex_force_match (lexer, T_LPAREN))
508 if (! lex_force_num (lexer))
510 oneway.alpha = lex_number (lexer);
512 if ( !lex_force_match (lexer, T_RPAREN))
517 msg (SE, _("The post hoc analysis method %s is not supported."), lex_tokcstr (lexer));
518 lex_error (lexer, NULL);
524 else if (lex_match_id (lexer, "CONTRAST"))
526 struct contrasts_node *cl = xzalloc (sizeof *cl);
528 struct ll_list *coefficient_list = &cl->coefficient_list;
529 lex_match (lexer, T_EQUALS);
531 ll_init (coefficient_list);
533 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
535 if ( lex_is_number (lexer))
537 struct coeff_node *cc = xmalloc (sizeof *cc);
538 cc->coeff = lex_number (lexer);
540 ll_push_tail (coefficient_list, &cc->ll);
545 destroy_coeff_list (cl);
546 lex_error (lexer, NULL);
551 if ( ll_count (coefficient_list) <= 0)
554 ll_push_tail (&oneway.contrast_list, &cl->ll);
556 else if (lex_match_id (lexer, "MISSING"))
558 lex_match (lexer, T_EQUALS);
559 while (lex_token (lexer) != T_ENDCMD && lex_token (lexer) != T_SLASH)
561 if (lex_match_id (lexer, "INCLUDE"))
563 oneway.exclude = MV_SYSTEM;
565 else if (lex_match_id (lexer, "EXCLUDE"))
567 oneway.exclude = MV_ANY;
569 else if (lex_match_id (lexer, "LISTWISE"))
571 oneway.missing_type = MISS_LISTWISE;
573 else if (lex_match_id (lexer, "ANALYSIS"))
575 oneway.missing_type = MISS_ANALYSIS;
579 lex_error (lexer, NULL);
586 lex_error (lexer, NULL);
593 struct casegrouper *grouper;
594 struct casereader *group;
597 grouper = casegrouper_create_splits (proc_open (ds), dict);
598 while (casegrouper_get_next_group (grouper, &group))
599 run_oneway (&oneway, group, ds);
600 ok = casegrouper_destroy (grouper);
601 ok = proc_commit (ds) && ok;
604 oneway_cleanup (&oneway);
609 oneway_cleanup (&oneway);
618 static struct descriptive_data *
619 dd_create (const struct variable *var)
621 struct descriptive_data *dd = xmalloc (sizeof *dd);
623 dd->mom = moments1_create (MOMENT_VARIANCE);
624 dd->minimum = DBL_MAX;
625 dd->maximum = -DBL_MAX;
632 dd_destroy (struct descriptive_data *dd)
634 moments1_destroy (dd->mom);
639 makeit (const void *aux1, void *aux2 UNUSED)
641 const struct variable *var = aux1;
643 struct descriptive_data *dd = dd_create (var);
649 killit (const void *aux1 UNUSED, void *aux2 UNUSED, void *user_data)
651 struct descriptive_data *dd = user_data;
658 updateit (const void *aux1, void *aux2, void *user_data,
659 const struct ccase *c, double weight)
661 struct descriptive_data *dd = user_data;
663 const struct variable *varp = aux1;
665 const union value *valx = case_data (c, varp);
667 struct descriptive_data *dd_total = aux2;
669 moments1_add (dd->mom, valx->f, weight);
670 if (valx->f < dd->minimum)
671 dd->minimum = valx->f;
673 if (valx->f > dd->maximum)
674 dd->maximum = valx->f;
677 const struct variable *var = dd_total->var;
678 const union value *val = case_data (c, var);
680 moments1_add (dd_total->mom,
684 if (val->f < dd_total->minimum)
685 dd_total->minimum = val->f;
687 if (val->f > dd_total->maximum)
688 dd_total->maximum = val->f;
693 run_oneway (const struct oneway_spec *cmd,
694 struct casereader *input,
695 const struct dataset *ds)
699 struct dictionary *dict = dataset_dict (ds);
700 struct casereader *reader;
703 struct oneway_workspace ws;
705 ws.actual_number_of_groups = 0;
706 ws.vws = xzalloc (cmd->n_vars * sizeof (*ws.vws));
707 ws.dd_total = xmalloc (sizeof (struct descriptive_data) * cmd->n_vars);
709 for (v = 0 ; v < cmd->n_vars; ++v)
710 ws.dd_total[v] = dd_create (cmd->vars[v]);
712 for (v = 0; v < cmd->n_vars; ++v)
714 struct payload payload;
715 payload.create = makeit;
716 payload.update = updateit;
717 payload.calculate = NULL;
718 payload.destroy = killit;
720 ws.vws[v].iact = interaction_create (cmd->indep_var);
721 ws.vws[v].cat = categoricals_create (&ws.vws[v].iact, 1, cmd->wv,
722 cmd->exclude, cmd->exclude);
724 categoricals_set_payload (ws.vws[v].cat, &payload,
725 CONST_CAST (struct variable *, cmd->vars[v]),
729 ws.vws[v].cov = covariance_2pass_create (1, &cmd->vars[v],
731 cmd->wv, cmd->exclude);
732 ws.vws[v].nl = levene_create (var_get_width (cmd->indep_var), NULL);
735 c = casereader_peek (input, 0);
738 casereader_destroy (input);
741 output_split_file_values (ds, c);
744 taint = taint_clone (casereader_get_taint (input));
746 input = casereader_create_filter_missing (input, &cmd->indep_var, 1,
747 cmd->exclude, NULL, NULL);
748 if (cmd->missing_type == MISS_LISTWISE)
749 input = casereader_create_filter_missing (input, cmd->vars, cmd->n_vars,
750 cmd->exclude, NULL, NULL);
751 input = casereader_create_filter_weight (input, dict, NULL, NULL);
753 reader = casereader_clone (input);
754 for (; (c = casereader_read (reader)) != NULL; case_unref (c))
757 double w = dict_get_case_weight (dict, c, NULL);
759 for (i = 0; i < cmd->n_vars; ++i)
761 struct per_var_ws *pvw = &ws.vws[i];
762 const struct variable *v = cmd->vars[i];
763 const union value *val = case_data (c, v);
765 if ( MISS_ANALYSIS == cmd->missing_type)
767 if ( var_is_value_missing (v, val, cmd->exclude))
771 covariance_accumulate_pass1 (pvw->cov, c);
772 levene_pass_one (pvw->nl, val->f, w, case_data (c, cmd->indep_var));
775 casereader_destroy (reader);
777 reader = casereader_clone (input);
778 for ( ; (c = casereader_read (reader) ); case_unref (c))
781 double w = dict_get_case_weight (dict, c, NULL);
782 for (i = 0; i < cmd->n_vars; ++i)
784 struct per_var_ws *pvw = &ws.vws[i];
785 const struct variable *v = cmd->vars[i];
786 const union value *val = case_data (c, v);
788 if ( MISS_ANALYSIS == cmd->missing_type)
790 if ( var_is_value_missing (v, val, cmd->exclude))
794 covariance_accumulate_pass2 (pvw->cov, c);
795 levene_pass_two (pvw->nl, val->f, w, case_data (c, cmd->indep_var));
798 casereader_destroy (reader);
800 reader = casereader_clone (input);
801 for ( ; (c = casereader_read (reader) ); case_unref (c))
804 double w = dict_get_case_weight (dict, c, NULL);
806 for (i = 0; i < cmd->n_vars; ++i)
808 struct per_var_ws *pvw = &ws.vws[i];
809 const struct variable *v = cmd->vars[i];
810 const union value *val = case_data (c, v);
812 if ( MISS_ANALYSIS == cmd->missing_type)
814 if ( var_is_value_missing (v, val, cmd->exclude))
818 levene_pass_three (pvw->nl, val->f, w, case_data (c, cmd->indep_var));
821 casereader_destroy (reader);
824 for (v = 0; v < cmd->n_vars; ++v)
826 const gsl_matrix *ucm;
828 struct per_var_ws *pvw = &ws.vws[v];
829 const struct categoricals *cats = covariance_get_categoricals (pvw->cov);
830 const bool ok = categoricals_sane (cats);
835 _("Dependent variable %s has no non-missing values. No analysis for this variable will be done."),
836 var_get_name (cmd->vars[v]));
840 ucm = covariance_calculate_unnormalized (pvw->cov);
842 cm = gsl_matrix_alloc (ucm->size1, ucm->size2);
843 gsl_matrix_memcpy (cm, ucm);
845 moments1_calculate (ws.dd_total[v]->mom, &pvw->n, NULL, NULL, NULL, NULL);
847 pvw->sst = gsl_matrix_get (cm, 0, 0);
851 pvw->sse = gsl_matrix_get (cm, 0, 0);
852 gsl_matrix_free (cm);
854 pvw->ssa = pvw->sst - pvw->sse;
856 pvw->n_groups = categoricals_n_total (cats);
858 pvw->mse = (pvw->sst - pvw->ssa) / (pvw->n - pvw->n_groups);
861 for (v = 0; v < cmd->n_vars; ++v)
863 const struct categoricals *cats = covariance_get_categoricals (ws.vws[v].cov);
865 if ( ! categoricals_is_complete (cats))
870 if (categoricals_n_total (cats) > ws.actual_number_of_groups)
871 ws.actual_number_of_groups = categoricals_n_total (cats);
874 casereader_destroy (input);
876 if (!taint_has_tainted_successor (taint))
877 output_oneway (cmd, &ws);
879 taint_destroy (taint);
883 for (v = 0; v < cmd->n_vars; ++v)
885 covariance_destroy (ws.vws[v].cov);
886 levene_destroy (ws.vws[v].nl);
887 dd_destroy (ws.dd_total[v]);
888 interaction_destroy (ws.vws[v].iact);
895 static void show_contrast_coeffs (const struct oneway_spec *cmd, const struct oneway_workspace *ws);
896 static void show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspace *ws);
897 static void show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace *ws, int depvar);
900 output_oneway (const struct oneway_spec *cmd, struct oneway_workspace *ws)
904 /* Check the sanity of the given contrast values */
905 struct contrasts_node *coeff_list = NULL;
906 struct contrasts_node *coeff_next = NULL;
907 ll_for_each_safe (coeff_list, coeff_next, struct contrasts_node, ll, &cmd->contrast_list)
909 struct coeff_node *cn = NULL;
911 struct ll_list *cl = &coeff_list->coefficient_list;
914 if (ll_count (cl) != ws->actual_number_of_groups)
917 _("In contrast list %zu, the number of coefficients (%zu) does not equal the number of groups (%d). This contrast list will be ignored."),
918 i, ll_count (cl), ws->actual_number_of_groups);
920 ll_remove (&coeff_list->ll);
921 destroy_coeff_list (coeff_list);
925 ll_for_each (cn, struct coeff_node, ll, cl)
929 msg (SW, _("Coefficients for contrast %zu do not total zero"), i);
932 if (cmd->stats & STATS_DESCRIPTIVES)
933 show_descriptives (cmd, ws);
935 if (cmd->stats & STATS_HOMOGENEITY)
936 show_homogeneity (cmd, ws);
938 show_anova_table (cmd, ws);
940 if (ll_count (&cmd->contrast_list) > 0)
942 show_contrast_coeffs (cmd, ws);
943 show_contrast_tests (cmd, ws);
949 for (v = 0 ; v < cmd->n_vars; ++v)
951 const struct categoricals *cats = covariance_get_categoricals (ws->vws[v].cov);
953 if ( categoricals_is_complete (cats))
954 show_comparisons (cmd, ws, v);
960 /* Show the ANOVA table */
962 show_anova_table (const struct oneway_spec *cmd, const struct oneway_workspace *ws)
966 size_t n_rows = cmd->n_vars * 3 + 1;
968 struct tab_table *t = tab_create (n_cols, n_rows);
970 tab_headers (t, 2, 0, 1, 0);
976 n_cols - 1, n_rows - 1);
978 tab_hline (t, TAL_2, 0, n_cols - 1, 1 );
979 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
980 tab_vline (t, TAL_0, 1, 0, 0);
982 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Sum of Squares"));
983 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df"));
984 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Mean Square"));
985 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("F"));
986 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("Sig."));
989 for (i = 0; i < cmd->n_vars; ++i)
994 const char *s = var_to_string (cmd->vars[i]);
995 const struct per_var_ws *pvw = &ws->vws[i];
997 moments1_calculate (ws->dd_total[i]->mom, &n, NULL, NULL, NULL, NULL);
999 df1 = pvw->n_groups - 1;
1000 df2 = n - pvw->n_groups;
1001 msa = pvw->ssa / df1;
1003 tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s);
1004 tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups"));
1005 tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups"));
1006 tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total"));
1009 tab_hline (t, TAL_1, 0, n_cols - 1, i * 3 + 1);
1012 /* Sums of Squares */
1013 tab_double (t, 2, i * 3 + 1, 0, pvw->ssa, NULL, RC_OTHER);
1014 tab_double (t, 2, i * 3 + 3, 0, pvw->sst, NULL, RC_OTHER);
1015 tab_double (t, 2, i * 3 + 2, 0, pvw->sse, NULL, RC_OTHER);
1018 /* Degrees of freedom */
1019 tab_double (t, 3, i * 3 + 1, 0, df1, NULL, RC_INTEGER);
1020 tab_double (t, 3, i * 3 + 2, 0, df2, NULL, RC_INTEGER);
1021 tab_double (t, 3, i * 3 + 3, 0, n - 1, NULL, RC_INTEGER);
1024 tab_double (t, 4, i * 3 + 1, TAB_RIGHT, msa, NULL, RC_OTHER);
1025 tab_double (t, 4, i * 3 + 2, TAB_RIGHT, pvw->mse, NULL, RC_OTHER);
1028 const double F = msa / pvw->mse ;
1031 tab_double (t, 5, i * 3 + 1, 0, F, NULL, RC_OTHER);
1033 /* The significance */
1034 tab_double (t, 6, i * 3 + 1, 0, gsl_cdf_fdist_Q (F, df1, df2), NULL, RC_PVALUE);
1038 tab_title (t, _("ANOVA"));
1043 /* Show the descriptives table */
1045 show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace *ws)
1049 struct tab_table *t;
1052 const double confidence = 0.95;
1053 const double q = (1.0 - confidence) / 2.0;
1055 const struct fmt_spec *wfmt = cmd->wv ? var_get_print_format (cmd->wv) : &F_8_0;
1059 for (v = 0; v < cmd->n_vars; ++v)
1060 n_rows += ws->actual_number_of_groups + 1;
1062 t = tab_create (n_cols, n_rows);
1063 tab_set_format (t, RC_WEIGHT, wfmt);
1064 tab_headers (t, 2, 0, 2, 0);
1066 /* Put a frame around the entire box, and vertical lines inside */
1071 n_cols - 1, n_rows - 1);
1073 /* Underline headers */
1074 tab_hline (t, TAL_2, 0, n_cols - 1, 2);
1075 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
1077 tab_text (t, 2, 1, TAB_CENTER | TAT_TITLE, _("N"));
1078 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Mean"));
1079 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Deviation"));
1080 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
1083 tab_vline (t, TAL_0, 7, 0, 0);
1084 tab_hline (t, TAL_1, 6, 7, 1);
1085 tab_joint_text_format (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE,
1086 _("%g%% Confidence Interval for Mean"),
1089 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
1090 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
1092 tab_text (t, 8, 1, TAB_CENTER | TAT_TITLE, _("Minimum"));
1093 tab_text (t, 9, 1, TAB_CENTER | TAT_TITLE, _("Maximum"));
1095 tab_title (t, _("Descriptives"));
1098 for (v = 0; v < cmd->n_vars; ++v)
1100 const char *s = var_to_string (cmd->vars[v]);
1101 const struct fmt_spec *fmt = var_get_print_format (cmd->vars[v]);
1105 struct per_var_ws *pvw = &ws->vws[v];
1106 const struct categoricals *cats = covariance_get_categoricals (pvw->cov);
1108 tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
1110 tab_hline (t, TAL_1, 0, n_cols - 1, row);
1112 for (count = 0; count < categoricals_n_total (cats); ++count)
1115 double n, mean, variance;
1116 double std_dev, std_error ;
1120 const struct ccase *gcc = categoricals_get_case_by_category (cats, count);
1121 const struct descriptive_data *dd = categoricals_get_user_data_by_category (cats, count);
1123 moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL);
1125 std_dev = sqrt (variance);
1126 std_error = std_dev / sqrt (n) ;
1128 ds_init_empty (&vstr);
1130 var_append_value_name (cmd->indep_var, case_data (gcc, cmd->indep_var), &vstr);
1132 tab_text (t, 1, row + count,
1133 TAB_LEFT | TAT_TITLE,
1138 /* Now fill in the numbers ... */
1140 tab_double (t, 2, row + count, 0, n, NULL, RC_WEIGHT);
1142 tab_double (t, 3, row + count, 0, mean, NULL, RC_OTHER);
1144 tab_double (t, 4, row + count, 0, std_dev, NULL, RC_OTHER);
1147 tab_double (t, 5, row + count, 0, std_error, NULL, RC_OTHER);
1149 /* Now the confidence interval */
1151 T = gsl_cdf_tdist_Qinv (q, n - 1);
1153 tab_double (t, 6, row + count, 0,
1154 mean - T * std_error, NULL, RC_OTHER);
1156 tab_double (t, 7, row + count, 0,
1157 mean + T * std_error, NULL, RC_OTHER);
1161 tab_double (t, 8, row + count, 0, dd->minimum, fmt, RC_OTHER);
1162 tab_double (t, 9, row + count, 0, dd->maximum, fmt, RC_OTHER);
1165 if (categoricals_is_complete (cats))
1168 double n, mean, variance;
1172 moments1_calculate (ws->dd_total[v]->mom, &n, &mean, &variance, NULL, NULL);
1174 std_dev = sqrt (variance);
1175 std_error = std_dev / sqrt (n) ;
1177 tab_text (t, 1, row + count,
1178 TAB_LEFT | TAT_TITLE, _("Total"));
1180 tab_double (t, 2, row + count, 0, n, NULL, RC_WEIGHT);
1182 tab_double (t, 3, row + count, 0, mean, NULL, RC_OTHER);
1184 tab_double (t, 4, row + count, 0, std_dev, NULL, RC_OTHER);
1186 tab_double (t, 5, row + count, 0, std_error, NULL, RC_OTHER);
1188 /* Now the confidence interval */
1189 T = gsl_cdf_tdist_Qinv (q, n - 1);
1191 tab_double (t, 6, row + count, 0,
1192 mean - T * std_error, NULL, RC_OTHER);
1194 tab_double (t, 7, row + count, 0,
1195 mean + T * std_error, NULL, RC_OTHER);
1199 tab_double (t, 8, row + count, 0, ws->dd_total[v]->minimum, fmt, RC_OTHER);
1200 tab_double (t, 9, row + count, 0, ws->dd_total[v]->maximum, fmt, RC_OTHER);
1203 row += categoricals_n_total (cats) + 1;
1209 /* Show the homogeneity table */
1211 show_homogeneity (const struct oneway_spec *cmd, const struct oneway_workspace *ws)
1215 size_t n_rows = cmd->n_vars + 1;
1217 struct tab_table *t = tab_create (n_cols, n_rows);
1218 tab_headers (t, 1, 0, 1, 0);
1220 /* Put a frame around the entire box, and vertical lines inside */
1225 n_cols - 1, n_rows - 1);
1228 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
1229 tab_vline (t, TAL_2, 1, 0, n_rows - 1);
1231 tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, _("Levene Statistic"));
1232 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("df1"));
1233 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("df2"));
1234 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Sig."));
1236 tab_title (t, _("Test of Homogeneity of Variances"));
1238 for (v = 0; v < cmd->n_vars; ++v)
1241 const struct per_var_ws *pvw = &ws->vws[v];
1242 double F = levene_calculate (pvw->nl);
1244 const struct variable *var = cmd->vars[v];
1245 const char *s = var_to_string (var);
1248 moments1_calculate (ws->dd_total[v]->mom, &n, NULL, NULL, NULL, NULL);
1250 df1 = pvw->n_groups - 1;
1251 df2 = n - pvw->n_groups;
1253 tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s);
1255 tab_double (t, 1, v + 1, TAB_RIGHT, F, NULL, RC_OTHER);
1256 tab_double (t, 2, v + 1, TAB_RIGHT, df1, NULL, RC_INTEGER);
1257 tab_double (t, 3, v + 1, TAB_RIGHT, df2, NULL, RC_INTEGER);
1259 /* Now the significance */
1260 tab_double (t, 4, v + 1, TAB_RIGHT, gsl_cdf_fdist_Q (F, df1, df2), NULL, RC_PVALUE);
1267 /* Show the contrast coefficients table */
1269 show_contrast_coeffs (const struct oneway_spec *cmd, const struct oneway_workspace *ws)
1274 int n_contrasts = ll_count (&cmd->contrast_list);
1275 int n_cols = 2 + ws->actual_number_of_groups;
1276 int n_rows = 2 + n_contrasts;
1278 struct tab_table *t;
1280 const struct covariance *cov = ws->vws[0].cov ;
1282 t = tab_create (n_cols, n_rows);
1283 tab_headers (t, 2, 0, 2, 0);
1285 /* Put a frame around the entire box, and vertical lines inside */
1290 n_cols - 1, n_rows - 1);
1304 tab_hline (t, TAL_1, 2, n_cols - 1, 1);
1305 tab_hline (t, TAL_2, 0, n_cols - 1, 2);
1307 tab_vline (t, TAL_2, 2, 0, n_rows - 1);
1309 tab_title (t, _("Contrast Coefficients"));
1311 tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
1314 tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
1315 var_to_string (cmd->indep_var));
1317 for ( cli = ll_head (&cmd->contrast_list);
1318 cli != ll_null (&cmd->contrast_list);
1319 cli = ll_next (cli))
1322 struct contrasts_node *cn = ll_data (cli, struct contrasts_node, ll);
1325 tab_text_format (t, 1, c_num + 2, TAB_CENTER, "%d", c_num + 1);
1327 for (coeffi = ll_head (&cn->coefficient_list);
1328 coeffi != ll_null (&cn->coefficient_list);
1329 ++count, coeffi = ll_next (coeffi))
1331 const struct categoricals *cats = covariance_get_categoricals (cov);
1332 const struct ccase *gcc = categoricals_get_case_by_category (cats, count);
1333 struct coeff_node *coeffn = ll_data (coeffi, struct coeff_node, ll);
1336 ds_init_empty (&vstr);
1338 var_append_value_name (cmd->indep_var, case_data (gcc, cmd->indep_var), &vstr);
1340 tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE, ds_cstr (&vstr));
1344 tab_text_format (t, count + 2, c_num + 2, TAB_RIGHT, "%.*g",
1345 DBL_DIG + 1, coeffn->coeff);
1354 /* Show the results of the contrast tests */
1356 show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspace *ws)
1358 int n_contrasts = ll_count (&cmd->contrast_list);
1361 size_t n_rows = 1 + cmd->n_vars * 2 * n_contrasts;
1363 struct tab_table *t;
1365 t = tab_create (n_cols, n_rows);
1366 tab_headers (t, 3, 0, 1, 0);
1368 /* Put a frame around the entire box, and vertical lines inside */
1373 n_cols - 1, n_rows - 1);
1381 tab_hline (t, TAL_2, 0, n_cols - 1, 1);
1382 tab_vline (t, TAL_2, 3, 0, n_rows - 1);
1384 tab_title (t, _("Contrast Tests"));
1386 tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("Contrast"));
1387 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Value of Contrast"));
1388 tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Error"));
1389 tab_text (t, 5, 0, TAB_CENTER | TAT_TITLE, _("t"));
1390 tab_text (t, 6, 0, TAB_CENTER | TAT_TITLE, _("df"));
1391 tab_text (t, 7, 0, TAB_CENTER | TAT_TITLE, _("Sig. (2-tailed)"));
1393 for (v = 0; v < cmd->n_vars; ++v)
1395 const struct per_var_ws *pvw = &ws->vws[v];
1396 const struct categoricals *cats = covariance_get_categoricals (pvw->cov);
1397 if (!categoricals_is_complete (cats))
1401 int lines_per_variable = 2 * n_contrasts;
1403 tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE,
1404 var_to_string (cmd->vars[v]));
1406 for ( cli = ll_head (&cmd->contrast_list);
1407 cli != ll_null (&cmd->contrast_list);
1408 ++i, cli = ll_next (cli))
1410 struct contrasts_node *cn = ll_data (cli, struct contrasts_node, ll);
1413 double contrast_value = 0.0;
1414 double coef_msq = 0.0;
1417 double std_error_contrast;
1419 double sec_vneq = 0.0;
1421 /* Note: The calculation of the degrees of freedom in the
1422 "variances not equal" case is painfull!!
1423 The following formula may help to understand it:
1424 \frac{\left (\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
1427 \frac{\left (c_i^2\frac{s_i^2}{n_i}\right)^2} {n_i-1}
1432 double df_denominator = 0.0;
1433 double df_numerator = 0.0;
1436 moments1_calculate (ws->dd_total[v]->mom, &grand_n, NULL, NULL, NULL, NULL);
1437 df = grand_n - pvw->n_groups;
1441 tab_text (t, 1, (v * lines_per_variable) + i + 1,
1442 TAB_LEFT | TAT_TITLE,
1443 _("Assume equal variances"));
1445 tab_text (t, 1, (v * lines_per_variable) + i + 1 + n_contrasts,
1446 TAB_LEFT | TAT_TITLE,
1447 _("Does not assume equal"));
1450 tab_text_format (t, 2, (v * lines_per_variable) + i + 1,
1451 TAB_CENTER | TAT_TITLE, "%d", i + 1);
1454 tab_text_format (t, 2,
1455 (v * lines_per_variable) + i + 1 + n_contrasts,
1456 TAB_CENTER | TAT_TITLE, "%d", i + 1);
1458 for (coeffi = ll_head (&cn->coefficient_list);
1459 coeffi != ll_null (&cn->coefficient_list);
1460 ++ci, coeffi = ll_next (coeffi))
1462 double n, mean, variance;
1463 const struct descriptive_data *dd = categoricals_get_user_data_by_category (cats, ci);
1464 struct coeff_node *cn = ll_data (coeffi, struct coeff_node, ll);
1465 const double coef = cn->coeff;
1468 moments1_calculate (dd->mom, &n, &mean, &variance, NULL, NULL);
1470 winv = variance / n;
1472 contrast_value += coef * mean;
1474 coef_msq += (pow2 (coef)) / n;
1476 sec_vneq += (pow2 (coef)) * variance / n;
1478 df_numerator += (pow2 (coef)) * winv;
1479 df_denominator += pow2((pow2 (coef)) * winv) / (n - 1);
1482 sec_vneq = sqrt (sec_vneq);
1484 df_numerator = pow2 (df_numerator);
1486 tab_double (t, 3, (v * lines_per_variable) + i + 1,
1487 TAB_RIGHT, contrast_value, NULL, RC_OTHER);
1489 tab_double (t, 3, (v * lines_per_variable) + i + 1 +
1491 TAB_RIGHT, contrast_value, NULL, RC_OTHER);
1493 std_error_contrast = sqrt (pvw->mse * coef_msq);
1496 tab_double (t, 4, (v * lines_per_variable) + i + 1,
1497 TAB_RIGHT, std_error_contrast,
1500 T = fabs (contrast_value / std_error_contrast);
1504 tab_double (t, 5, (v * lines_per_variable) + i + 1,
1509 /* Degrees of Freedom */
1510 tab_double (t, 6, (v * lines_per_variable) + i + 1,
1511 TAB_RIGHT, df, NULL, RC_INTEGER);
1514 /* Significance TWO TAILED !!*/
1515 tab_double (t, 7, (v * lines_per_variable) + i + 1,
1516 TAB_RIGHT, 2 * gsl_cdf_tdist_Q (T, df),
1519 /* Now for the Variances NOT Equal case */
1523 (v * lines_per_variable) + i + 1 + n_contrasts,
1524 TAB_RIGHT, sec_vneq,
1527 T = contrast_value / sec_vneq;
1529 (v * lines_per_variable) + i + 1 + n_contrasts,
1533 df = df_numerator / df_denominator;
1536 (v * lines_per_variable) + i + 1 + n_contrasts,
1541 double p = gsl_cdf_tdist_P (T, df);
1542 double q = gsl_cdf_tdist_Q (T, df);
1544 /* The Significance */
1545 tab_double (t, 7, (v * lines_per_variable) + i + 1 + n_contrasts,
1546 TAB_RIGHT, 2 * ((T > 0) ? q : p),
1552 tab_hline (t, TAL_1, 0, n_cols - 1, (v * lines_per_variable) + 1);
1561 show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace *ws, int v)
1563 const int n_cols = 8;
1564 const int heading_rows = 2;
1565 const int heading_cols = 3;
1568 int r = heading_rows ;
1570 const struct per_var_ws *pvw = &ws->vws[v];
1571 const struct categoricals *cat = pvw->cat;
1572 const int n_rows = heading_rows + cmd->n_posthoc * pvw->n_groups * (pvw->n_groups - 1);
1574 struct tab_table *t = tab_create (n_cols, n_rows);
1576 tab_headers (t, heading_cols, 0, heading_rows, 0);
1578 /* Put a frame around the entire box, and vertical lines inside */
1583 n_cols - 1, n_rows - 1);
1589 n_cols - 1, n_rows - 1);
1591 tab_vline (t, TAL_2, heading_cols, 0, n_rows - 1);
1593 tab_title (t, _("Multiple Comparisons (%s)"), var_to_string (cmd->vars[v]));
1595 tab_text_format (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(I) %s"), var_to_string (cmd->indep_var));
1596 tab_text_format (t, 2, 1, TAB_LEFT | TAT_TITLE, _("(J) %s"), var_to_string (cmd->indep_var));
1597 tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean Difference"));
1598 tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("(I - J)"));
1599 tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Error"));
1600 tab_text (t, 5, 1, TAB_CENTER | TAT_TITLE, _("Sig."));
1602 tab_joint_text_format (t, 6, 0, 7, 0, TAB_CENTER | TAT_TITLE,
1603 _("%g%% Confidence Interval"),
1604 (1 - cmd->alpha) * 100.0);
1606 tab_text (t, 6, 1, TAB_CENTER | TAT_TITLE, _("Lower Bound"));
1607 tab_text (t, 7, 1, TAB_CENTER | TAT_TITLE, _("Upper Bound"));
1610 for (p = 0; p < cmd->n_posthoc; ++p)
1613 const struct posthoc *ph = &ph_tests[cmd->posthoc[p]];
1615 tab_hline (t, TAL_2, 0, n_cols - 1, r);
1617 tab_text (t, 0, r, TAB_LEFT | TAT_TITLE, gettext (ph->label));
1619 for (i = 0; i < pvw->n_groups ; ++i)
1621 double weight_i, mean_i, var_i;
1625 struct descriptive_data *dd_i = categoricals_get_user_data_by_category (cat, i);
1626 const struct ccase *gcc = categoricals_get_case_by_category (cat, i);
1629 ds_init_empty (&vstr);
1630 var_append_value_name (cmd->indep_var, case_data (gcc, cmd->indep_var), &vstr);
1633 tab_hline (t, TAL_1, 1, n_cols - 1, r);
1634 tab_text (t, 1, r, TAB_LEFT | TAT_TITLE, ds_cstr (&vstr));
1636 moments1_calculate (dd_i->mom, &weight_i, &mean_i, &var_i, 0, 0);
1638 for (j = 0 ; j < pvw->n_groups; ++j)
1641 double weight_j, mean_j, var_j;
1643 const struct ccase *cc;
1644 struct descriptive_data *dd_j = categoricals_get_user_data_by_category (cat, j);
1649 cc = categoricals_get_case_by_category (cat, j);
1650 var_append_value_name (cmd->indep_var, case_data (cc, cmd->indep_var), &vstr);
1651 tab_text (t, 2, r + rx, TAB_LEFT | TAT_TITLE, ds_cstr (&vstr));
1653 moments1_calculate (dd_j->mom, &weight_j, &mean_j, &var_j, 0, 0);
1655 tab_double (t, 3, r + rx, 0, mean_i - mean_j, NULL, RC_OTHER);
1658 std_err *= weight_i + weight_j;
1659 std_err /= weight_i * weight_j;
1660 std_err = sqrt (std_err);
1662 tab_double (t, 4, r + rx, 0, std_err, NULL, RC_OTHER);
1664 tab_double (t, 5, r + rx, 0, 2 * multiple_comparison_sig (std_err, pvw, dd_i, dd_j, ph), NULL, RC_PVALUE);
1666 half_range = mc_half_range (cmd, pvw, std_err, dd_i, dd_j, ph);
1668 tab_double (t, 6, r + rx, 0,
1669 (mean_i - mean_j) - half_range, NULL, RC_OTHER);
1671 tab_double (t, 7, r + rx, 0,
1672 (mean_i - mean_j) + half_range, NULL, RC_OTHER);
1677 r += pvw->n_groups - 1;