# Linear Regression vs. Nonlinear Least Squares Fit

I am trying to fit Moseley's Law ( $E = \frac{3}{4}R_\infty (Z-\sigma)^2$ ) to a set of data points ($Z,E$) I obtained through an experiment. From this I want to obtain a value for $R_\infty$ and $\sigma$. There are two ways I can do this.

First is a linear regression of the form $\sqrt{E} = \sqrt{\frac{3}{4}R_\infty} Z-\sqrt{\frac{3}{4}R_\infty}\sigma$. From the slope $m$ and intercept $b$ I can calculate $R_\infty$ and $\sigma$ quite easily. I have done this in Excel using LINEST and in MatLab using polyfit(). I obtain the same values in both packages.

The second method is non-linear least squares where I fit my data to $E = \frac{3}{4}R_\infty (Z-\sigma)^2$. I have done this in Excel using Solver and in MatLab using fit(). Once again I obtain the same value for $R_\infty$ and $sigma$ in both packages.

However the problem is that the first and the second methods give me slightly different results. The second method (non-linear least squares) has a lower RSS value which indicates to me that it is a better fit. Why is this the case when in principle both methods are fitting to the same function and therefore should give me the same results?

• Beside what M Turgeon answered, you must take care that what is measured is $E$ and not $\sqrt E$. So, making the model linear to get some good estimates is the right solution as long as you continue with the nonlinear regression. – Claude Leibovici Nov 5 '15 at 11:39

$$\sum_{i=1}^n\left(\sqrt{E_i} - \sqrt{\frac{3}{4}R_\infty} Z_i + \sqrt{\frac{3}{4}R_\infty} \sigma \right)^2,$$
whereas in the second case, you have $$\sum_{i=1}^n\left(E_i - \frac{3}{4}R_\infty( Z_i - \sigma) \right)^2.$$
Therefore, you are minimizing two different criteria (one is linear in $E$, the other is quadratic). There is no reason a priori to except you will get the same answer.