rtmb

What is this outermgc message while optimising with TMB?


After producing the objective function and gradient with TMB, and calling the optim function, I get a sequence of reports printed in my console that seems to of the form "outer mgc: ":

outer mgc:  56.54273 
outer mgc:  56.51064 
outer mgc:  56.96065 
outer mgc:  57.13384 
outer mgc:  29.01959 
outer mgc:  27.08267 
outer mgc:  25.99866 
outer mgc:  25.79068 
outer mgc:  25.58621 
outer mgc:  21.91722 
outer mgc:  21.73952 
outer mgc:  21.56449 
outer mgc:  21.52924 
outer mgc:  21.52189 
outer mgc:  21.19551 
outer mgc:  20.7331 
outer mgc:  16.39087 
outer mgc:  11.35111 
outer mgc:  10.61466 
outer mgc:  6.748524 
outer mgc:  1.420802 
outer mgc:  0.1197647 

It seems that smaller numbers indicate quicker convergence and better convergence results. But I am not entirely sure what these are so it would be nice to know in order to diagnose the convergence properties of the algorithm.


Solution

  • The abbreviation mgc stands for "maximum gradient component".

    For each parameter TMB estimates a gradient (partial derivative), which after optimisation you can get by running obj$gr(opt$par). All of these should be as close to zero as possible. So for the model to be ok, the highest or maximum one (furthest away from zero) should still be low. You'll notice that when using sdreport(), the final maximum gradient component is also given. These gradients are by default also calculated and printed (unless silent=TRUE in makeADfun) for each iteration when using nlminb/optim.