From 3d2d7cd7e835a1f49fb24e629972dd5d99d872ab Mon Sep 17 00:00:00 2001 From: Jason Stover Date: Wed, 15 Aug 2007 19:24:16 +0000 Subject: [PATCH] fix bug 19819 --- src/language/stats/ChangeLog | 5 +++++ src/language/stats/regression.q | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/language/stats/ChangeLog b/src/language/stats/ChangeLog index ac368fd0..55c4a8e3 100644 --- a/src/language/stats/ChangeLog +++ b/src/language/stats/ChangeLog @@ -1,3 +1,8 @@ +2007-08-15 Jason Stover + + * regression.q (identify_indep_vars): Print an error if dependent + and independent variables are the same. Fixes bug 19819. + 2007-08-12 Ben Pfaff * flip.c: Drop use of dict_get_compacted_dict_index_to_case_index diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index d5008b56..c6fddb90 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -1021,7 +1021,17 @@ identify_indep_vars (const struct variable **indep_vars, 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 sequares 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; } @@ -1036,6 +1046,9 @@ prepare_categories (struct casereader *input, struct ccase c; size_t i; + assert (vars != NULL); + assert (mom != NULL); + for (i = 0; i < n_vars; i++) if (var_is_alpha (vars[i])) cat_stored_values_create (vars[i]); @@ -1163,7 +1176,6 @@ run_regression (struct casereader *input, struct cmd_regression *cmd, dep_var = cmd->v_dependent[k]; n_indep = identify_indep_vars (indep_vars, dep_var); - reader = casereader_clone (input); reader = casereader_create_filter_missing (reader, indep_vars, n_indep, MV_ANY, NULL); -- 2.30.2