1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include <math/linreg/linreg.h>
23 #include <src/data/variable.h>
24 #include <src/data/value.h>
27 This file contains definitions of data structures for storing
28 coefficients of a statistical model. The coefficients are the point
29 in the model where the theoretical aspects of the model meet the
30 data. As such, the coefficients are the interface where users need
31 to match variable names and values with any information about the
32 model itself. This file and coefficient.c provide this interface
33 between data and model structures.
39 Cache for the relevant data from the model. There are several
40 members which the caller might not use, and which could use a lot of
41 storage. Therefore non-essential members of the struct will be
42 allocated only when requested.
46 double estimate; /* Estimated coefficient. */
47 double std_err; /* Standard error of the estimate. */
48 struct varinfo *v_info; /* Information pertaining to the variable(s)
49 associated with this coefficient. The
50 calling function should initialize this
51 value with the functions in coefficient.c.
52 The estimation procedure ignores this
53 member. It is here so the caller can match
54 parameters with relevant variables and
55 values. If the coefficient is associated
56 with an interaction, then v_info contains
57 information for multiple variables. */
58 int n_vars; /* Number of variables associated with this
59 coefficient. Coefficients corresponding to
60 interaction terms will have more than one
63 typedef struct pspp_coeff coefficient;
65 void pspp_coeff_free (struct pspp_coeff *);
68 Initialize the variable and value pointers inside the
69 coefficient structures for the linear model.
71 void pspp_coeff_init (struct pspp_coeff **, const struct design_matrix *);
75 pspp_coeff_set_estimate (struct pspp_coeff *, double estimate);
78 pspp_coeff_set_std_err (struct pspp_coeff *, double std_err);
81 Accessor functions for matching coefficients and variables.
85 Return the estimated value of the coefficient.
87 double pspp_coeff_get_est (const struct pspp_coeff *);
90 Return the standard error of the estimated coefficient.
92 double pspp_coeff_get_std_err (const struct pspp_coeff *);
95 How many variables are associated with this coefficient?
97 int pspp_coeff_get_n_vars (struct pspp_coeff *);
100 Which variable does this coefficient match? The int argument is usually
101 0, unless the coefficient refers to an interaction.
103 const struct variable *pspp_coeff_get_var (struct pspp_coeff *,
106 Which value is associated with this coefficient/variable comination?
108 const union value *pspp_coeff_get_value (struct pspp_coeff *,
109 const struct variable *);
111 const struct pspp_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache
113 const struct variable
115 const union value *);