+2006-04-18 Jason Stover <jhs@math.gcsu.edu>
+
+ * regression.q (regression_trns_proc): Look up the residual
+ variable in the linear regression cache.
+
+ * regression.q (subcommand_save): Set the residual variable in the
+ linear regression cache.
+
2006-04-17 Jason Stover <jason@wonko.gcsu.edu>
* regression.q (regression_trns_proc): Accept case_idx as an int
statistics_keyword_output (reg_stats_selection, keywords[selection], c);
}
static int
-regression_trns_proc (void *m, struct ccase *c, int case_idx)
+regression_trns_proc (void *m, struct ccase *c, int case_idx UNUSED)
{
size_t i;
size_t n_vars;
const union value **vals = NULL;
const union value *obs = NULL;
struct variable **vars = NULL;
- struct variable *resid = NULL;
assert (model != NULL);
assert (model->depvar != NULL);
+ assert (model->resid != NULL);
vals = xnmalloc (n_variables, sizeof (*vals));
dict_get_vars (default_dict, &vars, &n_vars, 1u << DC_ORDINARY);
- resid = dict_get_var (default_dict, case_idx);
- assert (resid != NULL);
- output = case_data_rw (c, resid->fv);
- assert (output);
+ output = case_data_rw (c, model->resid->fv);
+ assert (output != NULL);
for (i = 0; i < n_vars; i++)
{
- if (i != case_idx) /* Do not use the residual variable as a predictor. */
+ /* Do not use the residual variable as a predictor. */
+ if (vars[i]->index != model->resid->index)
{
+ /* Do not use the dependent variable as a predictor. */
if (vars[i]->index == model->depvar->index)
{
- /* Do not use the dependent variable as a predictor. */
obs = case_data (c, i);
assert (obs != NULL);
}
if (save)
{
- residuals = dict_create_var_assert (default_dict, "residuals", 0);
+ residuals = dict_create_var (default_dict, "residuals", 0);
assert (residuals != NULL);
+ lc->resid = residuals;
add_transformation (regression_trns_proc, pspp_linreg_cache_free, lc);
}
else