I have a dataframe with x-y values representing values and their counts, e.g. (1, 1000), (2, 100), (3, 10), etc. I would like to fit a power law to this distribution using MLE.
I could use the power.law.fit or poweRlaw libraries, but it appears that these libraries take in specific samples for data instead of x-y values representing values and their counts.
Is there any other library that might do the job? Thanks!
You can use the poweRlaw
package - it's just a bit clunky. Simply expand your values and counts into a single vector, e.g.
dd = data.frame(x=1:3, counts = 3:1)
x = rep(dd$x, dd$counts)
library(poweRlaw)
m = displ$new(x)