[R] distribution fitting

Adelchi Azzalini
Thu, 16 Feb 2006 08:24:05 -0000

On Wed, 15 Feb 2006 14:39:53 -0500, Glazko, Galina wrote:

GG> Dear list,
GG>
GG>
GG>
GG> Does anyone know how to fit the power law distribution?
GG>
GG> I have the empirical distribution and would like to check whether
GG> it fits
GG>
GG> the power law (with the power estimated from the data).
GG>


you can you fitdistr() from MASS, as indicated below

notice that the so-called "exponential power" (Subbotin, 1923)
distribution has been used with many different sort of parametrizations;
the form used below is proportional to  exp(-|x|^p/p).

best regards,
Adelchi Azzalini
--
library(MASS)
dep<- function(x,location,scale,tail) # Exponential power (=Subbotin)
{
  const<- 2*tail^(1/tail-1) *gamma(1/tail)
  z<- (x-location)/scale
  exp(-abs(z)^tail/tail)/(scale*const)
}


x <- rt(100,df=3)
a <- fitdistr(x, dep, start=list(location=0, scale=1, tail=1.5))
print(a$estimate)
print(a$sd)

--
Adelchi Azzalini  <azzalini at stat.unipd.it>
Dipart.Scienze Statistiche, Universit?? di Padova, Italia
tel. +39 049 8274147,  http://azzalini.stat.unipd.it/