MATLAB: Accuracy of coefficients using fit with power1

power model regression fit

I'm seeing a discrepency between the coefficients obtained via MATLAB's fit function using the fitType power1 and the coefficients provided with the same data using two other stats packages, one of which is Excel. The other is JMP, which agrees with Excel. So, I'm thinking the Excel and JMP values are likely correct. Here a simple data set:
x = [1 2 3 4 5]
y = [9.58 10.90 12.56 13.41 14.33]
Using MATLAB, I get…
>>
f = fit(x',y','power1')
f =
General model Power1:
f(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 9.384 (8.774, 9.994)
b = 0.2592 (0.206, 0.3125)
Using the same data and a power fit, the a and b coefficients with Excel and JMP are different, however. They both give
a = 9.4293
b = 0.9871
Any idea what might be causing this discrepency?

Best Answer

The Excel coefficients are what you get if you transform
t == a*x^b
using a log transform to get
log(t) == log(a) + b * log(x)
and then do a first degree polynomial fit, remembering to take exp() of the linear term (the second one in the polyfit coefficients) . This is least squared in log of x, but not least squared in x itself.
The coefficients that MATLAB gives are least squared in the original problem domain.
You can do calculus analysis on
r = sum( (a*x^b - t).^2 )
to minimize that by a = 9.38329520500233 b = 0.259283233448218
Related Question