Something additional has come up with this example. I’m trying to solve it with other methods (BFGS and Newton) just to check if I get the same values. It is not working with the BFGS method.
If I do this:
result_BFGS = optimize(b -> loglik1(AGE, HDOM, b), inits1, BFGS(), Optim.Options(iterations=1000000))
It gets solved but the minimum value is 1024.27 instead of 35.08.
If I use AD, I get an error related to the dimensions.
func_once = OnceDifferentiable(b -> loglik1(AGE, HDOM, b), inits1; autodiff=:forward);
result_once = optimize(func_once, inits1, BFGS())
I get this warning:
Warning: First function call produced NaNs. Exiting. Double check that none of the initial conditions, parameters, or timespan values are NaN.
DimensionMismatch(“arrays could not be broadcast to a common size; got a dimension with lengths 50 and 450”)
Remember 50 was the size of the vector of initial values, and 450 is what we get if we multiply the ages for which this was solved (9) by 50.
I don’t have this problem with Newton.I get the same value as with the Nelder-Mead method:
func_twice = TwiceDifferentiable(b -> loglik1(AGE, HDOM, b), inits1; autodiff=:forward);
@time result_twice = optimize(func_twice, inits1, Newton())
Why can’t I get it to work with BFGS?