title: Errors while trying to fit gamma distribution with R fitdistr{MASS}
body: <p>I have a problem with fitdistr{MASS} function in R. I have this vector:</p>
  
  <pre><code>a &lt;- c(26,73,84,115,123,132,159,207,240,241,254,268,272,282,300,302,329,346,359,367,375,378, 384,452,475,495,503,531,543,563,594,609,671,687,691,716,757,821,829,885,893,968,1053,1081,1083,1150,1205,1262,1270,1351,1385,1498,1546,1565,1635,1671,1706,1820,1829,1855,1873,1914,2030,2066,2240,2413,2421,2521,2586,2727,2797,2850,2989,3110,3166,3383,3443,3512,3515,3531,4068,4527,5006,5065,5481,6046,7003,7245,7477,8738,9197,16370,17605,25318,58524)
  </code></pre>
  
  <p>and I want to fit a gamma distribution to the data with a command:</p>
  
  <pre><code>fitted.gamma &lt;- fitdistr(a, "gamma")
  </code></pre>
  
  <p>but I have such error:</p>
  
  <pre><code>Error in optim(x = c(26, 73, 84, 115, 123, 132, 159, 207, 240, 241, 254,  : 
  non-finite finite-difference value [1]
  In addition: Warning messages:
  1: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  2: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  3: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  4: In densfun(x, parm[1], parm[2], ...) : NaNs produced
  </code></pre>
  
  <p>So I tried with initializing the parameters:</p>
  
  <pre><code>(fitted.gamma &lt;- fitdistr(a, "gamma", start=list(1,1)))
  </code></pre>
  
  <p>The object fitted.gamma is created but when printed, creates an error:</p>
  
  <pre><code>Error in dn[[2L]] : subscript out of bounds
  </code></pre>
  
  <p>Do you know what is happening or maybe know some other R functions to fit univariate distributions by MLE?</p>
  
  <p>Thanks in advance for any help or response.</p>
  
  <p>Kuba</p>