2 lib/linreg/coefficient.c
4 Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover.
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 51
18 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
26 #include <math/linreg/linreg.h>
27 #include <src/data/variable.h>
28 #include <src/data/value.h>
33 Cache for the relevant data from the model. There are several
34 members which the caller might not use, and which could use a lot of
35 storage. Therefore non-essential members of the struct will be
36 allocated only when requested.
38 struct pspp_linreg_coeff
40 double estimate; /* Estimated coefficient. */
41 double std_err; /* Standard error of the estimate. */
42 struct varinfo *v_info; /* Information pertaining to the variable(s)
43 associated with this coefficient. The
44 calling function should initialize this
45 value with the functions in coefficient.c.
46 The estimation procedure ignores this
47 member. It is here so the caller can match
48 parameters with relevant variables and
49 values. If the coefficient is associated
50 with an interaction, then v_info contains
51 information for multiple variables. */
52 int n_vars; /* Number of variables associated with this
53 coefficient. Coefficients corresponding to
54 interaction terms will have more than one
59 void pspp_linreg_coeff_free (struct pspp_linreg_coeff *);
62 Initialize the variable and value pointers inside the
63 coefficient structures for the linear model.
65 void pspp_linreg_coeff_init (pspp_linreg_cache *, struct design_matrix *);
69 pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *, double estimate);
72 pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err);
75 Accessor functions for matching coefficients and variables.
79 Return the estimated value of the coefficient.
81 double pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *);
84 Return the standard error of the estimated coefficient.
86 double pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *);
89 How many variables are associated with this coefficient?
91 int pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *);
94 Which variable does this coefficient match? The int argument is usually
95 0, unless the coefficient refers to an interaction.
97 const struct variable *pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *,
100 Which value is associated with this coefficient/variable comination?
102 const union value *pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *,
103 const struct variable *);
105 const struct pspp_linreg_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache
107 const struct variable
109 const union value *);