title: fitdistr() warning with dbeta: "In densfun(x, parm[1], parm[2], ...) : NaNs produced"
body: <p>I see the following warnings. Does anyone know why there are such warnings despite the fact that the fit seems to work OK? Is there any way to make the optimization work better so that it will not generate these warnings?</p>
  
  <pre><code>R&gt; library(MASS) 
  R&gt; set.seed(0)
  R&gt; x=rbeta(1000, shape1=1, shape2=1)
  R&gt; fitdistr(x, dbeta, list(shape1=1,shape2=1)) 
       shape1       shape2  
    1.00959537   0.99603351 
   (0.04183720) (0.04116276)
  Warning messages:
  1: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  2: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  R&gt; x=rbeta(1000, shape1=10, shape2=10)
  R&gt; fitdistr(x, dbeta, list(shape1=1,shape2=1)) 
      shape1      shape2  
    8.5038157   8.5794416 
   (0.3749814) (0.3784147)
  </code></pre>