# Bug in Trendexp

Lindner shared this problem 8 years ago
New

Is there an explanation why there are 2 different results for Fit? Liste1 = {A, B, C, D}

f(x) = FitExp[Liste1]

g(x) = a ℯ^(-b x)

h(x) = Fit[Liste1, g]

f and h should be the same?!

Andreas

ggb 4.2.28

https://ggbm.at/561211

Best Answer Is there an explanation why there are 2 different results for Fit?

Liste1 = {A, B, C, D}

f(x) = FitExp[Liste1]

g(x) = a ℯ^(-b x)

h(x) = Fit[Liste1, g]

f and h should be the same?!

IANAGGP (I am not a GeoGebra programer), but I think I can explain what is probably going on. In a nutshell, they use two different algorithms.

The FitExp[] command linearizes the data by taking the natural log of the y values and then finding the best-fit line from all the (x,ln(y)) points. The process for doing this type of regression is very simple and fast. This best-fit line will produce results that will be fairly close to the actual best-fit exponential curve. This is what your calculator's ExpReg command does.

The Fit[] command attempts to find the best-fit curve based on the given function without doing any linearizing. It's a much more complicated process, but if done correctly will result in a curve that is the actual best-fit curve. I don't know what GG does, but the method usually involves systematically trying different values for a,b,c... until the sum of the squares of the differences between the actual and predicted y values is a minimum (the method of least-mean-squares). (If I'm not mistaken, I think that your calculator's Logistic Regression uses a similar technique which is why it takes so long to calculate.)

If you plug the data points you gave into a calculator and use ExpReg, the calculator will give you an equation equivalent to FitExp[] and report that the r^2 = 0.89318. But this is the r^2 of the line using the linearized points. If you calculate the r^2 of the suggested exponential curve, you get r^2 = 0.89459. However, if you find the r^2 of the exponential curve from Fit[], you get r^2 = 0.92381.

In other words, Fit[] gives you a better "fit" than FitExp[].

Hope this helps,

-Wes L

## Comments (4) 1

Did you try g(x) = a e^(b x) without the minus sign? It shouldn't matter but maybe this is what throws off the more complicated algorithm fot Fit[]?

Have you tried other comparisons, like linear, polynomial, trigonometric, logistic...? 1

Yes, I have tried g(x) = a e^(b x) - same result as for g(x) = a e^(-b x).

Andreas 1

Is there an explanation why there are 2 different results for Fit?

Liste1 = {A, B, C, D}

f(x) = FitExp[Liste1]

g(x) = a ℯ^(-b x)

h(x) = Fit[Liste1, g]

f and h should be the same?!

IANAGGP (I am not a GeoGebra programer), but I think I can explain what is probably going on. In a nutshell, they use two different algorithms.

The FitExp[] command linearizes the data by taking the natural log of the y values and then finding the best-fit line from all the (x,ln(y)) points. The process for doing this type of regression is very simple and fast. This best-fit line will produce results that will be fairly close to the actual best-fit exponential curve. This is what your calculator's ExpReg command does.

The Fit[] command attempts to find the best-fit curve based on the given function without doing any linearizing. It's a much more complicated process, but if done correctly will result in a curve that is the actual best-fit curve. I don't know what GG does, but the method usually involves systematically trying different values for a,b,c... until the sum of the squares of the differences between the actual and predicted y values is a minimum (the method of least-mean-squares). (If I'm not mistaken, I think that your calculator's Logistic Regression uses a similar technique which is why it takes so long to calculate.)

If you plug the data points you gave into a calculator and use ExpReg, the calculator will give you an equation equivalent to FitExp[] and report that the r^2 = 0.89318. But this is the r^2 of the line using the linearized points. If you calculate the r^2 of the suggested exponential curve, you get r^2 = 0.89459. However, if you find the r^2 of the exponential curve from Fit[], you get r^2 = 0.92381.

In other words, Fit[] gives you a better "fit" than FitExp[].

Hope this helps,

-Wes L 1

Well, it helped me at least. Thanks for a clear and concise explanation.

:-)

Leave a Comment
• GeoGebra
• Help
• Partners
• Contact us
• Feedback & Questions
• This email address is being protected from spambots. You need JavaScript enabled to view it.
• +43 677 6137 2693
© 2021 International GeoGebra Institute