### 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.

### 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 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 panel data PQG graphics procs random numbers strings structures threading### Recent Questions

- How to identify the break date for Hatemi-J cointegration test
- error G0152 : Variable not initialized stack trace:
- 'selif' does not work for strings
- Some parts of the screen show very small fonts
- Integration over an interval
- CKLS 1992 Gauss Code with Structural Breaks?
- plotSetXRange is not working
- Gauss Mac Installation
- Can i get MaxLik Packge for Mac OS
- How to run Narayan and Popp (2010) unit root test with two structural break

### 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

# How do I set the 'ind' input to my objective function with COMT

I’m trying to write an objective function when using COMT. The inputs to my function are supposed to be like this:

proc fct(struct PV p, struct DS d, ind)

My question is how to assign value to the third inputs ‘ind’. Is it through comtControl?

Thanks.

## 1 Answer

The way that COMT and the other GAUSS optimization packages work is that the main GAUSS procedure, in this case `comt`, calls your objective function. You will not call it directly.

The third input to your objective function for COMT is an indicator vector, `ind`. You do not ever set this input. This indicator vector is a way for COMT to tell you what it wants you to compute.

If the first element of `ind` is nonzero, COMT needs you to compute the value of your objective function at the parameter values that it passes in. If the second element of `ind` is nonzero, then COMT would like you to calculate the gradient. If the third element of `ind` is nonzero, then COMT would like you to calculate the hessian. For example:

proc (1) = logLik(struct PV p, struct DS d, ind); struct modelResults mm; if ind[1]; mm.function = //compute log-likelihood endif; if ind[2]; mm.gradient = //optionally compute first derivative endif; if ind[3]; mm.hessian = //optionally computer second derivative endif; retp(mm); endp;

Your problem will converge more quickly and with higher accuracy if you can supply code to compute the first and second derivative of your function. However, it is not required. If you do not calculate the derivatives when indicated by the `ind` input, COMT will simply calculate them numerically.

I think this explanation will answer your question, but you should also take a look at the section discussing the `ind` input to the likelihood function in chapter 3 of the COMT manual.

## Your Answer

## 1 Answer

The way that COMT and the other GAUSS optimization packages work is that the main GAUSS procedure, in this case `comt`, calls your objective function. You will not call it directly.

The third input to your objective function for COMT is an indicator vector, `ind`. You do not ever set this input. This indicator vector is a way for COMT to tell you what it wants you to compute.

If the first element of `ind` is nonzero, COMT needs you to compute the value of your objective function at the parameter values that it passes in. If the second element of `ind` is nonzero, then COMT would like you to calculate the gradient. If the third element of `ind` is nonzero, then COMT would like you to calculate the hessian. For example:

proc (1) = logLik(struct PV p, struct DS d, ind); struct modelResults mm; if ind[1]; mm.function = //compute log-likelihood endif; if ind[2]; mm.gradient = //optionally compute first derivative endif; if ind[3]; mm.hessian = //optionally computer second derivative endif; retp(mm); endp;

Your problem will converge more quickly and with higher accuracy if you can supply code to compute the first and second derivative of your function. However, it is not required. If you do not calculate the derivatives when indicated by the `ind` input, COMT will simply calculate them numerically.

I think this explanation will answer your question, but you should also take a look at the section discussing the `ind` input to the likelihood function in chapter 3 of the COMT manual.