-/*
- COV is the covariance matrix for variables included in the
- model. That means the dependent variable is in there, too.
- */
-static void
-coeff_init (pspp_linreg_cache * c, const struct design_matrix *cov)
-{
- c->coeff = xnmalloc (cov->m->size2, sizeof (*c->coeff));
- c->n_coeffs = cov->m->size2 - 1;
- pspp_coeff_init (c->coeff, cov);
-}
-
-/* Encode categorical variables.
- Returns number of valid cases. */
-static int
-data_pass_one (struct casereader *input,
- const struct variable **vars, size_t n_vars,
- struct moments_var **mom)
-{
- int n_data;
- struct ccase c;
- size_t i;
-
- for (i = 0; i < n_vars; i++)
- {
- mom[i] = xmalloc (sizeof (*mom[i]));
- mom[i]->v = vars[i];
- mom[i]->mean = xmalloc (sizeof (*mom[i]->mean));
- mom[i]->variance = xmalloc (sizeof (*mom[i]->mean));
- mom[i]->weight = xmalloc (sizeof (*mom[i]->weight));
- mom[i]->m = moments1_create (MOMENT_VARIANCE);
- if (var_is_alpha (vars[i]))
- cat_stored_values_create (vars[i]);
- }
-
- n_data = 0;
- for (; casereader_read (input, &c); case_destroy (&c))
- {
- /*
- The second condition ensures the program will run even if
- there is only one variable to act as both explanatory and
- response.
- */
- for (i = 0; i < n_vars; i++)
- {
- const union value *val = case_data (&c, vars[i]);
- if (var_is_alpha (vars[i]))
- cat_value_update (vars[i], val);
- else
- moments1_add (mom[i]->m, val->f, 1.0);
- }
- n_data++;
- }
- casereader_destroy (input);
- for (i = 0; i < n_vars; i++)
- {
- if (var_is_numeric (mom[i]->v))
- {
- moments1_calculate (mom[i]->m, mom[i]->weight, mom[i]->mean,
- mom[i]->variance, NULL, NULL);
- }
- }
-
- return n_data;
-}
-
-static pspp_linreg_cache *
-fit_model (const struct design_matrix *cov, const struct moments1 **mom,