Changed include paths to be explicitly specified in the #include directive.
[pspp-builds.git] / src / math / linreg / coefficient.h
1 /* lib/linreg/coefficient.c
2
3    Copyright (C) 2005 Free Software Foundation, Inc.
4    Written by Jason H Stover.
5
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.
10
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.
15
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
19    02111-1307, USA.
20  */
21
22
23 #ifndef COEFFICIENT_H
24 #define COEFFICIENT_H
25
26
27 #include <math/linreg/linreg.h>
28
29 struct design_matrix;
30
31 /*
32   Cache for the relevant data from the model. There are several
33   members which the caller might not use, and which could use a lot of
34   storage. Therefore non-essential members of the struct will be
35   allocated only when requested.
36  */
37 struct pspp_linreg_coeff
38 {
39   double estimate; /* Estimated coefficient. */
40   double std_err; /* Standard error of the estimate. */
41   struct varinfo *v_info;  /* Information pertaining to the
42                               variable(s) associated with this
43                               coefficient.  The calling function
44                               should initialize this value with the
45                               functions in coefficient.c.  The
46                               estimation procedure ignores this
47                               member. It is here so the caller can
48                               match parameters with relevant variables
49                               and values. If the coefficient is
50                               associated with an interaction, then
51                               v_info contains information for multiple
52                               variables.
53                            */
54   int n_vars; /* Number of variables associated with this coefficient.
55                  Coefficients corresponding to interaction terms will
56                  have more than one variable.
57               */
58 };
59
60
61
62 /*
63   Accessor functions for matching coefficients and variables.
64  */
65
66 void pspp_linreg_coeff_free (struct pspp_linreg_coeff *c);
67
68 /*
69   Initialize the variable and value pointers inside the
70   coefficient structures for the linear model.
71  */
72 void
73 pspp_linreg_coeff_init (pspp_linreg_cache *c, 
74                         struct design_matrix *X);
75
76
77 void
78 pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *c,
79                                 double estimate);
80
81 void
82 pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *c,
83                                double std_err);
84 /*
85   How many variables are associated with this coefficient?
86  */
87 int
88 pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *c);
89
90 /*
91   Which variable does this coefficient match?
92  */
93 const struct variable *
94 pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *c, int i);
95
96 /* 
97    Which value is associated with this coefficient/variable comination? 
98 */
99 const union value *
100 pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *c,
101                              const struct variable *v);
102
103
104 #endif