+ 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)
+ {
+ int df = 1;
+ const struct interaction *iact = cat->iap[i].iact;
+
+ cat->iap[i].df_prod = xcalloc (iact->n_vars, sizeof (int));
+
+ 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));
+
+ if (hmap_count (&vn->valmap) == 0)
+ return false;
+
+ cat->iap[i].df_prod[v] = df * (hmap_count (&vn->valmap) - 1);
+ df = cat->iap[i].df_prod[v];
+
+ cat->iap[i].n_cats *= hmap_count (&vn->valmap);
+ }
+
+ cat->df_sum += cat->iap[i].df_prod [v - 1];
+ cat->n_cats_total += cat->iap[i].n_cats;
+ }
+
+