Code for 2 new Gnumeric functions (logarithmic regression)



Hello,

This is a request that you consider to incorporate the attached code
for two new functions into the Gnumeric distribution.

I am no registered Gnumeric developer. If there is a more appropriate
place to send this request to, please tell me.

I have written this code for Gnumeric version 1.0.9.

The functions both perform logarithmic regression. The fitted
logarithmic equations can mimic the trend of some types of scientific
data and serve as calibration-equations for the calculation of
unknowns.

1.)

``LOGREG'' fits the parameters `a' and `b' of the equation

"y = b + a * log(x)".

It transforms x's to z=log(x) and then calls
``general_linear_regression'' written by others to perform a linear
regression of y's and z's. Although the transformation to log(x) could
also be done within a worksheet, logarithmic regression seemed general
enough to me to deserve an extra function. In Excel, this
functionality is not available as a function, but is available as a
``trend curve'' within graphs. ``general_linear_regression'' written
by others provides multidimensional regression, although the
corresponding ``LINEST'' function is not yet quite ready to deal with
more than one independent variable. ``LOGREG'' is prepared to use this
functionality, as soon as LINEST uses it, too --- although I do not
know if multidimensional regression of logarithmically transformed
independent data is useful in statistical praxis.

2.)

``LOGFIT'' fits the parameters `sign', `a', `b', and `c' of the
equation

"y = a + b * log (sign * (x - c))", with sign in {-1, +1}.

This equation can be well adapted to point clouds which, although
shaped ``logarithmic'', are shifted in the direction of the x-axis. In
these cases, ``LOGREG'' would often fail or produce bad fits. At work,
I have often encountered such data in assays which correlate optical
densities with substance amounts. If sign == -1, the graph of the
equation is mirrored across the y-axis.

``LOGFIT'' performs non-linear fitting. It searches for the best c
while computing the corresponding a and b for each c by a simple
linear regression. This approach could also be carried out using a
general solver, but then the success would depend on the choosing of
suitable starting parameters (I have tried it with the Excel solver),
and the preparation of such a worksheet would be complicated.

A function corresponding to ``LOGFIT'' is not available in Excel.


The two functions would affect the files regression.c and
regression.h, of which Morten Welinder and Andrew Chatham are the
authors, and the file functions/fn-stat.c. ``LOGREG'' relies on code
from these authors in these files.

Regards,

Olaf

Attachment: regression.c.1.0.9.diff
Description: Text document

Attachment: regression.h.1.0.9.diff
Description: Text document

Attachment: fn-stat.c.1.0.9.diff
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]