R fit gamma distributions using fitdist gives warnings and is different from fitdistr

73 views Asked by At

I am using fitdist () from fitdistrplus package to fit gamma distributions. Most of the data are fitted fine, but I get a warning for one group of data like below. It seems to be related to NaN produced in Std. Error. Also, I found different results produced using fitdistr from MASS.

fit.gamma = fitdist(data, 'gamma')

Warning messages:
1: In sqrt(diag(varcovar)) : NaNs produced
2: In sqrt(1/diag(V)) : NaNs produced
3: In cov2cor(varcovar) :
  diag(.) had 0 or NA entries; non-finite result is doubtful

#estimates
> fit.gamma
Fitting of the distribution ' gamma ' by maximum likelihood 
Parameters:
         estimate Std. Error
shape    818.3582        NaN
rate  528503.7582        NaN

#different results produced using fitdistr from MASS
      shape         rate    
     820.7819   530073.2864 
 (   121.4543) ( 78460.8728)

The sample data from dput() is

c(0.00163517802885779, 0.00160283775056125, 0.00148355878584797, 0.00156397046432363, 
0.00162024854828131, 0.00156768768420791, 0.00158063023100016, 0.00156508718537038, 
0.00158003450240634, 0.00153358763566883, 0.00161065493852838, 0.00149028640335203, 
0.00162802968564173, 0.00156671606699238, 0.00154716199638081, 0.00153821195940563, 
0.00162198744285207, 0.00164083522311704, 0.00160865087968146, 0.00144217049528351, 
0.00153505545581709, 0.00151854732860282, 0.00157043155113409, 0.00162826610639283, 
0.00148190133362775, 0.00159462274874306, 0.00156724510802065, 0.0015398433747737, 
0.00143860062975494, 0.00150409532005301, 0.00153848336893089, 0.00151664158431484, 
0.00158084694063614, 0.00154878376860822, 0.00144337583756375, 0.00154777476470974, 
0.00160737367968485, 0.00149589176429248, 0.00151175669790827, 0.00152465054164807, 
0.00144735761146658, 0.0015726344621995, 0.00155360393089093, 0.00156793539059828, 
0.00162794136974673, 0.00158943155328826, 0.0016170212947375, 0.00162497885156522, 
0.00148874480354704, 0.00153209305693994, 0.00152311018565133, 0.00151099524254965, 
0.00157917892375966, 0.00154874669553882, 0.00154939184680954, 0.00153031019277051, 
0.00162243261815283, 0.00157590294470343, 0.00148554642291284, 0.00153540799890674, 
0.00154243522592646, 0.00160275040086466, 0.00157940839557194, 0.00156961922875331, 
0.00155304074589656, 0.00152928212568257, 0.00159290538926061, 0.00155801215578425, 
0.00155369439113824, 0.00145084623308752, 0.00155089000592941, 0.00155886786525376, 
0.00148652203536432, 0.0015927863907019, 0.00151196015173343, 0.0015821024463818, 
0.00160081599038558, 0.00156313209340047, 0.00163608907687576, 0.00153841239422154, 
0.0014710592012673, 0.00159246516016538, 0.00152258152415454, 0.00162132418508525, 
0.00140478594523462, 0.00151683262604363, 0.0016052558226825, 0.00147646957382916, 
0.0015132984105642, 0.00146861128575331, 0.00153106862171981, 0.00155880526046832, 
0.001550953370886, 0.00158975519781942, 0.00142012723811699, 0.00155218402168674, 
0.00156750756220327, 0.0015045948435867, 0.00159416372305572, 0.0014232058948302)

Also, here are the plots for the fitted gamma distribution.

enter image description here

I wonder what the warning actually means and why the results are different from those produced using fitdistr.

0

There are 0 answers