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

0

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;
mm.function = //compute log-likelihood
endif;

if ind;
mm.gradient = //optionally compute first derivative
endif;

if ind;
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. aptech

1,338

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.

### Try GAUSS for 30 days for FREE

See what GAUSS can do for your data