X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flinreg%2Flinreg.c;h=217e201ce588bbbb95a3688ddb89beaebfe7e102;hb=09907ebe926441d6a6834f358844e10358ea86e2;hp=9465875e81b3c697d58fa27112bccc466188ece3;hpb=a94d5054363ca725a6810780b3621f064956929a;p=pspp-builds.git diff --git a/src/math/linreg/linreg.c b/src/math/linreg/linreg.c index 9465875e..217e201c 100644 --- a/src/math/linreg/linreg.c +++ b/src/math/linreg/linreg.c @@ -107,10 +107,7 @@ pspp_linreg_get_vars (const void *c_, const struct variable **v) { v[i] = NULL; } - /* - Start at c->coeff[1] to avoid the intercept. - */ - for (j = 1; j < c->n_coeffs; j++) + for (j = 0; j < c->n_coeffs; j++) { tmp = pspp_coeff_get_var (c->coeff[j], 0); assert (tmp != NULL); @@ -243,9 +240,9 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, cache->dft = cache->n_obs - 1; cache->dfm = cache->n_indeps; cache->dfe = cache->dft - cache->dfm; - cache->n_coeffs = X->size2 + 1; /* Adjust this later to allow for - regression through the origin. - */ + cache->n_coeffs = X->size2; + cache->intercept = 0.0; + if (cache->method == PSPP_LINREG_SWEEP) { gsl_matrix *sw; @@ -319,7 +316,7 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, for (i = 0; i < cache->n_indeps; i++) { tmp = gsl_matrix_get (sw, i, cache->n_indeps); - cache->coeff[i + 1]->estimate = tmp; + cache->coeff[i]->estimate = tmp; m -= tmp * gsl_vector_get (cache->indep_means, i); } /* @@ -355,7 +352,7 @@ pspp_linreg (const gsl_vector * Y, const gsl_matrix * X, } gsl_matrix_set (cache->cov, 0, 0, tmp); - cache->coeff[0]->estimate = m; + cache->intercept = m; } else {