# How to measure/argue the goodness of fit of a trendline to a power law?

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. 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.
• 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. Oct 1, 2010 at 18:32
• "So you think..." is an excellent reference. Points 1-6 (out of 7) directly address the question posed here.
– whuber
Oct 1, 2010 at 20:45
• 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. Oct 1, 2010 at 21:39
• 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? Oct 2, 2010 at 2:02
• @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 ..
– ars
Oct 2, 2010 at 5:51

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.

• Aaron - that link is dead, could you post a fresh one? Nov 12, 2011 at 17:56
• 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 Apr 17, 2018 at 13:01