From c18af316ce7ec02e6fd7c3417f914a6658ddbe71 Mon Sep 17 00:00:00 2001 From: Jason Stover Date: Mon, 28 Nov 2005 03:17:00 +0000 Subject: [PATCH] Correct reporting for parametr estimates via QR decomposition --- lib/linreg/linreg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/linreg/linreg.c b/lib/linreg/linreg.c index 2a8aff3f..fb6bbc45 100644 --- a/lib/linreg/linreg.c +++ b/lib/linreg/linreg.c @@ -139,6 +139,7 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, gsl_vector_view xty; gsl_vector_view xi; gsl_vector_view xj; + gsl_vector *param_estimates; size_t i; size_t j; @@ -300,6 +301,8 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, /* Use QR decomposition via GSL. */ + + param_estimates = gsl_vector_alloc (1 + X->size2); design = gsl_matrix_alloc (X->size1, 1 + X->size2); for (j = 0; j < X->size1; j++) @@ -313,11 +316,16 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, } gsl_multifit_linear_workspace *wk = gsl_multifit_linear_alloc (design->size1, design->size2); - rc = gsl_multifit_linear (design, Y, cache->param_estimates, + rc = gsl_multifit_linear (design, Y, param_estimates, cache->cov, &(cache->sse), wk); + for (i = 0; i < cache->n_coeffs; i++) + { + cache->coeff[i].estimate = gsl_vector_get (param_estimates, i); + } if (rc == GSL_SUCCESS) { gsl_multifit_linear_free (wk); + gsl_vector_free (param_estimates); } else { -- 2.30.2