-/*
- Count the explanatory variables. The user may or may
- not have specified a response variable in the syntax.
- */
-static
-int get_n_indep (const struct variable *v)
+
+/* Identify the explanatory variables in v_variables. Returns
+ the number of independent variables. */
+static int
+identify_indep_vars (const struct variable **indep_vars,
+ const struct variable *depvar)
+{
+ int n_indep_vars = 0;
+ int i;
+
+ for (i = 0; i < n_variables; i++)
+ if (!is_depvar (i, depvar))
+ indep_vars[n_indep_vars++] = v_variables[i];
+ if ((n_indep_vars < 2) && is_depvar (0, depvar))
+ {
+ /*
+ There is only one independent variable, and it is the same
+ as the dependent variable. Print a warning and continue.
+ */
+ msg (SE,
+ gettext ("The dependent variable is equal to the independent variable."
+ "The least squares line is therefore Y=X."
+ "Standard errors and related statistics may be meaningless."));
+ n_indep_vars = 1;
+ indep_vars[0] = v_variables[0];
+ }
+ return n_indep_vars;
+}
+
+/* Encode categorical variables.
+ Returns number of valid cases. */
+static int
+prepare_categories (struct casereader *input,
+ const struct variable **vars, size_t n_vars,
+ struct moments_var *mom)