X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flinreg.c;h=63d1a0f976ee420ca52b476e67aa85cd94ff4a5e;hb=0f1b17abb6bd3e98e0f0747950144fe2ea67ea2f;hp=8bf1ad62f70a345702b75fff14f6f992f711471c;hpb=f50fcf3adae1695a0ae3ca148c3bba68071c1bd3;p=pspp-builds.git diff --git a/src/math/linreg.c b/src/math/linreg.c index 8bf1ad62..63d1a0f9 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. 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 @@ -74,6 +74,7 @@ linreg_alloc (const struct variable *depvar, const struct variable **indep_vars, c = xmalloc (sizeof (*c)); c->depvar = depvar; c->indep_vars = xnmalloc (p, sizeof (*indep_vars)); + c->dependent_column = p; for (i = 0; i < p; i++) { c->indep_vars[i] = indep_vars[i]; @@ -268,6 +269,8 @@ void linreg_set_indep_variable_mean (linreg *c, size_t j, double m) static void linreg_fit_qr (const gsl_matrix *cov, linreg *l) { + double intcpt_coef = 0.0; + double intercept_variance = 0.0; gsl_matrix *xtx; gsl_matrix *q; gsl_matrix *r; @@ -312,7 +315,6 @@ linreg_fit_qr (const gsl_matrix *cov, linreg *l) gsl_blas_dtrsm (CblasLeft, CblasLower, CblasNoTrans, CblasNonUnit, linreg_mse (l), r, q); /* Copy the lower triangle into the upper triangle. */ - double intercept_variance = 0.0; for (i = 0; i < q->size1; i++) { gsl_matrix_set (l->cov, i + 1, i + 1, gsl_matrix_get (q, i, i)); @@ -336,7 +338,6 @@ linreg_fit_qr (const gsl_matrix *cov, linreg *l) /* Covariances related to the intercept. */ intercept_variance += linreg_mse (l) / linreg_n_obs (l); gsl_matrix_set (l->cov, 0, 0, intercept_variance); - double intcpt_coef = 0.0; for (i = 0; i < q->size1; i++) { for (j = 0; j < q->size2; j++) @@ -375,7 +376,7 @@ linreg_fit (const gsl_matrix *cov, linreg *l) gsl_matrix *params; params = gsl_matrix_calloc (cov->size1, cov->size2); gsl_matrix_memcpy (params, cov); - reg_sweep (params); + reg_sweep (params, l->dependent_column); post_sweep_computations (l, params); gsl_matrix_free (params); }