- The second pass fills the design matrix.
- */
- row = 0;
- for (r = casefile_get_reader (cf, NULL); casereader_read (r, &c);
- case_destroy (&c))
- /* Iterate over the cases. */
- {
- case_num = casereader_cnum (r) - 1;
- if (!is_missing_case[case_num])
- {
- for (i = 0; i < n_variables; ++i) /* Iterate over the
- variables for the
- current case.
- */
- {
- val = case_data (&c, v_variables[i]);
- /*
- Independent/dependent variable separation. The
- 'variables' subcommand specifies a varlist which contains
- both dependent and independent variables. The dependent
- variables are specified with the 'dependent'
- subcommand, and maybe also in the 'variables' subcommand.
- We need to separate the two.
- */
- if (!is_depvar (i, cmd.v_dependent[k]))
- {
- if (var_is_alpha (v_variables[i]))
- {
- design_matrix_set_categorical (X, row,
- v_variables[i],
- val);
- }
- else
- {
- design_matrix_set_numeric (X, row,
- v_variables[i], val);
- }
- }
- }
- val = case_data (&c, cmd.v_dependent[k]);
- gsl_vector_set (Y, row, val->f);
- row++;
- }
- }
+ 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);