2

I have a sample of data, with the sample size being around 500,000. I am currently trying to fit the sample with power law distribution, using the poweRlaw package in R.

So this is my code to that end:

pl_rg <- conpl$new(a)
estimate_xmin(pl_rg, xmax = 100)

However, there comes the problem when I try to run the code of x<-estimate_xmin(pl_rg,xmax = 100). I found this code was very very time consuming. I have run this code by now for up to 5 hours and it is still running.

So any way to accelerate the process or other ways to fit the power law?

csgillespie
  • 59,189
  • 14
  • 150
  • 185
Burry Xie
  • 85
  • 9
  • Please provide a reproducible example http://stackoverflow.com/help/mcve and for questions wherein you have working code that you'd like to speed up please consider moving your question to http://codereview.stackexchange.com – Hack-R Jul 22 '16 at 01:27

1 Answers1

1

The reason that estimate_xmin is slow is that it is trying every possible value of your data for a potential xmin value. You can significantly speed up the function by specifying values, e.g.

estimate_xmin(pl_rg, xmins = 1:10)

See the help page for further details.

csgillespie
  • 59,189
  • 14
  • 150
  • 185
  • Thanks. but how can I specify the initial values for xmin ? Can I just choose several values according to the probability density function of the data as where the plot starts to be linear in the log-log axis? – Burry Xie Jul 22 '16 at 11:54
  • In the code above you are choosing xmin values using the `xmins` argument. – csgillespie Jul 22 '16 at 15:45