I have some data, and I expect that part of the data will fit to a power law, and part of the data to a line. Here's a made up example of some similar data:

enter image description here

Where I've made the red part a quadratic with some error, and the blue part a line with some error, just for illustration.

Now supposed I don't know where this clear break between the functions is because it was data I just took in. I want to essentially find this point by choosing points throughout the data range, and for each point, suppose that's the "break point", and try fitting a power law to the left of it and a line to the right, and getting the R Squared value for each section, and minimizing the total error.

My question is, if I have the R Squared for each section, what's the best way to minimize the "total error"? Do I want to minimize simply $R_{power}^2 + R_{linear}^2$?

Edit: To clarify, I don't know the actual exponent of the power law, or the slope of the line. I'll be fitting a general power law of the form $ax^b$ and a line $mx+c$ to the two regions (so it's not a matter of just finding the divider between the region for two known functions).

  • $\begingroup$ You could try to instead fit the entire thing to a function on the form $f_{\text{power}}e^{-\alpha x}+f_{\text{linear}}(1-e^{-\alpha x})$, and optimize the value of the parameter $\alpha$. This way, the power-part dies off as $x$ grows, leaving the linear part. This way you dont have to worry about having two different functions. Edit: $x$ is supposed to be whatever the $x$-axis of your plot is. $\endgroup$ – Morten Oct 27 '14 at 15:30
  • $\begingroup$ @Morten, is that actually better? That's introducing stuff into the fitting that shouldn't actually be there, and the two original functions are still basically there, even if they're added... $\endgroup$ – F dot Floss Oct 27 '14 at 15:34
  • $\begingroup$ @F dot Floss, Edit: It doesn't add anything new into the problem beyond what you had already done. Your cutoff-point introduces an additional degree of freedom into the fit, which you have to optimize. They way you propose is basically fitting your function to $f_{\text{power}}s(x)+f_{\text{linear}}(1-s(x))$, where $s(x)$ is a step function which is $s(x)=1$ for $0\le x \le \alpha$, and $s(x)=0$ for $x>\alpha$. $\endgroup$ – Morten Oct 27 '14 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.