From: Jason Stover Date: Fri, 28 Apr 2006 19:17:15 +0000 (+0000) Subject: pass only the variables in the model to pspp_linreg_predict() X-Git-Tag: v0.6.0~927 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5e3c75df80897a583aedcdbd4269a7ca5ccc491;p=pspp-builds.git pass only the variables in the model to pspp_linreg_predict() --- diff --git a/src/language/stats/ChangeLog b/src/language/stats/ChangeLog index fce036c1..6f7c271f 100644 --- a/src/language/stats/ChangeLog +++ b/src/language/stats/ChangeLog @@ -3,6 +3,9 @@ * regression.q (regression_trns_resid_proc): Pass only the variables used in the model to (*model->residual)(). + * regression.q (regression_trns_pred_proc): Pass only the + variables used in the model to (*model->pred)(). + 2006-04-26 Jason Stover * regression.q: Added support for multiple transformations. diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index c9e245d2..793d8325 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -539,58 +539,34 @@ static int regression_trns_pred_proc (void *t_, struct ccase *c, int case_idx UNUSED) { size_t i; - size_t n_vars; - size_t n_vals = 0; - union value *tmp = NULL; - struct reg_trns *t = t_; + size_t n_vals; + struct reg_trns *trns = t_; pspp_linreg_cache *model; - union value *output; + union value *output = NULL; const union value **vals = NULL; struct variable **vars = NULL; - struct variable **model_vars = NULL; - assert (t != NULL); - model = t->c; + assert (trns!= NULL); + model = trns->c; assert (model != NULL); assert (model->depvar != NULL); assert (model->pred != NULL); - - dict_get_vars (default_dict, &vars, &n_vars, 1u << DC_SYSTEM); - vals = xnmalloc (n_vars, sizeof (*vals)); - model_vars = xnmalloc (n_vars, sizeof (*model_vars)); - assert (vals != NULL); + + vars = xnmalloc (model->n_coeffs, sizeof (*vars)); + n_vals = (*model->get_vars) (model, vars); + + vals = xnmalloc (n_vals, sizeof (*vals)); output = case_data_rw (c, model->pred->fv); assert (output != NULL); - for (i = 0; i < n_vars; i++) + for (i = 0; i < n_vals; i++) { - /* Use neither the predicted values nor the dependent variable. */ - if (vars[i]->index != model->pred->index && - vars[i]->index != model->depvar->index) - { - if (vars[i]->type == ALPHA && vars[i]->obs_vals != NULL) - { - tmp = vars[i]->obs_vals->vals; - } - else - { - tmp = NULL; - } - /* - Make sure the variable we use is in the linear model. - */ - if (pspp_linreg_get_coeff (model, vars[i], tmp) != NULL) - { - vals[n_vals] = case_data (c, i); - model_vars[n_vals] = vars[i]; - n_vals++; - } - } + vals[i] = case_data (c, vars[i]->fv); } output->f = (*model->predict) ((const struct variable **) vars, vals, model, n_vals); free (vals); - free (model_vars); + free (vars); return TRNS_CONTINUE; } /*