[R] Using "optim" with exponential power distribution

Ronald Bialozyt bialozyt at staff.uni-marburg.de
Fri Jan 16 17:19:42 CET 2009


Hello,

I am trying to fit a exponential power distribution 

y = b/(2*pi*a^2*gamma(2/b))*exp(-(x/a)^b)

to a bunch of data for x and y I have in a table.
> data
           x         y 
1         25        27 
2         75        59 
3        125       219 
...
259    12925         1
260    12975         0

I know "optim" should do a minimisation, therefor I used as the 
optimisation function

opt.power <- function(val, x, y) { 
   a <- val[1]; 
   b <- val[2]; 
   sum(y - b/(2*pi*a^2*gamma(2/b))*exp(-(x/a)^b));
}

I call: (with xm and ym the data from the table)

a1 <- c(0.2, 100)
opt <- optim(a1, opt.power, method="BFGS", x=xm, y=ym)

but no optimisation of the parameter in a1 takes place.
Any ideas?

-- 
Ciao
Ronald




More information about the R-help mailing list