[R] Error when using fitdist function in R

Paul Bernal paulbernal07 at gmail.com
Wed Apr 10 15:04:34 CEST 2013


Dear PIKAL,

Thank you for your kind reply. The function fitdist comes from package
fitdistrplus. I am attaching a .csv document that contains the data I want
to fit a distribution to, so you can have a good idea of what kind of data
I am dealing with.

Basically what str(k) contains is the information that appears in the
column Toll in the .csv document I am attaching. I will also show you the
result of str(k), for your reference:

 int [1:499] 363328 376216 367032 314826 311892 313340 367106 227742 386744
372002 ...

Hope this helps explain my situation better,

Best regards,

Paul

2013/4/10 PIKAL Petr <petr.pikal at precheza.cz>

> Hi
>
> where is function fitdist from? Do you by chance mean fitdistr from MASS
> package?
> What is result of str(k)?
>
> Without these questions answered you hardly get any useful answer.
>
> Regards
> Petr
>
>
>
> > -----Original Message-----
> > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > project.org] On Behalf Of Paul Bernal
> > Sent: Tuesday, April 09, 2013 11:19 PM
> > To: r-help at r-project.org
> > Subject: [R] Error when using fitdist function in R
> >
> > Hello everyone,
> >
> > I  was trying to do some distribution fitting with a numerical field
> > called Tolls. The sample size = 999 rows.
> >
> > Basically I assigned the Toll data to a new variable K by doing:
> > k<-dtest$Toll
> >
> > After that, tried to fit a gamma distribution by doing: fitG<-
> > fitdist(k,
> > "gamma")
> >
> > Then the following messages showed (oh and I checked for empty rows
> > before doing this):
> >
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L,
> > 313340L,  :
> >   NaNs produced
> > [1] "Error in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs =
> > data,  : \n  non-finite finite-difference value [2]\n"
> > attr(,"class")
> > [1] "try-error"
> > attr(,"condition")
> > <simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs
> > =
> > data,     ddistnam = ddistname, hessian = TRUE, method = meth, lower =
> > lower,     upper = upper, ...): non-finite finite-difference value [2]>
> > Error in fitdist(k, "gamma") :
> >   the function mle failed to estimate the parameters,
> >                 with the error code 100
> > >
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-<http://www.r-project.org/posting->
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


More information about the R-help mailing list