1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2005, 2011 Free Software Foundation, Inc. Written by Jason H. Stover.
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/>. */
20 #include <gsl/gsl_matrix.h>
24 Find the least-squares estimate of b for the linear model:
28 where Y is an n-by-1 column vector, X is an n-by-p matrix of
29 independent variables, b is a p-by-1 vector of regression coefficients,
30 and Z is an n-by-1 normally-distributed random vector with independent
31 identically distributed components with mean 0.
33 This estimate is found via the sweep operator or singular-value
34 decomposition with gsl.
39 1. Matrix Computations, third edition. GH Golub and CF Van Loan.
40 The Johns Hopkins University Press. 1996. ISBN 0-8018-5414-8.
42 2. Numerical Analysis for Statisticians. K Lange. Springer. 1999.
45 3. Numerical Linear Algebra for Applications in Statistics. JE Gentle.
46 Springer. 1998. ISBN 0-387-98542-5.
51 struct linreg *linreg_alloc (const struct variable *, const struct variable **,
52 double, size_t, bool);
54 void linreg_unref (struct linreg *);
55 void linreg_ref (struct linreg *);
57 int linreg_n_indeps (const struct linreg *c);
60 Fit the linear model via least squares.
62 void linreg_fit (const gsl_matrix *, struct linreg *);
64 double linreg_predict (const struct linreg *, const double *, size_t);
65 double linreg_residual (const struct linreg *, double, const double *, size_t);
66 const struct variable ** linreg_get_vars (const struct linreg *);
69 Mean of the independent variable.
71 double linreg_get_indep_variable_mean (const struct linreg *, size_t);
72 void linreg_set_indep_variable_mean (struct linreg *, size_t, double);
74 double linreg_mse (const struct linreg *);
76 double linreg_intercept (const struct linreg *);
78 const gsl_matrix * linreg_cov (const struct linreg *);
79 double linreg_coeff (const struct linreg *, size_t);
80 const struct variable * linreg_indep_var (const struct linreg *, size_t);
81 const struct variable * linreg_dep_var (const struct linreg *);
82 size_t linreg_n_coeffs (const struct linreg *);
83 double linreg_n_obs (const struct linreg *);
84 double linreg_sse (const struct linreg *);
85 double linreg_ssreg (const struct linreg *);
86 double linreg_dfmodel (const struct linreg *);
87 double linreg_dferror (const struct linreg *);
88 double linreg_dftotal (const struct linreg *);
89 double linreg_sst (const struct linreg *);
90 void linreg_set_depvar_mean (struct linreg *, double);
91 double linreg_get_depvar_mean (const struct linreg *);