- /*
- Find the least-squares estimates and other statistics.
- */
- pspp_linreg ((const gsl_vector *) Y, X->m, &lopts, models[k]);
- subcommand_statistics (cmd.a_statistics, models[k]);
- subcommand_export (cmd.sbc_export, models[k]);
-
- gsl_vector_free (Y);
- design_matrix_destroy (X);
- free (indep_vars);
- free (lopts.get_indep_mean_std);
- casereader_destroy (r);
- }
+ /*
+ The second pass fills the design matrix.
+ */
+ reader = casereader_create_counter (reader, &row, -1);
+ for (; casereader_read (reader, &c); case_destroy (&c))
+ {
+ for (i = 0; i < n_indep; ++i)
+ {
+ const struct variable *v = indep_vars[i];
+ const union value *val = case_data (&c, v);
+ if (var_is_alpha (v))
+ design_matrix_set_categorical (X, row, v, val);
+ else
+ design_matrix_set_numeric (X, row, v, val);
+ }
+ gsl_vector_set (Y, row, case_num (&c, dep_var));
+ }
+ casereader_destroy (reader);
+ /*
+ Now that we know the number of coefficients, allocate space
+ and store pointers to the variables that correspond to the
+ coefficients.
+ */
+ coeff_init (models[k], X);