# How to make the Lmaxalgr option automatic

Hi All,

Some time during maximum likelihood estimation, the gauss will pop up a option named "Lmaxalgr" and asks user to select an algorithm from the list to continue the estimation. Is there some way to make this automatic, such that if for some reason the estimation gets stuck, gauss knows internally that it needs to apply certain algorithm.

I am providing a screen shot of the problem discussed above for convenience.

Lmaxalgr = 2

= 1, steepest descent
= 2, BFGS
= 3, DFP
= 4, Newton-Raphson
= 5, BHHH
= 6, PRCG
= 7, scaled BFGS
= 8, scaled DFP

Enter new value:

So basically, at enter the value option, we need to manually enter the number.

0

You can specify the algorithm to switch to with the control variable _max_Switch. Here is the documentation for it:

```_max_Switch 4 × 1 or 4 × 2 vector, controls algorithm switching. If
4 × 1, set its elements in the following way,
max Switch is
1 , algorithm number to switch to
2 , FASTMAX will switch to algorithm in the first element when the
function value is less than the value entered here
3 FASTMAX switches if the number of iterations exceeds the
number entered here
4 FASTMAX switches if line search step changes less than the
amount entered here
If max Switch is 4 × 2, FASTMAX switches between the algorithms in
column 1 and column 2 subject to the conditions specified for the 4 × 1
vector.
Thus if max Switch is a 4 × 1 vector, FASTMAX will switch
algorithms no more than once during the iterations, whereas if it is 4 × 2
it may switch back and forth between the two algorithms throughout the
iterations.
```
0

Thanks a lot. I was going through gauss source files yesterday and came across this as well. However, i do have one last question. What are the default values which gauss uses for row number 2,3 and 4?.

I believe row 3 should not be a problem (we can set some high number).

I tried searching for default values in gauss source files, but no luck so far. Any help is appreciated. In case you find them, please mention the file name as well.

0

I searched around a bit in the code. The default value can be found in the file maxlik.dec. It is also assigned to in the maxset function which resets all the Maxlik control variables to defaults--that is in maxlik.src.

After looking around in the code, it looks like _max_Switch is not set automatically to anything other than a missing value. I found _max_Switch being passed into some internal Maxlik functions. It was passed to _max. Inside of _max the variable is called Lmaxswch. Whenever I saw it referenced it was always inside a block surrounded with:

```if not scalmiss(Lmaxswch);
.
.
.
endif;
```

I couldn't find it assigned to or referenced otherwise. Though if you follow Lmaxswch you may find more than I did.

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.