Reputation: 91
Is there any way that we could get the Hessian matrix (so as to calculate the standard error) after getting the optimization result through scipy.minimize
function?
The parameter of hessian in the minimize function seems to be input instead of an output.
from scipy import minimize
opt = minimize(logitfn, args=df, x0=x_start, method='Nelder-Mead')
Upvotes: 3
Views: 3241
Reputation: 33
Given a function f and initial point x0, and assuming we use L-BFGS-B, then the following code works:
opt = minimize(f, x0=x0, method='L-BFGS-B')
B = opt.hess_inv # LinearOperator object
B = B * np.identity(B.shape[1]) # numpy array
Upvotes: 1