Commit e47470a4 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

White-space mania.

1999-12-17  Morten Welinder  <terra@diku.dk>

	* src/functions/fn-stat.c: White-space mania.

1999-12-16  Andrew Chatham  <andrew.chatham@duke.edu>

	* src/regression.h: Better comments for parts of extra_stat
	* src/regression.c (linear_solve): Fixed adjusted R^2 bug (hopefully).
	* src/functions/fn-stat.c (gnumeric_linest, gnumeric_logest) Added
	beginning support for 3+ dimensional regressions in linest and logest.
	* src/analysis-tools.c (regression_tool) Documented Excel bugs with
	no-intercept regressions that I didn't/can't mimic.
parent 7b7513b5
1999-12-17 Morten Welinder <terra@diku.dk>
* src/functions/fn-stat.c: White-space mania.
1999-12-16 Andrew Chatham <andrew.chatham@duke.edu>
* src/regression.h: Better comments for parts of extra_stat
* src/regression.c (linear_solve): Fixed adjusted R^2 bug (hopefully).
* src/functions/fn-stat.c (gnumeric_linest, gnumeric_logest) Added
beginning support for 3+ dimensional regressions in linest and logest.
* src/analysis-tools.c (regression_tool) Documented Excel bugs with
no-intercept regressions that I didn't/can't mimic.
1999-12-16 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_destroy): Plug leak.
......
......@@ -18,6 +18,9 @@ Frank:
Cort:
* Expanded CORBA API.
Andrew:
* Many improvement for multi-dimensional linear regression.
--------------------------------------------------------------------------
Gnumeric 0.45
......
1999-12-17 Morten Welinder <terra@diku.dk>
* src/functions/fn-stat.c: White-space mania.
1999-12-16 Andrew Chatham <andrew.chatham@duke.edu>
* src/regression.h: Better comments for parts of extra_stat
* src/regression.c (linear_solve): Fixed adjusted R^2 bug (hopefully).
* src/functions/fn-stat.c (gnumeric_linest, gnumeric_logest) Added
beginning support for 3+ dimensional regressions in linest and logest.
* src/analysis-tools.c (regression_tool) Documented Excel bugs with
no-intercept regressions that I didn't/can't mimic.
1999-12-16 Morten Welinder <terra@diku.dk>
* src/func.c (tokenized_help_destroy): Plug leak.
......
This diff is collapsed.
......@@ -1765,6 +1765,28 @@ int random_tool (Workbook *wb, Sheet *sheet, int vars, int count,
* The results are given in a table which can be printed out in a new
* sheet, in a new workbook, or simply into an existing sheet.
*
* Excel Bug 1: (Andrew) I believe that the following is a bug in Excel: When
* calculating the F-statistic in the no-intercept case, it will use xdim as
* the numerator df and (n - xdim) as the denominator df, which is as it should
* be. However, in the regression it will then calculate the significance of the
* F-statistic using (n - #slope parameters - 1) as the denominator df, which
* makes sense when you are calculating an intercept, but in this case you are not
* and the df should be just (n - #slope parameters). Excel is inconsistent,
* in that it does not use the same df to calculate the significance that it
* does to calculate the the F-stat itself. Inference on regressions
* without intercepts don't really work anyway (because of the way the
* statistics work, not the code), so this is not a terribly big deal, and
* those who would actually use the significance of F are not likely to be
* using interceptless regressions anyway. So while it is easy to mimic Excel
* in this respect, currently we do not and chose what at least for now seems
* to be more correct.
*
* Excel Bug 2: (Andrew) Also in the no-intercept case: Excel has some weird way of
* calculating the adjusted R^2 value that makes absolutely no sense to me, so
* I couldn't mimic it if I tried. Again, what statistical opinion I have found
* suggests that if you're running interceptless regressions, you won't know what
* to do with an adjusted R^2 anyway.
*
**/
int regression_tool (Workbook *wb, Sheet *sheet, Range *input_range_y,
......
This diff is collapsed.
......@@ -124,14 +124,12 @@ linear_solve (float_t **A, float_t *b, int n, float_t *res)
/* Special case. */
if (n == 2) {
float_t d = A[0][0] * A[1][1] - A[1][0] * A[0][1];
if (d == 0)
return 2; /* Singular. */
res[0] = (A[1][1] * b[0] - A[1][0] * b[1]) / d;
res[1] = (A[0][0] * b[1] - A[0][1] * b[0]) / d;
return 0;
}
}
/* Otherwise, use LUP-decomposition to find res such that
xTx * res = b */
......@@ -209,6 +207,7 @@ general_linear_regression (float_t **xss, int xdim,
int err2;
float_t *residuals = g_new (float_t, n);
float_t **LU;
float_t ss_total = 0;
int *P;
float_t *e, *inv;
......@@ -251,7 +250,7 @@ general_linear_regression (float_t **xss, int xdim,
/* FIXME: we want to guard against division by zero. */
extra_stat->sqr_r = 1 - (extra_stat->ss_resid / extra_stat->se_y);
extra_stat->adj_sqr_r = 1 - (extra_stat->ss_resid / (n - xdim - affine)) / (extra_stat->se_y / (n - 1));
extra_stat->adj_sqr_r = 1 - (extra_stat->ss_resid / (n - xdim)) / (extra_stat->se_y / (n - 1));
extra_stat->var = (extra_stat->ss_resid / (n - xdim));
ALLOC_MATRIX (LU, xdim, xdim);
......@@ -285,7 +284,10 @@ general_linear_regression (float_t **xss, int xdim,
((1 - extra_stat->sqr_r) / (n - xdim));
extra_stat->df = n-xdim;
extra_stat->ss_reg = 0;
for (i = 0; i < n; i++)
ss_total += (ys[i] - extra_stat->ybar) *
(ys[i] - extra_stat->ybar);
extra_stat->ss_reg = ss_total - extra_stat->ss_resid;
extra_stat->se_y = sqrt (extra_stat->se_y / n); /* Now it is SE */
g_free (residuals);
}
......
......@@ -25,14 +25,15 @@ typedef struct {
float_t *t; /*t values for each parameter estimator*/
float_t sqr_r;
float_t adj_sqr_r;
float_t se_y;
float_t se_y; /* The Standard Error of Y */
float_t F;
int df;
float_t ss_reg;
float_t ss_resid;
float_t ybar;
float_t *xbar;
float_t var;
float_t var; /* The variance of the entire regression:
sum(errors^2)/(n-xdim) */
} regression_stat_t;
int linear_regression (float_t **xss, int dim,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment