Coefficient changes with log transformation; how to interpret the original coefficients?

Melisandre

New member
Joined
Sep 8, 2023
Messages
4
Hi all,

I have a non-linear equation I would like to fit to some data points, however given the range of resulting data (y) values the raw fit to this equation is skewed. However, by transforming both sides of the equation by log[10], the equation fits but the resulting fitting coefficients cannot be directly applied to data that is not log transformed.

The original equation is as follows, with independent coefficients a, b and g:

y = ((1+(b/a))*exp(a*g*x)-(b/a))^(-1/g).

taking log[10] of both sides:

log(y) = log(((1+(b/a))*exp(a*g*x)-(b/a))^(-1/g))

As mentioned, this log transformation of the data and equation provides a good fit, though the calculated coefficients a, b and g need to be modified somehow so they can be applied to the original data/equation.

How is this achieved? I'm really hoping someone can shed some light on this problem.

Many thanks,

M
 
The original equation is as follows, with independent coefficients a, b and g:

y = ((1+(b/a))*exp(a*g*x)-(b/a))^(-1/g). (i)

taking log[10] of both sides:

log(y) = log(((1+(b/a))*exp(a*g*x)-(b/a))^(-1/g)) (ii)

To get started, are the equations (labelled (i) and (ii) above) correctly formatted below?

(i) [imath]y = \left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}[/imath]

(ii) [imath]\log(y) = \log\left(\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}\right)[/imath]

Thank you!
 
I have a non-linear equation I would like to fit to some data points, however given the range of resulting data (y) values the raw fit to this equation is skewed. However, by transforming both sides of the equation by log[10], the equation fits but the resulting fitting coefficients cannot be directly applied to data that is not log transformed.

Could you perhaps clarify what you mean by the above? In particular, what do you mean when you want to change "the resulting fitting coeffiients"? What do you mean by the values of the numbers no longer being applicable?

Thank you!
 
As mentioned, this log transformation of the data and equation provides a good fit, though the calculated coefficients a, b and g need to be modified somehow so they can be applied to the original data/equation.
I think it will help if you show the actual data and the equation you got (including the coefficients), how you got them, and what does and doesn't work.
 
Ok sure.

So essentially what I'm needing are the coefficients a, b and g as per equ. 1 that produces a good fit to my data points.

I have a set of data points (y) for which the non-linear equ. 1 is a good fit (provided the right coefficients are used). To find these coefficients, I use mathematical software that calculates each coefficient according to equ. 1 using the x, y data (Table1_2) as an input:

1694404120846.png

However, as you can see, the fit equation is skewed relative to the data and doesn't represent it well. Here, the program calculates a = 3.313, b=11.492 and g=0.605 for the "fit".

Apparently this deviation is due to the very large range of data y-values (shown as a log scale on the graph) and the fitting equation is skewing or biasing towards the LHS data points. Again, apparently, this is solved by taking log[10] of both sides of the equ. 1 i.e., taking the log of all the data points on the y-axis and taking the log of the fitting equ with the coefficients, resulting in equ. 2.

When using the log-transformed fitting equation with the log-transformed data points, the fit is much more accurate and different coefficients are produced:

1694404307575.png
Here, a = 1.028, b=4.788 and g=1.007. The salient point here is if I use the coefficients from equ. 1 for my "raw" data (y-values), the fit is not good. And while the coefficients from equ. 2 fit well, they themselves have been log-transformed and fit against the log of the data points. This is summarised in the graph below:

1694407051479.png

As you can see, a, b and g coefficients using either Equ. 1 or Equ. 2 do not fit well to the raw data. However, I was able to get a relatively good fit to the raw data using factors applied to the coefficients from Equ.2 (given that a nice fit was achieved with the log-transform approach). A table of all these coefficients is shown below:

1694407026940.png

Essentially I multiplied the 'a' and 'b' log-fit coefficients by 2.5 to get the corresponding estimated fit values, and the 'g' coefficient by 0.5. I then plugged these into Equ. 1 to get a pretty good fit to the raw data. Of course, this is just a trial-and-error stab in the dark approach and not at all mathematical!

So my question boils down to this: how do you go from the a, b, g log fit coefficients derived using Equ. 2, to values that I can use with the raw data and the raw fitting equation as per Equ. 1? (Note: I'm assuming here that some sort of operation is to be applied to the log fit coefficients as guesstimated above as I have information that suggests this is the right way to go, though I don't know how to mathematically arrive at this 'factor').

Thank you everyone for your patience and time in looking into this with me, it's really appreciated.

- M
 
I have a set of data points (y) for which the non-linear equ. 1 is a good fit (provided the right coefficients are used). To find these coefficients, I use mathematical software that calculates each coefficient according to equ. 1 using the x, y data (Table1_2) as an input:
...
However, as you can see, the fit equation is skewed relative to the data and doesn't represent it well. Here, the program calculates a = 3.313, b=11.492 and g=0.605 for the "fit".
I'm not sure why you say the equation is a good fit, when it clearly is not (for larger values of x). Maybe you just mean that it's supposed to be a good fit.
Apparently this deviation is due to the very large range of data y-values (shown as a log scale on the graph) and the fitting equation is skewing or biasing towards the LHS data points. Again, apparently, this is solved by taking log[10] of both sides of the equ. 1 i.e., taking the log of all the data points on the y-axis and taking the log of the fitting equ with the coefficients, resulting in equ. 2.

When using the log-transformed fitting equation with the log-transformed data points, the fit is much more accurate and different coefficients are produced:
...
Here, a = 1.028, b=4.788 and g=1.007. The salient point here is if I use the coefficients from equ. 1 for my "raw" data (y-values), the fit is not good. And while the coefficients from equ. 2 fit well, they themselves have been log-transformed and fit against the log of the data points.
I'm still not quite sure exactly what you are plotting, and what you say doesn't fit. What does it mean to say "the coefficients have been log-transformed"?

Now, what I would expect is that when you fit the curve [math]\log(y) = \log\left(\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}\right)[/math] to your data, you would then compare the data to [math]y = 10^{\log\left(\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}\right)}[/math] using the coefficients you got, and it would agree. Is that not what you did?
 
I'm not sure why you say the equation is a good fit, when it clearly is not (for larger values of x). Maybe you just mean that it's supposed to be a good fit.
Yes, as I expanded upon it's supposed to be a good fit and it's what I have to work with.

I'm still not quite sure exactly what you are plotting, and what you say doesn't fit. What does it mean to say "the coefficients have been log-transformed"?
I mean that the coefficients a, b, and g in Equ. 2 have been derived with a log function. Not just applied to the data points, but with the fitting equation itself. Which means I cannot simply plug the coefficients calculated using Equ. 2 into Equ. 1 (this results in the orange curve on the composite graph).

I'm still not quite sure exactly what you are plotting,
The colored plot with multiple lines shows different plots of Equ. 1, using different sets of a, b, g coefficients derived using the methods I've already detailed along with the raw data points (triangles). Note that a good fit using Equ. 1 can be achieved (green estimated fit line) to these data points by calculating coefficients that are a function of the log-derived coefficients obtained using Equ. 2. In this case, the function was to multiply the Equ. 2 coefficients (or log-transformed coefficients) by 2.5 for 'a' and 'b', and 0.5 for 'g' (as shown in the table).

The question I would like you to address is, how do you arrive at this function? Or, how do you take the coefficients calculated in Equ. 2 and modify them so they can be used directly in Equ. 1?

Now, what I would expect is that when you fit the curve log⁡(y)=log⁡(((1+ba) eagx−ba)−1/g)\log(y) = \log\left(\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}\right)log(y)=log(((1+ab)eagx−ab)−1/g) to your data, you would then compare the data to y=10log⁡(((1+ba) eagx−ba)−1/g)y = 10^{\log\left(\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g}\right)}y=10log(((1+ab)eagx−ab)−1/g) using the coefficients you got, and it would agree. Is that not what you did?

Even if this were the case, that's not what I'm after as reiterated above. The agreement between data points (y) and fitting equation (Equ. 1) are met when both the data points and fitting equation have a log function applied to them (Equ. 2) and with this approach, the fitting program gives me coefficients a, b and g. Now, I want to know how to apply some function to these to get respective coefficients I can use in Equ. 1 with data, and a fitting equation, that does NOT have a log function applied to it. As shown in the graph, clearly this is possible (with my estimated fit coefficients) and appears to be some linear function of these "Equ. 2" coefficients (x2.5 for both 'a' and 'b'; x0.5 for 'g' or thereabouts).

So again, the summarized question is: how do you take the coefficients calculated in Equ. 2 and modify them so they can be used directly in Equ. 1?
 
If I were sitting next to you, I would be looking at your data and your fitting program to try to figure out exactly what the issue is. Explanations in words just aren't working.

Can you give us the data table so we can try to graph your equations and see for ourselves how they do or do not fit the data when we adjust things? I just can't be sure exactly what you are saying without being hands-on.

And I wish someone else who has more experience with this sort of fitting would join in.
 
To summarize the thread.
The OP found the parameters that fit under log-scaled for y.

[math]\large \log(y) = \log\left(\left(\left(1 + \frac{4.788}{1.028}\right)\,e^{1.028\cdot 1.077x} - \frac{4.788}{1.028}\right)^{-1/1.077}\right)[/math]
Or equivalently
[math]\large y = 10^{\log\left(\left(\left(1 + \frac{4.788}{1.028}\right)\,e^{1.028\cdot 1.077x} - \frac{4.788}{1.028}\right)^{-1/1.077}\right)}[/math]
The OP is seeking [imath]a,b,g[/imath] such that
[math]\Large y=\left(\left(1 + \frac{b}{a}\right)\,e^{agx} - \frac{b}{a}\right)^{-1/g} = 10^{\log\left(\left(\left(1 + \frac{4.788}{1.028}\right)\,e^{1.028\cdot 1.077x} - \frac{4.788}{1.028}\right)^{-1/1.077}\right)}[/math]
 
Top