It is a pity that I can not throw off a fully reproducible problem code, because I use a specific large vector. But in principle, the problem is already pretty clear. I'm trying to find the parameters of the beta distribution using the function mle :
params <- mle(nll, start = list(alpha = 0.1, beta = 10), method = "L-BFGS-B") Where nll is a function for negative log likelihood. The documentation for the mle function says that start is the initial value from which it starts approximating.
After going through several options, my 0.1 and 10 came up to me. But now I'm trying to bring different parts of the same vector closer to a certain factor and the same parameters are no longer suitable. On some parts I get this error:
Error in optim(start, f, method = method, hessian = TRUE, ...) : L-BFGS-B needs finite values of 'fn' In addition: Warning messages: 1: In lbeta(shape1[okk] + x[okk], shape2[okk] + size[okk] - x[okk]) : NaNs produced 2: In lbeta(shape1[okk], shape2[okk]) : NaNs produced On the Internet, I stumbled upon a good idea to begin an approximation from the values obtained by the method of moments . So I replaced my 0.1 and 10 with these formulas, but I get the same error.
Do you know any way to set exactly the appropriate initial values for approximating the beta distribution with the function mle ?
Thank you very much in advance!