### Aptech Systems, Inc. Worldwide Headquarters

Address:

Aptech Systems, Inc.

2350 East Germann Road, Suite #21

Chandler, AZ 85286Phone: 360.886.7100

FAX: 360.886.8922**Ready to Get Started?**### Request Quote & Product Information

### Industry Solutions

### Products

### Resources

### Support

### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

### What’s New in GAUSS 17

### Want to find out more?

### Have a Specific Question?

### Q&A: Register and Login

### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!

### Where to Buy

Available across the globe, you can have access to GAUSS no matter where you are.

### Recent Tags

applications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall econometrics Editor error error codes error handling errors Excel file i/o floating network GAUSS Engine GAUSS Light graphics GUI hotkeys installation license licensing linux loading data loop loops matrix manipulation Maximum Likelihood Maxlik MaxLikMT Memory multidimensional array optimization Optmum output PQG graphics procs random numbers strings structures threading### Recent Questions

### Features

### Time Series 2.0 MT

### Industry Solutions

### Find out more now

### Time Series MT 2.1

### Find out more now

### Find out more now

# Resources

# Constrained optmization numerical hessian

Dear All,

I'm using constrained optimization and want to compute a numerical hessian. Did somebody already do this and can maybe point me to some resources or give useful hints. I already tried using CML, which provides a hessia, but the LLF is unfortunately not straightforward (compared to the M-Estimation) and I would need to specify a distribution which I'm not really comfortable with.

best

Oldes

## 4 Answers

There are several functions in the GAUSS Run-Time Library for computing Hessians. If you are using CO, use hessp(&f,x0) to compute your hessian where &f is the pointer to the function used in your call to CO, and the second argument is the vector of parameter estimates returned by CO. For example,

{ x,fmin,g,retcode } = co(&f,x0);

h = hessp(&f,x);

If you are using COMT, then use hessmt(&f,par,data) where &f is again the pointer to the function used in your call to COMT, par is a PV structure containing the parameter estimates returned by COMT, and data is a DS structure containing any data used by your objective function procedure. For example,

struct comtResults out;

out = comt(&f,par,d0,c0);

h = hessmt(&f,out.par,d0);

Be advised that if any of your parameters are on a constraint boundary, then the inverse of the Hessian is not the correct covariance matrix of the parameters. The correct "approximate" covariance matrix calculation is described in the CMLMT Manual in Section 2.9.1. This covariance matrix is itself not completely correct and for that reason is called approximate. The correct procedure for models with constrained parameters is hypothesis testing. The method is described in Section 2.9.3 of the CMLMT Manual. Functions for the calculations of the test of the hypothesis can be found in the file hypotest.src in the Run-Time Library. Instructions for the calculations can be found at the top of that file.

Do I see correctly, that the hessian is already multiplied by -1, and therefore it is the inverse that is the variance-covariance matrix and not the negative of the inverse?

If your objective function is a log-likelihood then you are minimizing -logl and thus the Hessian is already multiplied by -1 and its inverse is the variance-covariance matrix.

## Your Answer

## 4 Answers

There are several functions in the GAUSS Run-Time Library for computing Hessians. If you are using CO, use hessp(&f,x0) to compute your hessian where &f is the pointer to the function used in your call to CO, and the second argument is the vector of parameter estimates returned by CO. For example,

{ x,fmin,g,retcode } = co(&f,x0);

h = hessp(&f,x);

If you are using COMT, then use hessmt(&f,par,data) where &f is again the pointer to the function used in your call to COMT, par is a PV structure containing the parameter estimates returned by COMT, and data is a DS structure containing any data used by your objective function procedure. For example,

struct comtResults out;

out = comt(&f,par,d0,c0);

h = hessmt(&f,out.par,d0);

Be advised that if any of your parameters are on a constraint boundary, then the inverse of the Hessian is not the correct covariance matrix of the parameters. The correct "approximate" covariance matrix calculation is described in the CMLMT Manual in Section 2.9.1. This covariance matrix is itself not completely correct and for that reason is called approximate. The correct procedure for models with constrained parameters is hypothesis testing. The method is described in Section 2.9.3 of the CMLMT Manual. Functions for the calculations of the test of the hypothesis can be found in the file hypotest.src in the Run-Time Library. Instructions for the calculations can be found at the top of that file.

Do I see correctly, that the hessian is already multiplied by -1, and therefore it is the inverse that is the variance-covariance matrix and not the negative of the inverse?

If your objective function is a log-likelihood then you are minimizing -logl and thus the Hessian is already multiplied by -1 and its inverse is the variance-covariance matrix.