+static void get_ssq (struct covariance *, gsl_vector *, struct glm_spec *);
+
+static bool
+not_dropped (size_t j, size_t * dropped, size_t n_dropped)
+{
+ size_t i;
+
+ for (i = 0; i < n_dropped; i++)
+ {
+ if (j == dropped [i])
+ return false;
+ }
+ return true;
+}
+
+static void
+get_ssq (struct covariance * cov, gsl_vector * ssq, struct glm_spec * cmd)
+{
+ const struct variable **vars;
+ gsl_matrix * small_cov = NULL;
+ gsl_matrix * cm = covariance_calculate_unnormalized (cov);
+ size_t i;
+ size_t j;
+ size_t k;
+ size_t n;
+ size_t m;
+ size_t * dropped;
+ size_t n_dropped;
+
+ dropped = xcalloc (covariance_dim (cov), sizeof (*dropped));
+ vars = xcalloc (covariance_dim (cov), sizeof (*vars));
+ covariance_get_var_indices (cov, vars);
+
+ for (k = 0; k < cmd->n_factor_vars; k++)
+ {
+ n_dropped = 0;
+ for (i = 1; i < covariance_dim (cov); i++)
+ {
+ if (vars [i] == cmd->factor_vars [k])
+ {
+ dropped [n_dropped++] = i;
+ }
+ }
+ small_cov = gsl_matrix_alloc (cm->size1 - n_dropped, cm->size2 - n_dropped);
+ gsl_matrix_set (small_cov, 0, 0, gsl_matrix_get (cm, 0, 0));
+ n = 0;
+ m = 0;
+ for (i = 0; i < cm->size1; i++)
+ {
+ if (not_dropped (i, dropped, n_dropped))
+ {
+ m = 0;
+ for (j = 0; j < cm->size2; j++)
+ {
+ if (not_dropped (j, dropped, n_dropped))
+ {
+ gsl_matrix_set (small_cov, n, m, gsl_matrix_get (cm, i, j));
+ m++;
+ }
+ }
+ n++;
+ }
+ }
+ reg_sweep (small_cov, 0);
+ gsl_vector_set (ssq, k + 1,
+ gsl_matrix_get (small_cov, 0, 0)
+ - gsl_vector_get (ssq, 0));
+ gsl_matrix_free (small_cov);
+ }
+
+ free (dropped);
+ free (vars);
+ gsl_matrix_free (cm);
+
+}
+