1 /* lib/linreg/coefficient.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
27 #include <math/linreg/linreg.h>
28 #include <src/data/variable.h>
29 #include <src/data/value.h>
34 Cache for the relevant data from the model. There are several
35 members which the caller might not use, and which could use a lot of
36 storage. Therefore non-essential members of the struct will be
37 allocated only when requested.
39 struct pspp_linreg_coeff
41 double estimate; /* Estimated coefficient. */
42 double std_err; /* Standard error of the estimate. */
43 struct varinfo *v_info; /* Information pertaining to the
44 variable(s) associated with this
45 coefficient. The calling function
46 should initialize this value with the
47 functions in coefficient.c. The
48 estimation procedure ignores this
49 member. It is here so the caller can
50 match parameters with relevant variables
51 and values. If the coefficient is
52 associated with an interaction, then
53 v_info contains information for multiple
56 int n_vars; /* Number of variables associated with this coefficient.
57 Coefficients corresponding to interaction terms will
58 have more than one variable.
65 Accessor functions for matching coefficients and variables.
68 void pspp_linreg_coeff_free (struct pspp_linreg_coeff *);
71 Initialize the variable and value pointers inside the
72 coefficient structures for the linear model.
75 pspp_linreg_coeff_init (pspp_linreg_cache *,
76 struct design_matrix *);
80 pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *,
84 pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *,
87 Return the estimated value of the coefficient.
90 pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *);
93 Return the standard error of the estimated coefficient.
96 pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *);
99 How many variables are associated with this coefficient?
102 pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *);
105 Which variable does this coefficient match?
107 const struct variable *
108 pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *, int );
111 Which value is associated with this coefficient/variable comination?
114 pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *,
115 const struct variable *);
117 const struct pspp_linreg_coeff *
118 pspp_linreg_get_coeff (const pspp_linreg_cache *,
119 const struct variable *,
120 const union value *);