Dear All,
I would like to discuss some issues around the best way to include analytic scores and hessian in dsgelikelihood.m
1) extension to all KF routines: Currently, analytic derivations done only for the standard KF (stationary multivariate KF). This is done in a separate routine, however is this a good approach? This would imply that all KF routines will have a replica with analytic derivatives and all changes / bug fixes in the base KF routines will have to be ported to the ones with analytic derivations. So, I would like to consider the possibility to include extra options to all current KF routines with "if" statements triggering the analytic computations. This will have the cost of evaluating and "if" at every recursion in the KF.
2) using analytic derivatives in estimation: using analytic scores and/or hessian in optimization is now an option at hand. In this case, I would like to discuss the issue about the output arguments to dsgelikelihood. Currently the first output if fval, then a full list of output flags and dynare options, and finally we added scores and hessian. In an optimization framework, it would be convenient to have 1st and 2nd derivatives just after fval. I see two options for doing that: a) change the list of output arguments: we have to take care of changing all calls to dsgelikelihood across dynare; b) when analytic derivatives are triggered, the fval output argument becomes a cell array with the following entries: {LIK, SCORES, HESSIAN}. In no analytic derivation is triggered, fval remains as it is now. In this case, nothing will be changed when the standard numerical gradient and hessian are used, but will make calls easier when analytic scores/hessian are used.
what do you think?
best Marco