[R] Optim()

R. Michael Weylandt michael.weylandt at gmail.com
Sat Sep 29 14:57:34 CEST 2012


On Sat, Sep 29, 2012 at 8:17 AM, wasss <deichkinds at gmx.net> wrote:
> Hello,
> I have some problems regarding the function optim. In my simulations I
> generate negative binomial data and get estimates of the parameter  using
> the likelihood and the package optim. At some point there appears the
> warning:
>
> -  non-finite finite-difference value []
>
> I think it occurs, when the shape converges ->0 (no overdispersion). Is
> there an explanation for this and how do I handle it, because the
> simulations stops in this step.
>

Two possibilities:

1) Use the try-catch mechanisms to handle that one error at the
appropriate error in a way that lets the simulation continue.
2) Fix your objective function so it won't throw NaNs.

More help offered with a reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Cheers,

Michael

>
> Thanks
> wasss
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Optim-tp4644581.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list