X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flinreg%2Fcoefficient.h;h=0dc1a0353943b67e81e1a7bf5d73f4b4a4692874;hb=7ae8b9ba0e2634a5b72ac6470ebbdf92a78b7892;hp=a82b54200f88e03a11df9c1319118b3ae7be2c39;hpb=a19b858e0ac3c69e4a28c0ca6d8674427268a863;p=pspp diff --git a/src/math/linreg/coefficient.h b/src/math/linreg/coefficient.h index a82b54200f..0dc1a03539 100644 --- a/src/math/linreg/coefficient.h +++ b/src/math/linreg/coefficient.h @@ -1,30 +1,31 @@ -/* lib/linreg/coefficient.c - - Copyright (C) 2005 Free Software Foundation, Inc. - Written by Jason H Stover. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02111-1307, USA. - */ +/* + lib/linreg/coefficient.c + + Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover. + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 51 + Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. +*/ #ifndef COEFFICIENT_H #define COEFFICIENT_H - +#include #include +#include +#include struct design_matrix; @@ -36,69 +37,74 @@ struct design_matrix; */ struct pspp_linreg_coeff { - double estimate; /* Estimated coefficient. */ - double std_err; /* Standard error of the estimate. */ - struct varinfo *v_info; /* Information pertaining to the - variable(s) associated with this - coefficient. The calling function - should initialize this value with the - functions in coefficient.c. The - estimation procedure ignores this - member. It is here so the caller can - match parameters with relevant variables - and values. If the coefficient is - associated with an interaction, then - v_info contains information for multiple - variables. - */ - int n_vars; /* Number of variables associated with this coefficient. - Coefficients corresponding to interaction terms will - have more than one variable. - */ + double estimate; /* Estimated coefficient. */ + double std_err; /* Standard error of the estimate. */ + struct varinfo *v_info; /* Information pertaining to the variable(s) + associated with this coefficient. The + calling function should initialize this + value with the functions in coefficient.c. + The estimation procedure ignores this + member. It is here so the caller can match + parameters with relevant variables and + values. If the coefficient is associated + with an interaction, then v_info contains + information for multiple variables. */ + int n_vars; /* Number of variables associated with this + coefficient. Coefficients corresponding to + interaction terms will have more than one + variable. */ }; - -/* - Accessor functions for matching coefficients and variables. - */ - -void pspp_linreg_coeff_free (struct pspp_linreg_coeff *c); +void pspp_linreg_coeff_free (struct pspp_linreg_coeff *); /* Initialize the variable and value pointers inside the coefficient structures for the linear model. */ -void -pspp_linreg_coeff_init (pspp_linreg_cache *c, - struct design_matrix *X); +void pspp_linreg_coeff_init (pspp_linreg_cache *, struct design_matrix *); void -pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *c, - double estimate); +pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *, double estimate); void -pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *c, - double std_err); +pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err); + /* - How many variables are associated with this coefficient? + Accessor functions for matching coefficients and variables. */ -int -pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *c); /* - Which variable does this coefficient match? + Return the estimated value of the coefficient. */ -const struct variable * -pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *c, int i); +double pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *); -/* - Which value is associated with this coefficient/variable comination? +/* + Return the standard error of the estimated coefficient. */ -const union value * -pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *c, - const struct variable *v); +double pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *); +/* + How many variables are associated with this coefficient? + */ +int pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *); +/* + Which variable does this coefficient match? The int argument is usually + 0, unless the coefficient refers to an interaction. + */ +const struct variable *pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *, + int); +/* + Which value is associated with this coefficient/variable comination? + */ +const union value *pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *, + const struct variable *); + +const struct pspp_linreg_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache + *, + const struct variable + *, + const union value *); #endif