[R] Problem with fitdistr for beta

Agustin Lobo alobo at ija.csic.es
Fri Jul 4 18:16:19 CEST 2003

I have the following problem:

I have a vector x of data (0<x<=1 ) with
a U-shaped histogram and try to fit a beta
distribution using  fitdistr. In fact,
hist(rbeta(100,0.1,0.1)) looks a lot like
my data.

The equivalent to
the example in the manual
sometimes work:

> a <- rbeta(100,0.1,0.1)
> fitdistr(x=a, "beta", start=list(shape1=0.1,shape2=0.1))1)
>      shape1       shape2
  0.09444627   0.12048753
 (0.01120670) (0.01550129)

but sometimes does not:
> a <- rbeta(100,0.1,0.1)
> fitdistr(x=a, "beta", start=list(shape1=0.1,shape2=0.1))1)
> Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) :
        Function cannot be evaluated at initial parameters

Unfortunately, my data fall in the second case

I've searched for any weird value that be present in the
cases in which fitdistr exits with the error message, but
could not find any.

Any help?
(please if anyone answers be sure to answer to my address as well,
I cannot subscribe to the list)



Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo at ija.csic.es

More information about the R-help mailing list