Proposed specification for estimation functions

This includes factorization of common code and extensions for (unexpected) structural change

Estimated parameters description

xparam1 is a column n by 1 vector holding the current values of the estimated parameters (n is the number of parameters).

parameters_description is a (global?) strucure of arrays describing the estimated parameters with the following fields:

Remark 1. The considered subsamples for different parameters may be different.

Remark 2. StartPeriod and EndPeriod specify the closed sub sample used to estimate the parameter. If these two fields are empty the parameter is estimated using the whole sample.

Remark 3. The field Prior is empty if the model is estimated by maximum lilkelihood, simulated moments or indirect inference.

Remark 4. xxx_id vectors select subset of xparam1 (for instance, xparam_1(np_id) selects all the lines of xparam1 corresponding to the estimated "deep" parameters).

Functions

Additional Description Notes

Parameters and Sub-Samples

The initialization of estimation must detect the set of sub-samples where all parameters remain constant (such that max(StartPeriod)< t < min(EndPeriod) for the sub-sample) and make a table of which parameter is active in which subsample. For this, we need an additional component to the structure describing the parameters.

There is a prior for each sub-sample where the parameter remains constant. These sub-samples can be the union of several elementary sub-sampels defined as above.

Kalman

As change in parameters is not expected by the agents, the solution is very simple, we simply change the values of the system matrices in the Kalman filter within each sub-sample.

However, it would be too complicated to write a Kalman filter routine with changing matrices, so we prefer repeat the basic steps of the current implementation of DsgeLikelihood for each sub-sample during which all parameters remain unchanged.

The consistency of the transition from one sub-period to the next is insured by the proper initialization of initial state (a0) and initial covariance matrix (P0), that are taken from the last value of the previous sub-sample.

Likelihood Calculation

The likelihood (posterior) for the entire sample is simply computed as the sum of the likelihood for each sub-sample (weighted for the length of the sub-sample?).

From an estimation point of view, the changing parameters are treated as different parameters, so in the prior, constant parameters count for one, and each different values of a parameter count each for one as well.

Therefore, the value of log prior is not computed in the loop but only once at the end of DsgeLikelihood for all parameters.

Because we compute the likelihood (posterior) for the entire sample, introducing changing parameters doesn't modify the way the optimizers or the MCMC procedures calls DsgeLikelihood.

See also:

C++ Estimation and DsgeLikelihood Design