power law

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

power law

Glazko, Galina
Dear list,

 

Does anyone know how to fit the power law distribution?

I have the empirical distribution and would like to check whether it fits

power law (with the power estimated from the data).

 

Any hints are appreciated

 

Best regards

Galina



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: power law

Gábor Csárdi-2
See the methods here:
http://arxiv.org/abs/cond-mat/0412004
You can simply use the formula given here for continuous data.

Discrete data is a bit more tricky, this is the function I'm using:

# -------------------------------------------------
power.law.fit <- function(x, xmin=NULL, start=2, ...) {

  if (length(x) == 0) {
    error("zero length vector")
  }
  if (length(x) == 1) {
    error("vector should be at least of length two")
  }  

  require(stats4)
                   
  if (is.null(xmin)) { xmin <- min(x) }
                       
  n <- length(x)
  x <- x[ x >= xmin]
  if (length(x) != n) {
    warning("too small values eliminated from vector")
    n <- length(x)
  }
                                         
  mlogl <- function(alpha) {
     C <- 1/sum( (xmin:10000)^-alpha )
     -n*log(C)+alpha*sum(log(x))
  }
             
  alpha <- mle(mlogl, start=list(alpha=start), ...)
               
  alpha
}
# -------------------------------------------------

The function (with is manual page) is also included in the igraph package,
see http://cneurocvs.rmki.kfki.hu/igraph

Hope this helps,
Gabor

On Wed, Feb 15, 2006 at 08:07:50AM -0500, Glazko, Galina wrote:

> Dear list,
>
>  
>
> Does anyone know how to fit the power law distribution?
>
> I have the empirical distribution and would like to check whether it fits
>
> power law (with the power estimated from the data).
>
>  
>
> Any hints are appreciated
>
>  
>
> Best regards
>
> Galina
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

--
Csardi Gabor <[hidden email]>    MTA RMKI, ELTE TTK

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html