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:
gistfile1.txt
{
"cells": [
{
"outputs": [],
"cell_type": "markdown",
"source": [
"# Maximum Likelihood Estimation in Julia: The Normal Linear Model\n",
"\n",
"The following tutorial will introduce maximum likelihood estimation in Julia for\n",
"the normal linear model.\n",
This file has been truncated. show original
gistfile2.txt
using Optim
using NLSolversBase
using ForwardDiff
using LinearAlgebra
n = 500 # Number of observations
nvar = 2 # Number of variables
β = ones(nvar) * 3.0 # True coefficients
x = [ones(n) randn(n, nvar - 1)] # X matrix of explanatory variables plus constant
This file has been truncated. show original
gistfile3.txt
```@meta
EditURL = "https://github.com/TRAVIS_REPO_SLUG/blob/master/../../Desktop/Julia SAR Maximum Likelihood/Maximum Likehood Tutorial/maxlikenlm.jl"
```
# Maximum Likelihood Estimation in Julia: The Normal Linear Model
The following tutorial will introduce maximum likelihood estimation in Julia for
the normal linear model.
The normal linear model (sometimes referred to as the OLS model) is the workhorse of
This file has been truncated. show original
There are more than three files. show original
I guess I could do a PR at Optim.jl correct?
In any event, I hope people find this useful.
Thanks!
pkofod
December 7, 2018, 9:09pm
#2
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.
Thanks!