Covariance matrix interface change.
[pspp] / src / language / stats / glm.q
index 1444a0c1b7a66c0866c5ea32eca348037d5c4667..13b097f3b8fce021c9004184b2427f9602e94643 100644 (file)
@@ -23,7 +23,6 @@
 #include <stdlib.h>
 
 #include <data/case.h>
-#include <data/category.h>
 #include <data/casegrouper.h>
 #include <data/casereader.h>
 #include <data/dictionary.h>
 #include <language/data-io/file-handle.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/compiler.h>
-#include <libpspp/hash.h>
 #include <libpspp/message.h>
 #include <math/covariance.h>
-#include <math/coefficient.h>
+#include <math/categoricals.h>
 #include <math/linreg.h>
 #include <math/moments.h>
-#include <output/table.h>
+#include <output/tab.h>
 
 #include "xalloc.h"
 #include "gettext.h"
@@ -252,26 +250,13 @@ glm_custom_dependent (struct lexer *lexer, struct dataset *ds,
   return 1;
 }
 
-/*
-  COV is the covariance matrix for variables included in the
-  model. That means the dependent variable is in there, too.
- */
-static void
-coeff_init (pspp_linreg_cache * c, const struct design_matrix *cov)
-{
-  c->coeff = xnmalloc (cov->m->size2, sizeof (*c->coeff));
-  c->n_coeffs = cov->m->size2 - 1;
-  pspp_coeff_init (c->coeff, cov);
-}
-
-
-static pspp_linreg_cache *
+static linreg *
 fit_model (const struct covariance *cov,
           const struct variable *dep_var, 
           const struct variable ** indep_vars, 
           size_t n_data, size_t n_indep)
 {
-  pspp_linreg_cache *result = NULL;
+  linreg *result = NULL;
   
   return result;
 }
@@ -285,7 +270,7 @@ run_glm (struct casereader *input,
   const struct variable **numerics = NULL;
   const struct variable **categoricals = NULL;
   int n_indep = 0;
-  pspp_linreg_cache *model = NULL; 
+  linreg *model = NULL; 
   pspp_linreg_opts lopts;
   struct ccase *c;
   size_t i;
@@ -374,7 +359,13 @@ run_glm (struct casereader *input,
       k++;
     }
 
-  cov = covariance_2pass_create (n_numerics, numerics, n_categoricals, categoricals, NULL, MV_NEVER);
+  struct categoricals *cats = categoricals_create (categoricals,
+                                                  n_categoricals,
+                                                  NULL, MV_NEVER);
+
+  cov = covariance_2pass_create (n_numerics, numerics,
+                                cats,
+                                NULL, MV_NEVER);
 
   reader = casereader_clone (input);
   reader = casereader_create_filter_missing (reader, numerics, n_numerics,
@@ -391,8 +382,9 @@ run_glm (struct casereader *input,
     }
   for (; (c = casereader_read (r)) != NULL; case_unref (c))
     {
-      covariance_accumulate_pass1 (cov, c);
+      covariance_accumulate_pass2 (cov, c);
     }
+
   covariance_destroy (cov);
   casereader_destroy (reader);
   casereader_destroy (r);