Fixed type 3 sums of squares for models containing interactions
[pspp-builds.git] / src / language / stats / oneway.c
index 655e1925f8fa7f20be8b62e4e47bce00adbb4e27..1c80c2ba98e7f5f8aa41674e8601a4db2be35cdb 100644 (file)
@@ -655,8 +655,7 @@ run_oneway (const struct oneway_spec *cmd,
       struct interaction *inter = interaction_create (cmd->indep_var);
       ws.vws[v].cat = categoricals_create (&inter, 1, cmd->wv,
                                            cmd->exclude, makeit, updateit,
-                                           CONST_CAST (struct variable *,
-                                                       cmd->vars[v]),
+                                           CONST_CAST (struct variable *, cmd->vars[v]),
                                            ws.dd_total[v]);
 
       ws.vws[v].cov = covariance_2pass_create (1, &cmd->vars[v],
@@ -756,9 +755,12 @@ run_oneway (const struct oneway_spec *cmd,
 
   for (v = 0; v < cmd->n_vars; ++v)
     {
+      gsl_matrix *cm;
       struct per_var_ws *pvw = &ws.vws[v];
-      gsl_matrix *cm = covariance_calculate_unnormalized (pvw->cov);
       const struct categoricals *cats = covariance_get_categoricals (pvw->cov);
+      categoricals_done (cats);
+
+      cm = covariance_calculate_unnormalized (pvw->cov);
 
       moments1_calculate (ws.dd_total[v]->mom, &pvw->n, NULL, NULL, NULL, NULL);
 
@@ -781,8 +783,6 @@ run_oneway (const struct oneway_spec *cmd,
     {
       const struct categoricals *cats = covariance_get_categoricals (ws.vws[v].cov);
 
-      categoricals_done (cats);
-      
       if (categoricals_n_total (cats) > ws.actual_number_of_groups)
        ws.actual_number_of_groups = categoricals_n_total (cats);
     }