Change how checking for missing values works.
[pspp] / src / language / stats / oneway.c
index 3665211a1c64aa61ee953a9603a2fafeef047ead..6ad71f14c829fc75a91b63e89854f18d9fc3b179 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012, 2013, 2014,
+   2020 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -525,7 +526,7 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds)
        }
       else if (lex_match_id (lexer, "CONTRAST"))
        {
-         struct contrasts_node *cl = xzalloc (sizeof *cl);
+         struct contrasts_node *cl = XZALLOC (struct contrasts_node);
 
          struct ll_list *coefficient_list = &cl->coefficient_list;
           lex_match (lexer, T_EQUALS);
@@ -708,8 +709,8 @@ run_oneway (const struct oneway_spec *cmd,
   struct oneway_workspace ws;
 
   ws.actual_number_of_groups = 0;
-  ws.vws = xzalloc (cmd->n_vars * sizeof (*ws.vws));
-  ws.dd_total = xmalloc (sizeof (struct descriptive_data) * cmd->n_vars);
+  ws.vws = xcalloc (cmd->n_vars, sizeof (*ws.vws));
+  ws.dd_total = XCALLOC (cmd->n_vars, struct descriptive_data*);
 
   for (v = 0 ; v < cmd->n_vars; ++v)
     ws.dd_total[v] = dd_create (cmd->vars[v]);
@@ -771,7 +772,7 @@ run_oneway (const struct oneway_spec *cmd,
 
          if (MISS_ANALYSIS == cmd->missing_type)
            {
-             if (var_is_value_missing (v, val, cmd->exclude))
+             if (var_is_value_missing (v, val) & cmd->exclude)
                continue;
            }
 
@@ -794,7 +795,7 @@ run_oneway (const struct oneway_spec *cmd,
 
          if (MISS_ANALYSIS == cmd->missing_type)
            {
-             if (var_is_value_missing (v, val, cmd->exclude))
+             if (var_is_value_missing (v, val) & cmd->exclude)
                continue;
            }
 
@@ -818,7 +819,7 @@ run_oneway (const struct oneway_spec *cmd,
 
          if (MISS_ANALYSIS == cmd->missing_type)
            {
-             if (var_is_value_missing (v, val, cmd->exclude))
+             if (var_is_value_missing (v, val) & cmd->exclude)
                continue;
            }
 
@@ -1316,11 +1317,9 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac
          df_numerator = pow2 (df_numerator);
 
          double std_error_contrast = sqrt (pvw->mse * coef_msq);
-         double T = fabs (contrast_value / std_error_contrast);
+         double T = contrast_value / std_error_contrast;
          double T_ne = contrast_value / sec_vneq;
          double df_ne = df_numerator / df_denominator;
-          double p_ne = gsl_cdf_tdist_P (T_ne, df_ne);
-          double q_ne = gsl_cdf_tdist_Q (T_ne, df_ne);
 
           struct entry
             {
@@ -1335,13 +1334,13 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac
               { 1, 0, std_error_contrast },
               { 2, 0, T },
               { 3, 0, df },
-              { 4, 0, 2 * gsl_cdf_tdist_Q (T, df) },
+              { 4, 0, 2 * gsl_cdf_tdist_Q (fabs(T), df) },
               /* Do not assume equal. */
               { 0, 1, contrast_value },
               { 1, 1, sec_vneq },
               { 2, 1, T_ne },
               { 3, 1, df_ne },
-              { 4, 1, 2 * (T > 0 ? q_ne : p_ne) },
+              { 4, 1, 2 * gsl_cdf_tdist_Q (fabs(T_ne), df_ne) },
             };
 
           for (size_t i = 0; i < sizeof entries / sizeof *entries; i++)
@@ -1367,7 +1366,6 @@ show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace *
                                         _("Multiple Comparisons (%s)"),
                                         var_to_string (cmd->vars[v]))),
     "Multiple Comparisons");
-  table->omit_empty = true;
 
   struct pivot_dimension *statistics = pivot_dimension_create (
     table, PIVOT_AXIS_COLUMN, N_("Statistics"),