Categoricals to take interactions instead of variables.
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 5 Jul 2011 17:45:31 +0000 (19:45 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 26 Jul 2011 10:36:37 +0000 (12:36 +0200)
This change alters the API of categoricals_create, so as to
accept an array of interactions instead of an array of variables.
Currently, however only interactions which contain exactly one
variable will run correctly.

src/language/stats/glm.c
src/language/stats/oneway.c
src/math/categoricals.c
src/math/categoricals.h

index 0c85965ea8f92ce866056ed61460b8b450475a42..4ba93150c496db428ece611c79f7a149277e10b2 100644 (file)
@@ -402,7 +402,8 @@ run_glm (struct glm_spec *cmd, struct casereader *input,
 
   struct glm_workspace ws;
   struct covariance *cov;
-  ws.cats = categoricals_create (cmd->design_vars, cmd->n_design_vars,
+
+  ws.cats = categoricals_create (cmd->interactions, cmd->n_interactions,
                                 cmd->wv, cmd->exclude,
                                 NULL, NULL, NULL, NULL);
 
index 78bd215088d289b81e63a71a5ba5d511df4c61a9..447bdad1b3f6ec6c7dc3a9daa7eb528f5c324925 100644 (file)
@@ -651,7 +651,8 @@ run_oneway (const struct oneway_spec *cmd,
 
   for (v = 0; v < cmd->n_vars; ++v)
     {
-      ws.vws[v].cat = categoricals_create (&cmd->indep_var, 1, cmd->wv,
+      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]),
index 78944fca44803aabe3da896e8ac23e3f430257b0..2d65f8ae1902b5ad97f55e33602e173be4a6e19e 100644 (file)
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "math/categoricals.h"
+#include "math/interaction.h"
 
 #include <stdio.h>
 
@@ -215,7 +216,7 @@ lookup_value (const struct hmap *map, const struct variable *var, const union va
 
 
 struct categoricals *
-categoricals_create (const struct variable *const *v, size_t n_vars,
+categoricals_create (const struct interaction **inter, size_t n_inter,
                     const struct variable *wv, enum mv_class exclude,
                     user_data_create_func *udf,
                     update_func *update, void *aux1, void *aux2
@@ -224,7 +225,7 @@ categoricals_create (const struct variable *const *v, size_t n_vars,
   size_t i;
   struct categoricals *cat = xmalloc (sizeof *cat);
   
-  cat->n_vp = n_vars;
+  cat->n_vp = n_inter;
   cat->wv = wv;
   cat->n_cats_total = 0;
   cat->n_vars = 0;
@@ -244,7 +245,7 @@ categoricals_create (const struct variable *const *v, size_t n_vars,
   for (i = 0 ; i < cat->n_vp; ++i)
     {
       hmap_init (&cat->vp[i].map);
-      cat->vp[i].var = v[i];
+      cat->vp[i].var = inter[i]->vars[0];
     }
 
   return cat;
index cd887f096e06646596c25dc2be75aa8ffcbacdff..6ab451d73949ebcc723df4f577b99749b6e97476 100644 (file)
@@ -24,6 +24,7 @@
 struct categoricals;
 struct variable;
 struct ccase;
+struct interaction;
 
 union value ;
 
@@ -36,7 +37,7 @@ typedef void update_func (void *user_data,
 
 typedef void *user_data_create_func (void *aux1, void *aux2);
 
-struct categoricals *categoricals_create (const struct variable *const *v, size_t n_vars,
+struct categoricals *categoricals_create (const struct interaction **, size_t n_int,
                                          const struct variable *wv, enum mv_class exclude,
                                          user_data_create_func *udf,
                                          update_func *update, void *aux1, void *aux2);