[R] Problem with MASS::fitdistr().

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Mon Apr 27 02:54:43 CEST 2020

I thought about this some more and realized my last suggestion is
unlikely to work.
Another possibility would be to create a new function to compute the
Hessian with a smaller step size, but I suspect there will be more

Possibly a much simpler approach would be to:

Modify the source for fitdistr.
(Copy the source and create a new function, say fitdistr2).

Modify it not compute the Hessian in the optim call.
Then after the optim call, test the parameter estimates.
If they're very close to the boundaries (here zero), then they're
flagged as near-boundary cases and the fitdistr2 function returns the
parameter estimates without the Hessian and related info.
(Possibly generating a warning).

If they're sufficiently distant, the Hessian and related info can be
computed in separate steps and returned.
(Equivalent to what it does currently).

I note that there's at least one R package (numDeriv), and maybe more,
for computing the Hessian, numerically.

On Mon, Apr 27, 2020 at 9:31 AM Abby Spurdle <spurdle.a using gmail.com> wrote:
> > Dear Ms. Spurdle
> I usually refer to myself as "He".
> (But then, that's not the whole story...)
> I'm not an expert on maximum likelihood approaches.
> So, I apologize if the following suggestion is a poor one.
> Does your likelihood function have a limit, as alpha approaches zero (say zero)?
> If so, the limit of the log-likelihood would be -Inf, would it not.
> You could create a function representing the likelihood or
> log-likelihood by wrapping your density function.
> The function could allow alpha/beta values equal to or below zero, and
> return the limit.
> This is mathematically incorrect, but may be sufficient for
> permissible estimates of the second-order partial derivatives.
> Depending on the shape of the likelihood function these
> pseudo-likelihoods maybe able to be improved...?
> You could then do a small modification on the source code for
> MASS::fitdistr, such that the user specifies the likelihood function
> or log-likelihood function, rather than the density...
> The fitdistr function is relatively complex, however, you would only
> need to modify a couple of lines, the lines that create the fn
> function...

More information about the R-help mailing list