22
$\begingroup$

I have some data to which I am trying to fit a trendline. I believe the data to follow a power law, and so have plotted the data on log-log axes looking for a straight line. This has resulted in an (almost) straight line and so in Excel I have added a trendline for a power law. Being a stats newb, my question is, what is now the best way for me to go from "well the line looks like it fits pretty well" to "numeric property $x$ proves that this graph is fitted appropriately by a power law"?

In Excel I can get an r-squared value, though given my limited knowledge of statistics, I don't even know whether this is actually appropriate under my specific circumstances. I have included an image below showing the plot of the data I am working with in Excel. I have a little bit of experience with R, so if my analysis is being limited by my tools, I am open to suggestions on how to go about improving it using R.

alt text

$\endgroup$
1

2 Answers 2

26
$\begingroup$

See Aaron Clauset's page:

which has links to code for fitting power laws (Matlab, R, Python, C++) as well as a paper by Clauset and Shalizi you should read first.

You might want to read Clauset's and Shalizi's blogs posts on the paper first:

A summary of the last link could be:

  • Lots of distributions give you straight-ish lines on a log-log plot.

  • Abusing linear regression makes the baby Gauss cry.
    Fitting a line to your log-log plot by least squares is a bad idea.

  • Use maximum likelihood to estimate the scaling exponent.
  • Use goodness of fit to estimate where the scaling region begins.
  • Use a goodness-of-fit test to check goodness of fit.
  • Use Vuong's test to check alternatives, and be prepared for disappointment.
$\endgroup$
5
  • 1
    $\begingroup$ I second this. There are many examples of something that looked like a power law, but when examined a little more rigorously turned out not to be....and no, the high R^2 on the chart is not enough. $\endgroup$
    – PeterR
    Oct 1, 2010 at 18:32
  • $\begingroup$ "So you think..." is an excellent reference. Points 1-6 (out of 7) directly address the question posed here. $\endgroup$
    – whuber
    Oct 1, 2010 at 20:45
  • $\begingroup$ But a power-law distribution isn't the same thing as fitting a power law relationship between two separate variables. I'd assumed the question was about the latter, though i'm not certain. $\endgroup$
    – onestop
    Oct 1, 2010 at 21:39
  • $\begingroup$ Non-expert's question: apart from "robustness", are there other reasons why one should check goodness-of-fit with Kolmogorov-Smirnov instead of $\chi^2$ in this case? $\endgroup$ Oct 2, 2010 at 2:02
  • 2
    $\begingroup$ @J.M.: not really, chi-square is sensitive to binning and tail fluctuations complicate that. I think even with the KS, they reweigh the statistic for extremal points, and there's some discussion of other tests. @onestop: I assumed the other way, and on re-reading, you could be right. I'm not really sure .. $\endgroup$
    – ars
    Oct 2, 2010 at 5:51
3
$\begingroup$

If you're interested in bivariate power-law functions (as opposed to univariate power-law distributions), then

Warton et al. "Bivariate line-fitting methods for allometry." Biol. Rev. 81, 259-201 (2006)

is an excellent reference. In this case, regression is the right thing to do, although there can be some corrections (OLS vs. RMA, etc.) depending on what you want the results of the regression to mean.

$\endgroup$
2
  • $\begingroup$ Aaron - that link is dead, could you post a fresh one? $\endgroup$
    – keflavich
    Nov 12, 2011 at 17:56
  • $\begingroup$ Thanks for this. Most information is for univariate distributions which tends to bury information about bivariate relationships... Here is a link to the Riley listing onlinelibrary.wiley.com/doi/abs/10.1017/S1464793106007007 $\endgroup$
    – songololo
    Apr 17, 2018 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.