| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Provided that you have observations on some endogenous variables, it is possible to use Dynare to estimate some or all parameters. Both maximum likelihood (as in Ireland (2004)) and Bayesian techniques (as in Rabanal and Rubio-Ramirez (2003), Schorfheide (2000) or Smets and Wouters (2003)) are available. Using Bayesian methods, it is possible to estimate DSGE models, VAR models, or a combination of the two techniques called DSGE-VAR.
Note that in order to avoid stochastic singularity, you must have at least as many shocks or measurement errors in your model as you have observed variables.
The estimation using a first order approximation can benefit from the block decomposition of the model (see block).
Description
This command lists the name of observed endogenous variables for the estimation procedure. These variables must be available in the data file (see estimation_cmd).
Alternatively, this command is also used in conjunction with the
partial_information option of stoch_simul, for declaring
the set of observed variables when solving the model under partial
information.
Only one instance of varobs is allowed in a model file. If one
needs to declare observed variables in a loop, the macroprocessor can
be used as shown in the second example below.
Simple example
varobs C y rr; |
Example with a loop
varobs
@#for co in countries
GDP_@{co}
@#endfor
;
|
Description
This block specifies linear trends for observed variables as functions of model parameters.
Each line inside of the block should be of the form:
VARIABLE_NAME(EXPRESSION); |
In most cases, variables shouldn’t be centered when
observation_trends is used.
Example
observation_trends; Y (eta); P (mu/eta); end; |
Description
This block lists all parameters to be estimated and specifies bounds and priors as necessary.
Each line corresponds to an estimated parameter.
In a maximum likelihood estimation, each line follows this syntax:
stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME , INITIAL_VALUE [, LOWER_BOUND, UPPER_BOUND ]; |
In a Bayesian estimation, each line follows this syntax:
stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME | DSGE_PRIOR_WEIGHT [, INITIAL_VALUE [, LOWER_BOUND, UPPER_BOUND]], PRIOR_SHAPE, PRIOR_MEAN, PRIOR_STANDARD_ERROR [, PRIOR_3RD_PARAMETER [, PRIOR_4TH_PARAMETER [, SCALE_PARAMETER ] ] ]; |
The first part of the line consists of one of the three following alternatives:
stderr VARIABLE_NAMEIndicates that the standard error of the exogenous variable VARIABLE_NAME, or of the observation error associated with endogenous observed variable VARIABLE_NAME, is to be estimated
corr VARIABLE_NAME1, VARIABLE_NAME2Indicates that the correlation between the exogenous variables VARIABLE_NAME1 and VARIABLE_NAME2, or the correlation of the observation errors associated with endogenous observed variables VARIABLE_NAME1 and VARIABLE_NAME2, is to be estimated
PARAMETER_NAMEThe name of a model parameter to be estimated
DSGE_PRIOR_WEIGHT…
The rest of the line consists of the following fields, some of them being optional:
INITIAL_VALUESpecifies a starting value for maximum likelihood estimation
LOWER_BOUNDSpecifies a lower bound for the parameter value in maximum likelihood estimation
UPPER_BOUNDSpecifies an upper bound for the parameter value in maximum likelihood estimation
PRIOR_SHAPEA keyword specifying the shape of the prior density.
The possible values are: beta_pdf,
gamma_pdf, normal_pdf,
uniform_pdf, inv_gamma_pdf,
inv_gamma1_pdf, inv_gamma2_pdf. Note
that inv_gamma_pdf is equivalent to
inv_gamma1_pdf
PRIOR_MEANThe mean of the prior distribution
PRIOR_STANDARD_ERRORThe standard error of the prior distribution
PRIOR_3RD_PARAMETERA third parameter of the prior used for generalized beta distribution,
generalized gamma and for the uniform distribution. Default: 0
PRIOR_4TH_PARAMETERA fourth parameter of the prior used for generalized beta distribution
and for the uniform distribution. Default: 1
SCALE_PARAMETERThe scale parameter to be used for the jump distribution of the Metropolis-Hasting algorithm
Note that INITIAL_VALUE, LOWER_BOUND, UPPER_BOUND, PRIOR_MEAN, PRIOR_STANDARD_ERROR, PRIOR_3RD_PARAMETER, PRIOR_4TH_PARAMETER and SCALE_PARAMETER can be any valid EXPRESSION. Some of them can be empty, in which Dynare will select a default value depending on the context and the prior shape.
As one uses options more towards the end of the list, all previous options must be filled: for example, if you want to specify SCALE_PARAMETER, you must specify PRIOR_3RD_PARAMETER and PRIOR_4TH_PARAMETER. Use empty values, if these parameters don’t apply.
Example
The following line:
corr eps_1, eps_2, 0.5, , , beta_pdf, 0, 0.3, -1, 1; |
sets a generalized beta prior for the correlation between eps_1 and
eps_2 with mean 0 and variance 0.3. By setting
PRIOR_3RD_PARAMETER to -1 and PRIOR_4TH_PARAMETER to 1 the
standard beta distribution with support [0,1] is changed to a
generalized beta with support [-1,1]. Note that LOWER_BOUND and
UPPER_BOUND are left empty and thus default to -1 and 1,
respectively. The initial value is set to 0.5.
Similarly, the following line:
corr eps_1, eps_2, 0.5, -0.5, 1, beta_pdf, 0, 0.3, -1, 1; |
sets the same generalized beta distribution as before, but now truncates this distribution to [-0.5,1] through the use of LOWER_BOUND and UPPER_BOUND. Hence, the prior does not integrate to 1 anymore.
Parameter transformation
Sometimes, it is desirable to estimate a transformation of a parameter appearing in the model, rather than the parameter itself. It is of course possible to replace the original parameter by a function of the estimated parameter everywhere is the model, but it is often unpractical.
In such a case, it is possible to declare the parameter to be estimated
in the parameters statement and to define the transformation,
using a pound sign (#) expression (see section Model declaration).
Example
parameters bet; model; # sig = 1/bet; c = sig*c(+1)*mpk; end; estimated_params; bet, normal_pdf, 1, 0.05; end; |
This block declares numerical initial values for the optimizer when these ones are different from the prior mean.
Each line has the following syntax:
stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME , INITIAL_VALUE; |
See estimated_params, for the meaning and syntax of the various components.
This block declares lower and upper bounds for parameters in maximum likelihood estimation.
Each line has the following syntax:
stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME , LOWER_BOUND, UPPER_BOUND; |
See estimated_params, for the meaning and syntax of the various components.
Description
This command runs Bayesian or maximum likelihood estimation.
The following information will be displayed by the command:
Options
datafile = FILENAMEThe datafile: a ‘.m’ file, a ‘.mat’ file or, a ‘.xls’ file (the latter format is supported under Octave if the io and java packages from Octave-Forge are installed, along with a Java Runtime Environment)
xls_sheet = NAMExls_range = RANGEnobs = INTEGERThe number of observations to be used. Default: all observations in the file
nobs = [INTEGER1:INTEGER2]
Runs a recursive estimation and forecast for samples of size ranging
of INTEGER1 to INTEGER2. Option forecast must
also be specified
first_obs = INTEGERprefilter = INTEGER
A value of 1 means that the estimation procedure will demean
the data. Default: 0, i.e. no prefiltering
presample = INTEGER
The number of observations to be skipped before evaluating the
likelihood. Default: 0
loglinearComputes a log-linear approximation of the model instead of a linear approximation. The data must correspond to the definition of the variables used in the model. Default: computes a linear approximation
plot_priors = INTEGERControl the plotting of priors:
0No prior plot
1Prior density for each estimated parameter is plotted. It is important to check that the actual shape of prior densities matches what you have in mind. Ill choosen values for the prior standard density can result in absurd prior densities.
Default value is 1.
nographSee nograph.
nodisplaySee nodisplay.
graph_format = FORMATSee graph_format.
lik_init = INTEGERType of initialization of Kalman filter:
1For stationary models, the initial matrix of variance of the error of forecast is set equal to the unconditional variance of the state variables
2For nonstationary models: a wide prior is used with an initial matrix of variance of the error of forecast diagonal with 10 on the diagonal
3For nonstationary models: use a diffuse filter (use rather the diffuse_filter option)
4The filter is initialized with the fixed point of the Riccati equation
Default value is 1. For advanced use only.
lik_algo = INTEGERFor internal use and testing only.
conf_sig = DOUBLESee conf_sig.
mh_replic = INTEGER Number of replications for Metropolis-Hastings
algorithm. For the time being, mh_replic should be larger than
1200. Default: 20000
sub_draws = INTEGER number of draws from the Metropolis iterations that
are used to compute posterior distribution of various objects (smoothed
variable, smoothed shocks, forecast, moments, IRF). sub_draws should be smaller than
the total number of Metropolis draws available. Default:
min(1200,0.25*Total number of draws)
mh_nblocks = INTEGERNumber of parallel chains for Metropolis-Hastings algorithm. Default:
2
mh_drop = DOUBLEThe fraction of initially generated parameter vectors to be dropped
before using posterior simulations. Default: 0.5
mh_jscale = DOUBLEThe scale to be used for the jumping distribution in
Metropolis-Hastings algorithm. The default value is rarely
satisfactory. This option must be tuned to obtain, ideally, an
acceptation rate of 25% in the Metropolis-Hastings algorithm. Default:
0.2
mh_init_scale = DOUBLEThe scale to be used for drawing the initial value of the
Metropolis-Hastings chain. Default: 2*mh_scale
mh_recover Attempts to recover a Metropolis-Hastings
simulation that crashed prematurely. Shouldn’t be used together with
load_mh_file
mh_mode = INTEGER…
mode_file = FILENAME
Name of the file containing previous value for the mode. When
computing the mode, Dynare stores the mode (xparam1) and the
hessian (hh) in a file called
‘MODEL_FILENAME_mode.mat’
mode_compute = INTEGER | FUNCTION_NAMESpecifies the optimizer for the mode computation:
0The mode isn’t computed. When mode_file option is specified, the
mode is simply read from that file.
When mode_file option is not
specified, Dynare reports the value of the log posterior (log likelihood)
evaluated at the initial value of the parameters.
When mode_file
option is not specified and there is no estimated_params block,
but the smoother option is used, it is a roundabout way to
compute the smoothed value of the variables of a model with calibrated parameters.
1Uses fmincon optimization routine (not available under Octave)
2Value no longer used
3Uses fminunc optimization routine
4Uses Chris Sims’s csminwel
5Uses Marco Ratto’s newrat. This value is not compatible with non
linear filters or DSGE-VAR models
6Uses a Monte-Carlo based optimization routine (see Dynare wiki for more details)
7Uses fminsearch, a simplex based optimization routine (available
under MATLAB if the optimization toolbox is installed; available under
Octave if the optim
package from Octave-Forge is installed)
8Uses Dynare implementation of the Nelder-Mead simplex based optimization
routine (generally more efficient than the MATLAB or Octave implementation
available with mode_compute=7)
9Uses the CMA-ES (Covariance Matrix Adaptation Evolution Strategy) algorithm, an evolutionary algorithm for difficult non-linear non-convex optimization
FUNCTION_NAMEIt is also possible to give a FUNCTION_NAME to this option, instead of an INTEGER. In that case, Dynare takes the return value of that function as the posterior mode.
Default value is 4.
mode_checkTells Dynare to plot the posterior density for values around the computed mode for each estimated parameter in turn. This is helpful to diagnose problems with the optimizer
prior_trunc = DOUBLE Probability of extreme values of the prior
density that is ignored when computing bounds for the
parameters. Default: 1e-32
load_mh_file Tells Dynare to add to previous
Metropolis-Hastings simulations instead of starting from
scratch. Shouldn’t be used together with mh_recover
optim = (fmincon options)Can be used to set options for fmincon, the optimizing function
of MATLAB Optimization toolbox. Use MATLAB’s syntax for these
options. Default:
('display','iter','LargeScale','off','MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6)
nodiagnosticDoesn’t compute the convergence diagnostics for Metropolis-Hastings. Default: diagnostics are computed and displayed
bayesian_irf Triggers the computation of the posterior
distribution of IRFs. The length of the IRFs are controlled by the
irf option. Results are stored in oo_.PosteriorIRF.dsge
(see below for a description of this variable)
dsge_varTriggers the estimation of a DSGE-VAR model, where the weight of the
DSGE prior of the VAR model will be estimated. The prior on the
weight of the DSGE prior, dsge_prior_weight, must be defined in
the estimated_params section. NB: The previous method of
declaring dsge_prior_weight as a parameter and then placing it
in estimated_params is now deprecated and will be removed in a
future release of Dynare.
dsge_var = DOUBLE
Triggers the estimation of a DSGE-VAR model, where the weight of the
DSGE prior of the VAR model is calibrated to the value passed. NB: The
previous method of declaring dsge_prior_weight as a parameter
and then calibrating it is now deprecated and will be removed in a
future release of Dynare.
dsge_varlag = INTEGER The number of lags used to estimate a DSGE-VAR
model. Default: 4.
moments_varendo Triggers the computation of the posterior
distribution of the theoretical moments of the endogenous
variables. Results are stored in
oo_.PosteriorTheoreticalMoments (see below for a description of
this variable)
conditional_variance_decomposition = INTEGERSee below.
conditional_variance_decomposition = [INTEGER1:INTEGER2]See below.
conditional_variance_decomposition = [INTEGER1 INTEGER2 …]Computes the posterior distribution of the conditional variance
decomposition for the specified period(s). The periods must be strictly
positive. Conditional variances are given by
. For
period 1, the conditional variance decomposition provides the
decomposition of the effects of shocks upon impact. The results are
stored in
oo_.PosteriorTheoreticalMoments.dsge.ConditionalVarianceDecomposition,
but currently there is not output. Note that this option requires the
option moments_varendo to be specified.
filtered_vars Triggers the computation of the posterior
distribution of filtered endogenous variables and shocks. Results are
stored in oo_.FilteredVariables (see below for a description of
this variable)
smoother Triggers the computation of the posterior distribution
of smoothered endogenous variables and shocks. Results are stored in
oo_.SmoothedVariables, oo_.SmoothedShocks and
oo_.SmoothedMeasurementErrors. Also triggers the computation of
oo_.UpdatedVariables, which contains the estimation of the
expected value of variables given the information available at the
current date. See below for a description of all these
variables.
forecast = INTEGER Computes the posterior distribution of a forecast on
INTEGER periods after the end of the sample used in
estimation. If no Metropolis-Hastings is computed, the result is
stored in variable oo_.forecast and corresponds to the forecast
at the posterior mode. If a Metropolis-Hastings is computed, the
distribution of forecasts is stored in variables
oo_.PointForecast and
oo_.MeanForecast. See section Forecasting) for a description of
these variables.
texRequests the printing of results and graphs in TeX tables and graphics that can be later directly included in LaTeX files (not yet implemented)
kalman_algo = INTEGERkalman_tol = DOUBLE…
filter_covarianceSaves the series of one step ahead error of forecast covariance matrices.
filter_step_ahead = [INTEGER1:INTEGER2]
Triggers the computation k-step ahead filtered values. Stores results in
oo_.FilteredVariablesKStepAhead and
oo_.FilteredVariablesKStepAheadVariances.
filter_decompositionTriggers the computation of the shock decomposition of the above k-step ahead filtered values.
constant…
noconstant…
diffuse_filterUses the diffuse Kalman filter (as described in Durbin and Koopman (2001) and Koopman and Durbin (2003)) to estimate models with non-stationary observed variables.
When diffused_filter is used the lik_init option of
estimation has no effect.
When there are nonstationary variables in a model, there is no unique deterministic steady state. The user must supply a MATLAB/Octave function that computes the steady state values of the stationary variables in the model and returns dummy values for the nonstationary ones. The function should be called with the name of the ‘.mod’ file followed by ‘_steadystate’. See ‘fs2000_steadystate.m’ in ‘examples’ directory for an example.
Note that the nonstationary variables in the model must be integrated processes (their first difference or k-difference must be stationary).
selected_variables_onlyOnly run the smoother on the variables listed just after the
estimation command. Default: run the smoother on all the
declared endogenous variables.
cova_compute = INTEGERWhen 0, the covariance matrix of estimated parameters is not
computed after the computation of posterior mode (or maximum
likelihood). This increases speed of computation in large models
during development, when this information is not always necessary. Of
course, it will break all successive computations that would require
this covariance matrix. Default is 1.
solve_algo = INTEGERSee solve_algo.
order = INTEGEROrder of approximation, either 1 or 2. When equal to
2, the likelihood is evaluated with a particle filter based on
a second order approximation of the model (see
Fernandez-Villaverde and Rubio-Ramirez (2005)). Default is
1, ie the lilkelihood of the linearized model is evaluated
using a standard Kalman filter.
irf = INTEGERSee irf. Only used if bayesian_irf is passed.
irf_shocks = ( VARIABLE_NAME [[,] VARIABLE_NAME …] )See irf_shocks. Only used if bayesian_irf is passed. Cannot be used with dsge_var.
aim_solverSee aim_solver.
sylvester = OPTIONSee sylvester.
sylvester_fixed_point_tol = DOUBLElyapunov = OPTION
Determines the algorithm used to solve the Laypunov equation to initialized the variance-covariance matrix of the Kalman filter using the steady-state value of state variables. Possible values for OPTION are:
defaultUses the default solver for Lyapunov equations based on Bartels-Stewart algorithm.
fixed_pointUses a fixed point algorithm to solve the Lyapunov equation. This method is faster than the default one for large scale models, but it could require a large amount of iterations.
doublingUses a doubling algorithm to solve the Lyapunov equation (disclyap_fast). This method is faster than the two previous one for large scale models.
square_root_solverUses a square-root solver for Lyapunov equations
(dlyapchol). This method is fast for large scale models
(available under MATLAB if the control system toolbox is installed;
available under Octave if the
control package from
Octave-Forge is installed)
Default value is default
lyapunov_fixed_point_tol = DOUBLEThis is the convergence criterion used in the fixed point lyapunov solver. Its default value is 1e-10.
lyapunov_doubling_tol = DOUBLEThis is the convergence criterion used in the doubling algorithm to solve the lyapunov equation. Its default value is 1e-16.
analytic_derivationTriggers estimation with analytic gradient. The final hessian is also computed analytically. Only works for stationary models without missing observations.
Note
If no mh_jscale parameter is used in estimated_params, the
procedure uses mh_jscale for all parameters. If
mh_jscale option isn’t set, the procedure uses 0.2 for
all parameters.
Output
After running estimation, the parameters M_.params and
the variance matrix M_.Sigma_e of the shocks are set to the
mode for maximum likelihood estimation or posterior mode computation
without Metropolis iterations.
After estimation with Metropolis iterations (option
mh_replic > 0 or option load_mh_file set) the parameters
M_.params and the variance matrix M_.Sigma_e of the
shocks are set to the posterior mean.
Depending on the options, estimation stores results in various
fields of the oo_ structure, described below.
Running the smoother with calibrated parameters
It is possible to compute smoothed value of the endogenous variables
and the shocks with calibrated parameters, without estimation
proper. For this usage, there should be no estimated_params
block. Observed variables must be declared. A dataset must be
specified in the estimation instruction. In addition, use the
following options:
mode_compute=0,mh_replic=0,smoother. Currently, there is no
specific output for this usage of the estimation command. The
results are made available in fields of oo_ structure. An
example is available in ‘./tests/smoother/calibrated_model.mod’.
In the following variables, we will adopt the following shortcuts for specific field names:
This field can take the following values:
HPDinfLower bound of a 90% HPD interval(3)
HPDsupUpper bound of a 90% HPD interval
MeanMean of the posterior distribution
MedianMedian of the posterior distribution
StdStandard deviation of the posterior distribution
decilesDeciles of the distribution.
densityNon parametric estimate of the posterior density. First and second columns are respectively abscissa and ordinate coordinates.
This field can take the following values:
measurement_errors_corrCorrelation between two measurement errors
measurement_errors_stdStandard deviation of measurement errors
parametersParameters
shocks_corrCorrelation between two structural shocks
shocks_stdStandard deviation of structural shocks
Variable set by the estimation command.
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option.
Variable set by the estimation command, if it is used with the
filtered_vars option. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
filter_step_ahead option.
Variable set by the estimation command, if it is used with the
filter_step_ahead option.
Variable set by the estimation command, if it is used with the
bayesian_irf option. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
smoother option. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
smoother option. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
smoother option. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
smoother option. Contains the estimation of the expected value of
variables given the information available at the current
date. Fields are of the form:
|
Variable set by the estimation command, if it is used with the
moments_varendo option. Fields are of the form:
|
where THEORETICAL_MOMENT is one of the following:
covarianceVariance-covariance of endogenous variables
correlationCorrelation between endogenous variables
VarianceDecompositionDecomposition of variance(4)
ConditionalVarianceDecompositionOnly if the conditional_variance_decomposition option has been
specified
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Variable set by the estimation command, if it is used with
mh_replic > 0 or load_mh_file option. Fields are of the form:
|
Here are some examples of generated variables:
oo_.posterior_mode.parameters.alp oo_.posterior_mean.shocks_std.ex oo_.posterior_hpdsup.measurement_errors_corr.gdp_conso |
Description
This command computes odds ratios and estimate a posterior density over a collection of models. The priors over models can be specified as the DOUBLE values, otherwise a uniform prior is assumed.
Example
model_comparison my_model(0.7) alt_model(0.3); |
This example attributes a 70% prior over my_model and 30% prior
over alt_model.
Description
This command computes and displays shock decomposition according to the model for a given sample.
Note that this command must come after either estimation (in case
of an estimated model) or stoch_simul (in case of a calibrated
model).
Options
parameter_set = PARAMETER_SETSpecify the parameter set to use for running the smoother. The
PARAMETER_SET can take one of the following five values:
calibration, prior_mode, prior_mean,
posterior_mode, posterior_mean,
posterior_median. Default value: posterior_mean if
Metropolis has been run, else posterior_mode.
shocks = (VARIABLE_NAME [VARIABLE_NAME …] [ ; VARIABLE_NAME [VARIABLE_NAME …] …] )…
labels = ( VARIABLE_NAME [VARIABLE_NAME …] )…
datafile = FILENAMESee datafile. Useful when computing the shock decomposition on a calibrated model.
This command is deprecated. Use estimation option diffuse_filter instead for estimating a model with non-stationary observed variables or steady option nocheck to prevent steady to check the steady state returned by your steady state file.
Dynare also has the ability to estimate Bayesian VARs:
Computes the marginal density of an estimated BVAR model, using Minnesota priors.
See ‘bvar-a-la-sims.pdf’, which comes with Dynare distribution, for more information on this command.
Description
This command computes the smoothed variables (and possible the filtered
variables) on a calibrated model.
A datafile must be provided, and the observable variables declared with
varobs. The smoother is based on a first-order approximation of
the model.
By default, the command computes the smoothed variables and shocks and stores the
results in oo_.SmoothedVariables and
oo_.SmoothedShocks. It also fills oo_.UpdatedVariables.
Options
datafile = FILENAMESee datafile.
filtered_varsTriggers the computation of filtered variables. See filtered_vars for more details.
filter_step_ahead = [INTEGER1:INTEGER2]See filter_step_ahead.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on June 18, 2012 using texi2html 1.82.