GNU standards require "file name" instead of "filename" in
[pspp-builds.git] / src / language / stats / regression.q
index 11a1f211c87c35889413634a652ab715825c5b8a..737a25fdce4b4b2f03008ca8279d9b9b70a6ba73 100644 (file)
@@ -505,14 +505,17 @@ static void
 subcommand_save (int save, pspp_linreg_cache *lc, const struct casefile *cf, int *is_missing)
 {
   int i;
-  int k;
   int case_num;
   double residual;
-  const union value **vals;
+  const union value **vals = NULL;
+  const union value *obs = NULL;
   struct casereader *r;
   struct ccase c;
 
   assert (lc != NULL);
+  assert (lc->depvar != NULL);
+  assert (is_missing != NULL);
+
   if (save)
     {
       vals = xnmalloc (n_variables, sizeof (*vals));
@@ -525,8 +528,13 @@ subcommand_save (int save, pspp_linreg_cache *lc, const struct casefile *cf, int
              for (i = 0; i < n_variables; ++i)
                {
                  vals[i] = case_data (&c, v_variables[i]->fv);
+                 if (v_variables[i]->index == lc->depvar->index)
+                   {
+                     obs = vals[i];
+                   }
                }
-             residual = (*lc->predict) (v_variables, vals, lc, n_variables);
+             residual = (*lc->residual) ((const struct variable **) v_variables, 
+                                         (const union value **) vals, obs, lc, n_variables);
            }
        }
       free (vals);
@@ -663,7 +671,7 @@ subcommand_export (int export, pspp_linreg_cache * c)
     {
       assert (c != NULL);
       assert (model_file != NULL);
-      fp = fopen (fh_get_filename (model_file), "w");
+      fp = fopen (fh_get_file_name (model_file), "w");
       assert (fp != NULL);
       fprintf (fp, "%s", reg_preamble);
       reg_print_getvar (fp, c);