+ const struct interaction *cat_predictors = cmd->cat_predictors[i];
+ struct string str = DS_EMPTY_INITIALIZER;
+ interaction_to_string (cat_predictors, &str);
+ if (ivar != 0)
+ ds_put_format (&str, "(%d)", ivar);
+ var_idx = pivot_category_create_leaf (
+ step1, pivot_value_new_user_text_nocopy (ds_steal_cstr (&str)));
+
+ int df = categoricals_df (res->cats, i);
+ bool summary = ivar == 0;
+ if (summary)
+ {
+ /* Calculate the Wald statistic,
+ which is \beta' C^-1 \beta .
+ where \beta is the vector of the coefficient estimates comprising this
+ categorial variable. and C is the corresponding submatrix of the
+ hessian matrix.
+ */
+ gsl_matrix_const_view mv =
+ gsl_matrix_const_submatrix (res->hessian, idx, idx, df, df);
+ gsl_matrix *subhessian = gsl_matrix_alloc (mv.matrix.size1, mv.matrix.size2);
+ gsl_vector_const_view vv = gsl_vector_const_subvector (res->beta_hat, idx, df);
+ gsl_vector *temp = gsl_vector_alloc (df);
+
+ gsl_matrix_memcpy (subhessian, &mv.matrix);
+ gsl_linalg_cholesky_decomp (subhessian);
+ gsl_linalg_cholesky_invert (subhessian);
+
+ gsl_blas_dgemv (CblasTrans, 1.0, subhessian, &vv.vector, 0, temp);
+ double wald;
+ gsl_blas_ddot (temp, &vv.vector, &wald);
+
+ double entries[] = { wald, df, gsl_cdf_chisq_Q (wald, df) };
+ for (size_t j = 0; j < sizeof entries / sizeof *entries; j++)
+ pivot_table_put2 (table, j + 2, var_idx,
+ pivot_value_new_number (entries[j]));
+
+ idx_correction++;
+ gsl_matrix_free (subhessian);
+ gsl_vector_free (temp);
+ }
+
+ if (ivar++ == df)