- int idx = 0;
- cat->reverse_variable_map = pool_calloc (cat->pool,
- cat->n_cats_total,
- sizeof *cat->reverse_variable_map);
-
- for (v = 0 ; v < cat->n_vp; ++v)
+ int i;
+ int idx_short = 0;
+ int idx_long = 0;
+ cat->df_sum = 0;
+ cat->n_cats_total = 0;
+
+ /* Calculate the degrees of freedom, and the number of categories */
+ for (i = 0 ; i < cat->n_iap; ++i)
+ {
+ const struct interaction *iact = cat->iap[i].iact;
+
+ cat->iap[i].df = 1;
+ cat->iap[i].n_cats = 1;
+
+ for (v = 0 ; v < iact->n_vars; ++v)
+ {
+ const struct variable *var = iact->vars[v];
+
+ struct variable_node *vn = lookup_variable (&cat->varmap, var, hash_pointer (var, 0));
+
+ cat->iap[i].df *= hmap_count (&vn->valmap) - 1;
+ cat->iap[i].n_cats *= hmap_count (&vn->valmap);
+ }
+
+ cat->df_sum += cat->iap[i].df;
+ cat->n_cats_total += cat->iap[i].n_cats;
+ }
+
+
+ cat->reverse_variable_map_short = pool_calloc (cat->pool,
+ cat->df_sum,
+ sizeof *cat->reverse_variable_map_short);
+
+ cat->reverse_variable_map_long = pool_calloc (cat->pool,
+ cat->n_cats_total,
+ sizeof *cat->reverse_variable_map_long);
+
+ for (i = 0 ; i < cat->n_iap; ++i)