store intercept in proper place when using QR method
[pspp-builds.git] / src / math / linreg / linreg.c
index 217e201ce588bbbb95a3688ddb89beaebfe7e102..0782c36fc3df82aae30d00c5f88fbd5f89aa3ad7 100644 (file)
@@ -397,10 +397,11 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X,
       wk = gsl_multifit_linear_alloc (design->size1, design->size2);
       rc = gsl_multifit_linear (design, Y, param_estimates,
                                cache->cov, &(cache->sse), wk);
-      for (i = 0; i < cache->n_coeffs; i++)
+      for (i = 1; i < cache->n_coeffs; i++)
        {
          cache->coeff[i]->estimate = gsl_vector_get (param_estimates, i);
        }
+      cache->intercept = gsl_vector_get (param_estimates, 0);
       if (rc == GSL_SUCCESS)
        {
          gsl_multifit_linear_free (wk);