# Maximum Likelihood Example Update

**URL:** <https://discourse.julialang.org/t/maximum-likelihood-example-update/18436>\
**Category:** Optimization (Mathematical)\
**Created:** [December 7, 2018, 8:43pm UTC](https://discourse.julialang.org/t/maximum-likelihood-example-update/18436 "2018-12-07T20:43:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Donald\_Lacombe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/donald_lacombe/32/13500_2.png) [@Donald\_Lacombe](https://discourse.julialang.org/u/Donald_Lacombe)\
**Post date:** [December 7, 2018, 8:43pm UTC](https://discourse.julialang.org/t/maximum-likelihood-example-update/18436/1 "2018-12-07T20:43:26Z")

</div>

Hello!

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:

> <https://gist.github.com/djlacombe/a0d3070ddfc408c9b39cbcbbb07984c3>

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

In any event, I hope people find this useful.

Thanks!

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [December 7, 2018, 9:09pm UTC](https://discourse.julialang.org/t/maximum-likelihood-example-update/18436/2 "2018-12-07T21:09:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Donald\_Lacombe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/donald_lacombe/32/13500_2.png) [@Donald\_Lacombe](https://discourse.julialang.org/u/Donald_Lacombe)\
**Post date:** [December 7, 2018, 9:36pm UTC](https://discourse.julialang.org/t/maximum-likelihood-example-update/18436/3 "2018-12-07T21:36:25Z")

</div>

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

```julia
using ForwardDiff
using LinearAlgebra

```

```julia
numerical_hessian = NLSolversBase.hessian!(func,parameters)

```

```julia
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.

Thanks!
