Maximum Likelihood Example Update


I wanted to point to a new gist that I have developed to update the Normal Linear Model Maximum Likelihood example that is part of the Optim.jl examples.

I am going over all of my code to make sure it is 0.7.0 compliant by fixing the deprecation warning and other issues.

The public gist is available here:

I guess I could do a PR at Optim.jl correct?

In any event, I hope people find this useful.


Can you maybe clarify what you changed? Does the example in the docs not work, or did you extend it?

“Deprecations” may have been too strong a word, but I needed to add the following:

using ForwardDiff
using LinearAlgebra

numerical_hessian = NLSolversBase.hessian!(func,parameters)

temporary = vars -> Log_Likelihood(x, y, vars[1:nvar], vars[nvar + 1])

numerical_hessian2 = ForwardDiff.hessian(temporary, parameters)

The first block was to add the ForwardDiff and LinearAlgebra packages to make sure people understood that these were not in base.

The second code block was amended to NLSolversBase.hessian! but I’m not sure this is actually needed.

The third block was amended to obtain the Hessian from the ForwardDiff package.

It may be that the only “real” change is to add the calls in the first block, while the others are not necessary.