#acl DynareWriterGroup:read,write,delete,revert DynareTeamGroup:read,write,delete,revert,admin All:read = Dynare M files = This is the start of a documentation of the Matlab files (M files) that are at the heart of Dynare. Complete documentation will take some time. But we will do our best to add regularly to this page. == M2HTML documentation == M2html is a tool that documents automatically Matlab functions. In particular, it gives easy access to the other functions that call a particular functions and to the functions called by a particular function. [[http://www.dynare.org/dynare-matlab-m2html]] == Starting Dynare processing == Function [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare.html | dynare.m]] * executes Dynare preprocessor {{{dynare_m}}} that creates {{{.m}}}, {{{_static.m}}}, {{{_dynamic.m}}} * executes {{{.m}}} == The estimation block == * Dynare keyword {{{estimation}}} is translated by a call to Matlab function [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_estimation.html | dynare_estimation.m]]. * [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_estimation.html | dynare_estimation.m]] handles recursive estimation over several samples, when option {{{nobs}}} contains several values. * For one sample, estimation is done by [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_estimation_1.html | dynare_estimation_1.m]] * The big parts of [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_estimation_1.html | dynare_estimation_1.m]] are as follows: * initialization and data preparation * computation of maximum likelihood or posterior mode (starts around line 347) * runs MCMC (starts around line 1003) * computes the posterior distributions of various statistics (starts around line 1038) * computes smooth values at the last point estimate of the parameters (maximum likelihood, posterior mode or posterior mean) (starts around line 1052) === The likelihood / posterior function === [[http://www.dynare.org/dynare-matlab-m2html/matlab/DsgeLiklihood.html | DsgeLikelihood.m]] computes the likelihood of the model and if necessary evaluates the priors in order to compute the posterior. The likelihood is computed with the Kalman filter, but the implementation called here keeps only those elements necessary to the computation of the likelihood, for efficiency reasons. A fuller version of the Kalman filter is called by [[http://www.dynare.org/dynare-matlab-m2html/matlab/DsgeSmoother.html | DsgeSmoother.m]]. The main steps are: * initialization of the structural parameters * computation of the solution of the linear rational expectation model by [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_resolve.html | dynare_resolve.m]] * initialization of the Kalman filter * call the appropriate Kalman filter routine: * stationary initialization * multivariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/missing_observations_kalman_filter.html | missing_observations_kalman_filter.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/kalman_filter.html | kalman_filter.m]] * univariate filter * correlated shocks : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/univariat_kalman_filter_corr.html | univariate_kalman_filter_corr.m]] * non-correlated shocks : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/univariat_kalman_filter.html | univariate_kalman_filter.m]] * diffuse initialization * multivariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/missing_observations_diffuse_kalman_filter.html | missing_observations_diffuse_kalman_filter.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/diffuse_kalman_filter.html | diffuse_kalman_filter.m]] * univariate filter * correlated shocks : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/univariat_diffuse_kalman_filter_corr.html | univariate_diffuse_kalman_filter_corr.m]] * non-correlated shocks : [[http://www.dynare.org/dynare-matlab-m2html/matlab/kalman/likelihood/univariat_diffuse_kalman_filter.html | univariate_diffuse_kalman_filter.m]] * evaluation of priors if necessary When the multivariate filter encounters a singularity, Dynare switches automatically to the univariate filter. === The Smoother function === [[http://www.dynare.org/dynare-matlab-m2html/matlab/DsgeSmoother.html | DsgeSmoother.m]] computes the smoother of the model. The smoother is computed by first running the Kalman filter (forward in time), then the smoother (backward in time). The main steps are: * initialization of the structural parameters * computation of the solution of the linear rational expectation model by [[http://www.dynare.org/dynare-matlab-m2html/matlab/dynare_resolve.html | dynare_resolve.m]] * initialization of the Kalman filter * call the appropriate Kalman filter/smoother function (The structure of the smoother routines is different from the filter ones, because we are in the middle of the repackaging this code): * no measurement error * stationary initialization * multivariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/missing_DiffuseKalmanSmoother1.html | missing_DiffuseKalmanSmoother1.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmoother1.html | DiffuseKalmanSmoother1.m]] * univariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/missing_DiffuseKalmanSmoother3.m | missing_DiffuseKalmanSmoother3.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmoother3.m | DiffuseKalmanSmoother3.m]] * diffuse initialization * multivariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/missing_DiffuseKalmanSmoother1_Z.html | missing_DiffuseKalmanSmoother1_Z.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmoother1_Z.html | DiffuseKalmanSmoother1_Z.m]] * univariate filter * missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/missing_DiffuseKalmanSmoother3_Z.m | missing_DiffuseKalmanSmoother3_Z.m]] * no missing observations : [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmoother3_Z.m | DiffuseKalmanSmoother3_Z.m]] * measurement error * stationary initialization * multivariate filter * missing observations : N/A * no missing observations: [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmootherH1.html | DiffuseKalmanSmootherH1corr.m]] * univariate filter * missing observations : N/A * no missing observations * correlated shocks: [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmootherH3corr.html | DiffuseKalmanSmootherH3corr.m]] * correlated shocks: [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmootherH3.html | DiffuseKalmanSmootherH3.m]] * diffuse initialization * multivariate filter * missing observations : N/A * no missing observations: [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmootherH1_Z.html | DiffuseKalmanSmootherH1_Z.m]] * univariate filter * missing observations : N/A * no missing observations * correlated shocks: N/A * no correlated shocks: [[http://www.dynare.org/dynare-matlab-m2html/matlab/DiffuseKalmanSmootherH3_Z.html | DiffuseKalmanSmootherH3_Z.m]]