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

0

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

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

• Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

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

• Want to find out more?

Get a real answer from a real person

• Have a Specific Question?

Get a real answer from a real person

• Need Support?
• 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!