Rewrite PSPP output engine.
[pspp-builds.git] / src / language / stats / regression.q
index 2c259d0f904c1834c7d7e1614fe4f47084bab5ee..2487b9021d08bb14d86a14ed84e3b99dd6f5bad6 100644 (file)
@@ -43,7 +43,7 @@
 #include <math/coefficient.h>
 #include <math/linreg.h>
 #include <math/moments.h>
-#include <output/table.h>
+#include <output/tab.h>
 
 #include "xalloc.h"
 
@@ -149,8 +149,7 @@ reg_stats_r (pspp_linreg_cache * c)
   rsq = c->ssm / c->sst;
   adjrsq = 1.0 - (1.0 - rsq) * (c->n_obs - 1.0) / (c->n_obs - c->n_indeps);
   std_error = sqrt (pspp_linreg_mse (c));
-  t = tab_create (n_cols, n_rows, 0);
-  tab_dim (t, tab_natural_dimensions, NULL);
+  t = tab_create (n_cols, n_rows);
   tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
   tab_hline (t, TAL_2, 0, n_cols - 1, 1);
   tab_vline (t, TAL_2, 2, 0, n_rows - 1);
@@ -191,9 +190,8 @@ reg_stats_coeff (pspp_linreg_cache * c)
   assert (c != NULL);
   n_rows = c->n_coeffs + 3;
 
-  t = tab_create (n_cols, n_rows, 0);
+  t = tab_create (n_cols, n_rows);
   tab_headers (t, 2, 0, 1, 0);
-  tab_dim (t, tab_natural_dimensions, NULL);
   tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
   tab_hline (t, TAL_2, 0, n_cols - 1, 1);
   tab_vline (t, TAL_2, 2, 0, n_rows - 1);
@@ -288,9 +286,8 @@ reg_stats_anova (pspp_linreg_cache * c)
   struct tab_table *t;
 
   assert (c != NULL);
-  t = tab_create (n_cols, n_rows, 0);
+  t = tab_create (n_cols, n_rows);
   tab_headers (t, 2, 0, 1, 0);
-  tab_dim (t, tab_natural_dimensions, NULL);
 
   tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
 
@@ -379,9 +376,8 @@ reg_stats_bcov (pspp_linreg_cache * c)
   assert (c != NULL);
   n_cols = c->n_indeps + 1 + 2;
   n_rows = 2 * (c->n_indeps + 1);
-  t = tab_create (n_cols, n_rows, 0);
+  t = tab_create (n_cols, n_rows);
   tab_headers (t, 2, 0, 1, 0);
-  tab_dim (t, tab_natural_dimensions, NULL);
   tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, n_cols - 1, n_rows - 1);
   tab_hline (t, TAL_2, 0, n_cols - 1, 1);
   tab_vline (t, TAL_2, 2, 0, n_rows - 1);
@@ -914,7 +910,7 @@ run_regression (struct casereader *input, struct cmd_regression *cmd,
     }
   lopts.get_depvar_mean_std = 1;
 
-  lopts.get_indep_mean_std = xnmalloc (n_variables, sizeof (int));
+
   indep_vars = xnmalloc (n_variables, sizeof *indep_vars);
 
   for (k = 0; k < cmd->n_dependent; k++)
@@ -942,6 +938,7 @@ run_regression (struct casereader *input, struct cmd_regression *cmd,
            design_matrix_create (n_indep,
                                  (const struct variable **) indep_vars,
                                  n_data);
+         lopts.get_indep_mean_std = xnmalloc (X->m->size2, sizeof (int));
          for (i = 0; i < X->m->size2; i++)
            {
              lopts.get_indep_mean_std[i] = 1;
@@ -993,6 +990,7 @@ run_regression (struct casereader *input, struct cmd_regression *cmd,
 
          gsl_vector_free (Y);
          design_matrix_destroy (X);
+         free (lopts.get_indep_mean_std);
        }
       else
        {
@@ -1007,7 +1005,6 @@ run_regression (struct casereader *input, struct cmd_regression *cmd,
     }
   free (mom);
   free (indep_vars);
-  free (lopts.get_indep_mean_std);
   casereader_destroy (input);
 
   return true;