1 /* lib/linreg/predict.c
3 Copyright (C) 2005 Free Software Foundation, Inc.
4 Written by Jason H. Stover.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at
9 your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <math/linreg/linreg.h>
23 #include <math/linreg/coefficient.h>
26 Predict the value of the dependent variable with the
27 new set of predictors. PREDICTORS must point to a list
28 of variables, each of whose values are stored in VALS,
32 pspp_linreg_predict (const struct variable *predictors,
33 const union value *vals,
34 const pspp_linreg_cache *c,
41 assert (predictors != NULL);
42 assert (vals != NULL);
45 result = c->coeff->estimate; /* Intercept. */
48 Stop at the minimum of c->n_coeffs and n_vals in case
49 the caller passed us inadequate information, such as too
50 few or too many values.
52 for (i = 1; i < c->n_coeffs && i < n_vals; i++)
54 tmp = pspp_linreg_coeff_get_est (pspp_linreg_get_coeff (c, predictors + i, vals + i));
55 if ((predictors + i)->type == NUMERIC)