Credible set IRFs given priors

Hey all,
in very general form my question is the following:
I want to estimate a model to test certain economic hypotheses. Before doing so I want to show that certain versions of the model, i.e. when I restrict certain parameters, are not able to capture the behaviour of some economic variables after some shock X. In particular I would like to show IRFs with credible sets given the priors to clarify that certain parameters drive the model’s ability to accept or reject the hypothesis.
Is there an easy way to do this? Like a bayesian_IRF option in stoch_simul given the priors?
Thanks for any hints and suggestions :slight_smile:

So you want to conduct a prior predictive check. The probably easiest way to do this is to use the unstable version/4.5 with the

command. It allows you to execute arbitrary exercises on draws from the prior distribution. See [Posterior predictive checks) and the manual. Get back to me when you need assistance.

as usual: faster than lightning :wink: thank you very much, johannes!
I’ll get back to you if I need further help!

Hi there,
I need some more help concerning the use of prior_function.

  1. Is it possible to run prior_function before estimating the model?
  2. In my model.mod file I have prior_function(sampling_draws=500, function=prior_func); and then I still need to write the function prior_func.m correct? Is this thread the best guideline on how to proceed: ?
  3. I’m a bit confused with the naming of the function. Would it be
    function output_cell =prior_func(xparam1,M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info)
    function output_cell =model(xparam1,M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info)
    I would be extremely grateful for any help!
  1. There was a bug that did not easily allow this ( Dynare 4.5.2, which will be out later this week should allow it.
  2. Yes, you need to write that function. The best example is
  3. The filename needs to be identical with the name provided after function=. Thus, if your file is named prior_func that should be in the first line (although Matlab will not really care about this)

I am struggling a bit in producing/storing the output I want in the prior_function.
The function produces a draw from the prior distribution. I can’t call stoch_simul though to produce an IRF of variable X and store it in output cell. Could I call the irf-function or is there some other clever function I could use?
Given that I update the parameters to the current draw
% set the parameters draws to the model structure
M_ = set_all_parameters(xparam1,estim_params_,M_);
% compute the steady state for the parameter draw written to M_
[ys,params,info] = evaluate_steady_state(oo_.steady_state,M_,options_,oo_,0);
does that also update my decision rules? Or do I need to solve the model again?
Sorry for being so needy. Any help is greatly appreciated.

I used the following function:

function output_cell = IRF_moments(xparam1,M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info),
% function output_cell = IRF_moments(xparam1,M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info),
% Function called by execute_prior_posterior_function that generates
% variance decomposition for given set of parameters
% For input/output arguments, see the Dynare manual on posterior_function

% Copyright (C) 2016 Johannes Pfeifer
%  This is free software: you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation, either version 3 of the License, or
%  (at your option) any later version.
%  It is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  GNU General Public License for more details.
%  For a copy of the GNU General Public License,
%  see <>.
global options_ M_ oo_

M_ = set_all_parameters(xparam1,estim_params_,M_); %set parameters
var_list_=char('x','p','r'); %define variable list
info = stoch_simul(var_list_); %run stoch_simul on the variable list
if ~info(1)
    x_pos=strmatch('x',var_list_,'exact'); %get variable positions
    output_cell{1,1}  = (oo_.irfs.p_er);
    output_cell{1,2}  = (oo_.irfs.x_er);

    output_cell{1,3}= (oo_.var(p_pos,p_pos));
    output_cell{1,4}= (oo_.var(x_pos,x_pos));

    output_cell{1,5} = (oo_.autocorr{1,1}(p_pos,p_pos));
    output_cell{1,6} = (oo_.autocorr{1,1}(x_pos,x_pos));