Skip to content

power law

2 messages · Glazko, Galina, Gábor Csárdi

5 days later
#
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: