Giter Site home page Giter Site logo

rise_toolbox's Introduction

Rationality In Switching Environments (RISE) Toolbox

Welcome to RISE!!! For any issue, suggestion or bug report, please send an email to junior.maih AT gmail.com

RISE is an object-oriented Matlab toolbox for solving and estimating nonlinear Regime-Switching Dynamic Stochastic General Equilibrium (RS-DSGE) models.

A new paper describing the problem and the solution approach in RISE can be found here. Other references in the field include various papers by Dan Waggoner and Tao Zha, which can be found here.

In RISE, the switching process and can be endogenous. RISE uses perturbation to approximate the nonlinear Regime-Switching DSGE (RS-DSGE) model and solves it using efficient algorithms.

Constant-parameter DSGE models are a special case. RISE also includes the solution and estimation of

Features of the toolbox

  • Symbolic, automatic and numerical derivatives

  • Time Series

  • Maximum Likelihood and Bayesian estimation

  • Derivative-free optimization algorithms

  • Forecasting and conditional forecasting

  • DSGE-VAR modeling

  • Integrated SVAR modeling with short, long and mixed restrictions

  • High Dimensional Model Representation and Monte Carlo Filtering

  • Reporting system

Installation

  1. Download the toolbox either as zip file or through github (recommended)
  2. add the toolbox path to Matlab and run rise_startup();

Documentation

  • This publicly available version of RISE is largely work in progress and there is a documentation (PDF, HTML, etc) but that too is work in progress.
  • RISE is very intuitive as you will quickly realize when you run the examples in RISE_toolbox\examples\
  • Should you want to report a bug, make a suggestion or need help, please send an email to junior.maih AT gmail.com

Analytics

rise_toolbox's People

Contributors

jmaih avatar sehyoun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rise_toolbox's Issues

Problem with example "LWZ_Econometrica2013"

Dear Junior,
I use your RISE_toolbox to run the Zha Tao's example "LWZ_Econometrica2013",the m file master.m, but the results show that:

file2blocks:: (gentle warning): I is also a matlab function
file2blocks:: (gentle warning): Le is also a matlab function
file2blocks:: (gentle warning): Mu is also a matlab function
file2blocks:: (gentle warning): Psi is also a matlab function
file2blocks:: (gentle warning): alpha is also a matlab function
Error using parser.capture_equations/capture_equations_engine (line 124)
capture_equations:: attributes to model block no longer permitted in file lwz_model at
line 73

Error in parser.capture_equations (line 58)
[block,equation]=capture_equations_engine(block,listing(ii,:),block_name,equation);

Error in parser.parse_model (line 25)
[Model_block,dictionary]=parser.capture_equations(dictionary,blocks(current_block_id).listing,'model');

Error in parser.parse (line 195)
[Model_block,dictionary,blocks]=parser.parse_model(dictionary,blocks);

Error in dsge (line 320)
dictionary=parser.parse(model_filename,cmfArgins{:});

Error in rise (line 64)
obj=obj@dsge(varargin{:});

Error in master (line 5)
m=rise('lwz_model');

So what does "model block no longer permitted in file lwz_model" mean?Is it because dynare has been installed in my matlab, thus the command "model(linear)" conflicts with your toolbox? Should I uninstall dynare in order to run this example?

Thanks!

I am looking forward to your reply.

Zixiang Zhu

School of Economics and Management
Southwest Jiaotong University,Chengdu,P.R. China

Problem in solving regime-switching model

Hi Junior,

I was trying to solve a nonlinear medium-scale NK model with switching regimes. If I do not declare 'steady_state_imposed', true, then the model can only be solved in one of the two regimes using any solver. If I declare this, then the model can be solved using 'mn' or 'mnk' solver, but the solution is unstable.

To summarize, here is what I found in the debug mode:

(1) model with switching regimes + any solver -> the model in one regime is solved, but the model in another regime is not solved because lsqnonlin exceeded the iteration limit (Residual = 1e-9, Lambda = 1e-7 when stopped)

(2) model with switching regimes + regular solver + 'steady_state_imposed', true --> not solved

(3) model with switching regimes + 'mn' or 'mnk' solver + 'steady_state_imposed', true --> the model in both regimes are solved, but solution unstable

Would you offer me any advice about how I shall proceed? Thanks!

Best,
Zexi

Replicating the ZLB paper

Hi Dr Maih

I'm trying to replicate your joint paper on "Implementing the ZLB". I've tried to write a .rs file as similar to the model equations as possible, but the error message I've gotten is that the "model has not been solved at least up to the first order" (which I take is a signal that obj.solution is empty). I looked at an earlier thread on a similar issue, #2, but that didn't seem to help.

At this point, the only Markov chain in the model is an exogenous one for shifting time preference factor d_t. I also haven't included the restrictions in section 5.2. I would be grateful for any help you can provide!

Problem in simulating threshold-switching models

Hi Junior,

Hope everything is going well.

Recently I have been using RISE to build Markov-switching models with endogenous probabilities, and I am particularly interested in the threshold-switching model, where the regime is determined by whether a variable takes a value above or below some threshold level. It seems that RISE can solve but cannot simulate such kind of models.

As an example, the endogenous probabilities in such models are
! ocb_tp_1_2 = 1 - normcdf(var, 0, sigma)
! ocb_tp_2_1 = normcdf(var, 0, sigma)

where var is just an endogenous or exogenous variable. Ideally, to build a threshold-switching model, the parameter sigma should approach zero. When I set a high value for sigma (e.g. 0.1), the model can be solved and be simulated. But when I set a low value for sigma (e.g. 0.01) the model can only be solved by cannot be simulated.

Initially I thought the problem was coming from the algorithm you used, so I wrote a Matlab code myself to solve and simulate a model with threshold switching using exactly the algorithm you introduced in Maih (2015). Fortunately, it worked even for very low values of sigma (e.g. 0.0001). But then I don't understand the reason why it doesn't work in RISE. Do you have any thoughts on where the problem is coming from? Also, could you tell me where to find the Matlab codes for algorithms MFI, MN and MNK in the toolbox? Thanks!

Best,
Zexi

How to Get the sampler results

Hi Junior,

How can I get the results after use a sampler?
For example after I run:
Results=mh_sampler(objective,lb,ub,mcmc_options,x0,SIG);
for example how can I get the bayesian confidence intervals or other statistics?

Thanks in advance,
Leonard.

@sig at steady_state_imposed

Hi Junior.

I'm currently working on a Regime-Switching model with endogenous transition probabilities. However, I have a problem because the endogenous variable at transition probabilities does not have an unique steady state. So, in order to solve the model I must imposed the steady state (which is the steady state of the second regime). My problem is that I have @sig constants in the policy functions of the second regime, which represents a difference between the SS I am imposing and the SS that RISE would calculate without "'steady_state_imposed', true". I do not understand why those @sig constants appear. When I use exogenous probabilities and "'steady_state_imposed', true" the same problem arises. Am I misunderstanding @sig? Shouldn't appear when the imposed steady state is equal to the steady state of regime 2?

Thank you for your attention.

Sincelery,

Leonardo

about implementing csminwel or a more efficient optimization algorithm

Hi Junior,

I have replicated one example from Dynare in RISE but i got serious problems during the estimation,
the think is that dynare reaches a global minimum (while reaching the posterior mode) which is lower than the one i got from rise, and also got problems with the sigma (SIG) to be positive definite.

Have you implemented the csminwel algorithm in the estimation? Which one of those is possible to use would you recommend?

Regards,
Pedro

Explosion Limit reached

Dear Junior
I tried running a small open economy with export and it gives these errors
Looking for good enough start values. Please wait...
1 :: Explosion limit reached
483 :: Maximum Number of iterations reached or multiple solutions
499 :: Explosion limit reached
Error using generic/find_posterior_mode (line 78)
find_posterior_mode:: No admissible starting value after 500 trials

What is the cause of this problem and how do I fix it.

regard
Sam

How to read filtering.smoothed_regime_probabilities id there are two Markov chaines

Dear Junior,

I have two Markov chains, one that controls policy coefficients and the other controls parameters characterizing exogenous processes. Say (a,1) (a,2) and (b,1) (b,2). In this case, what is the combination of those chains in filtering.smoothed_regime_probabilities.regime_i ? After some experiments, I guess it should be this way:

regime_1 : (a1),(b,1)
regime_2 : (a2),(b,1)
regime_3 : (a1),(b,2)
regime_4 : (a2),(b,2)

Is that correct?

Thanks in advance,

Plotting posteriors after mh_sampler

Dear Junior,
I am trying to estimate the parameters for my MSDSGE model but when I try to use the plot_posteriors funtion, after the MH algorithm stops I get this error:

Error using matlab.graphics.axis.Axes/set
While setting the 'XLim' property of 'Axes':
Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf

For some starting points it is ok, but for others the error message pops up. Are there any additional settings that can change the limits of the axis?

Thank you,
Tom

ARMA(1,1) process

Dear Junior,

I recently updated the toolbox and now got a problem with my model. The last error message says:

Error using parser.create_auxiliary_equations>auxiliarize_exo_params/auxiliarize_one_equation (line 287)
Leads or lags on parameters or exogenous not allowed

I do have 2 ARMA(1,1) processes in my model, namely

laf_t   = rho_laf*laf_t(-1) + sig_laf*laf_sh - eta_laf*laf_sh(-1);
law_t   = rho_law*law_t(-1) + sig_law*law_sh - eta_law*law_sh(-1);

where laf_sh and law_sh are exogenous shocks. Is there a way around this issue?

Greetings
Gerret

treatment of endogenous probabilities in solution and simulation

Hi Junior,

I am working with endogenous switching probabilities defined as
! nk_tp_1_2 = prob_l_h(x_hat); ! nk_tp_2_1 = prob_h_l(x_hat);
where prob_l_h and prob_h_l are nonlinear functions of the variable x_hat.

  1. I guess RISE will linearize these functions when solving the model, right? Then, for estimation and simulation, the interpretation is that the probabilities are computed as the linear approximation of the nonlinear functions prob_l_h and prob_h_l?

  2. after simulation, is it possible to see the values of these probabilities at each point in time? The output shows the variable nk (in what regime is the model), but not the probabilities.

Thank you.
Martin

Initial values for estimated parameters

Dear Junior,

Every time I start estimate I get the message:

"Looking for good enough start values. Please wait..."

Isn't it enough to precise the starting value while defining my priors?

Anyway, I would like to give initial values for estimated parameters. I tried :

the_mod_file = struct('param_nk_1', 0.18, 'param_nk_2', 0.55);
m=estimate(m,'optimizer','bee_gate','optimset', myoptim,'estim_start_vals', the_mod_file);

But I get an error:

Error using rise_generic/set/set_one_at_a_time (line 139)
the_mod_file' is not a settable option or property of class rise

Error in rise_generic/set (line 116)
set_one_at_a_time();

....

What is the right way of doing it?
Thanks in advance.

solving a 2-regime model around arbitrary point

Hi Junior,

I would like to solve a 2-regime switching model around an arbitrary point, say between the SS at regime 1 and the SS at regime 2. I guess this could be done using the option 'steady_state_imposed','true', am I right?

My question is that I am not sure if that is the correct option, or how to use it. I'm working with a SS file (that works just fine when I don't try to impose the SS), and so I tried the command m=solve(m,'steady_state_file','mymodel_steadystate','steady_state_imposed','true')

but I get the following error:
Operands to the || and && operators must be convertible to logical scalar values. Error in dsge/compute_steady_state>prepare_steady_state_program (line 1024) if ~(sscode.is_imposed_steady_state||... Error in dsge/compute_steady_state (line 129) [obj,sscode,blocks,unsolved]=prepare_steady_state_program(obj); Error in dsge/solve/solve_zeroth_order (line 551) [obj,structural_matrices,retcode]=compute_steady_state(obj); Error in dsge/solve (line 340) retcode=solve_zeroth_order();

and when I go to the compute_steady_state function, the error reads:

errmsg=['With an initial guess for the steady state, the parameters cannot be modified in the steady state model or file'];

Do you know how to do this properly?

Thanks a lot.

Martin

Estimating model with the ZLB

Dear Junior,
I have a simple NK model with the zlb. I followed GavinKeenRichterMorton as in the “examples” file and assumes a Markov chain to control the states: “in” or “out” of the zlb. Now I’d like to estimate a linear version of this model. But even if I estimate only 2 parameters - transition probabilities zlb_tp_1_and zlb_tp_2_1 - I always get “Covariance of forecast errors not positive definite” , and at the end I have :

“Error using rise_generic/find_posterior_mode (line 78)
find_posterior_mode:: No admissible starting value after 500 trials”

I've checked that the model solution is stable. Is it possible to estimate a model like this in RISE?

Thanks a lot in advance.

Questions about simulate and irf commands

I have some questions about the simulate and irf commands, in particular how the changing probabilities are treated in the simulations.

The first question is when and how the probabilities are taken into account in the simulations. Suppose that I have a (1x1) rise object m: m=rise('mymodel') with two regimes. If, after solving, I use the command simdata = simulate(m) I get one time series for each endogenous variable, and a variable called “nk” (for the markov chain is called nk), which, as I understand tells you whether the model is in regime 1 or 2.

  1. Do these simulated time series take the probabilities (either exogenous or endogenous) of changing regime into account, in the sense that the simulated series is some weighted average of each variable obtained by multiplying the probabilities of being in regime 1 or 2 at each point in time, times the values that the variables would have in each state? And is the output of this command identical to the one I would get with the command simdata = simulate(m,'simul_regime',[1 2]); (I couldn’t really compare the outcomes since I don’t know how to trigger a deterministic simulator like the one of Dynare).

  2. When you use the command simdata = simulate(m,'simul_regime',1); or simdata = simulate(m,'simul_regime',2); you get one time series for each variable and the nk variable is always in regime 1 or 2, respectively. Are these simulations identical to the case where you simulate the model “as if” it where a single-regime model for each regime? (i.e., simulating each model around its steady state ignoring completely the possibility of changing to a different regime).

  3. If, instead, I run the model as (suggested in one of Tao Zha’s examples):

labels={0,'baseline'
            1,'alternative'};

for imod=1:size(labels,1)
            m(imod,1)=rise('mymodel',... % name of the file to read
            'rise_flags',struct('indx_model',labels{imod,1}));
            end

then the rise objet is (2x1) and the outcome of simdata = simulate(m) is two time series for each variable and two independent “nk” series that oscillate between 1 and 2. In this case it is not clear to me if these are just two independent models or a model with two regimes. If it’s the latter, how does this outcome relate to the one described at the very beginning of this post? (i.e, when using the simdata = simulate(m) on the (1x1) rise element described there).

  1. As for the IRFs, I guess they are always computed either in one regime or another, i.e. the probabilities don’t affect them in any way?

Two additional questions are:

  1. Is it possible to trigger a deterministic simulator like the mt199937ar algorithm with a seed of zero, as in Dynare? So far my simulations generate different results for subsequent runs.

  2. How to control the volatility of the exogenous variables (shocks) in the simulations and IRFs? My RISE simulations yield strange results when compared with the ones of Dynare that I have performed for shock sizes consistent with reasonable values for the variables.

estimating MS-DSGE models

Hi Junior,

Is there any example to estimate MS-DSGE in the toolbox? because I haven't found any, it seems that all of them uses calibrated parameters and when I try to use the estimate() function in a MS-DSGE models i get errors "parameter rho_x is not controlled by const", for example. I know that to calculate the likelihood for the estimation is with a different filter than the Kalman filter but I do not know if one has to implement that option in the estimate() function or so.

Thanks a lot and regards.
Pedro.

Modelling frontier

Dear Junior,

I try to make frontier of the Markov Switching DSGE model. I have 2 questions:

  1. I struggle to understand the difference between simulate (which is used by the function 'frontier'), 'simulate_nonlinear' and 'stoch_simul'. Can you tell me very briefly what is the difference between them in RISE and which of them is right to use for nonlinear MS DSGE models?

  2. 'frontier' function: I can do the frontier for the 1st regime and 2nd regime (I enter the code and add 'simul_regime' to simulate command in 'frontier' funtion). When don't do this, the result is different. Am I right that this is the simulation for both regimes?

I would be very grateful for your help.
Tom

error using simulate

Hi Junior,

I'm getting an error message when using the simulate RISE command in the context of a RS-DSGE model with endogenous probabilities. The error reads:

Error using generic/simulate (line 166) Problem in transition matrix Error in dsge/simulate (line 21) [varargout{1:nargout}]=simulate@generic_switch(obj,varargin{:});

I find it puzzling that the error appears only in certain configurations. It may or may not appear depending on the parameters governing the probability functions, the way to compute the steady state (i.e., whether it is imposed, unique or regime-specific), and the number of periods in the simulation. E.g., in a particular exercise, the error does not appear if I use 10.000 or less periods, but it shows up if I use 11.000 or more periods.

Do you know what could be going on?

Cheers,
Martin

parameter_restrictions

Dear Junior,

I need to impose a restriction on parameters which looks like
(1-zlb_tp_2_1)*Pi_star/K < 1

zlb_tp_2_1 is a transition probability

Which is exactly as the restriction (44) in your joint paper with Binning (2016).
However it seems like RISE is not very happy, it returns:

Error using str2func
Error: Unbalanced or unexpected parenthesis or bracket.
Error in
rise_generic/setup_nonlinear_restrictions>reprocess_nonlinear_restrictions
(line 240)
nonlcon=str2func(['@(M)[',nonlcon,']']);
Error in rise_generic/setup_nonlinear_restrictions (line 66)
nonlinear_restrictions=reprocess_nonlinear_restrictions(RestrictionsBlock);
Error in rise_generic/setup_restrictions (line 32)
obj=setup_nonlinear_restrictions(obj);
Error in rise_generic/transform_parameters (line 68)
obj=setup_restrictions(obj);
Error in rise_generic/estimate (line 268)
[obj,x0,lb_short,ub_short]=transform_parameters(obj,x0,lb,ub);
Error in dsge/estimate (line 27)
...

What is the right way to write down such restriction?

Thank you in advance.

Error in parser.capture

Hi Junior
I run the attached file and gives me the following error what has gone wrong and how do I fix it.
error using parser.capture_parameterization/capture_parameterization_engine/process_normal (line 237)
Error: This statement is incomplete.

Error in parser.capture_parameterization/capture_parameterization_engine (line 153)
process_normal()
modelcodepapertwo1.zip
Best,
Sam

Changing options for optimizer.

Hi Junior,
I would like to make MaxTime value higher, since I have a filling that the mode I found is not the right one. But I don't succeed in doing that. In the 'help' I read that we can specify a cell, containing the name of the optimizer and other inputs. So I do:
optimpot=struct('MaxNodes',20,'MaxIter',1000,'MaxTime',3600*5,...
'MaxFunEvals',inf);

X = java_array('java.lang.String', 7);
X(1) = java.lang.String('bee_gate');
X(2) = java.lang.String('fh');
X(3) = java.lang.String('x0');
X(4) = java.lang.String('lb');
X(5) = java.lang.String('ub');
X(6) = java.lang.String('optimpot');
X(7) = java.lang.String('varargin');

My_optim = cell(X)

estim_models_3=estimate(estim_models_3,'optimizer',My_optim);

Could you please tell me what is the right way of doing it? Shall I right a wrapper to change the initial settings?

Thanks in advance!

Backing out data series from an estimated model

Hi Junior,

Is there a function in your RISE toolbox that is similar to Dynare simult_(y0,dr,ex_,iorder) so that users can back out data from smoothed shocks and regime probabilities?

Thanks,
Aaron

How to plot posterior density figure?

Hi Junior:

My model is as same as FWZ(2011), and I check the FWZ example of RISE, I still have some  problem. To be more specific, after estimated the model, I want to plot the posterior density of these parameters by the function "plot_posterior" and I can't get anything. So I check the folder...\simutlations, it is empty. I don't why, can you help me?
By the way, when i estimated the model, using command like "estimate(mymodel,'optimizer','fmincon');"  was I missed soming or some parameters in this command?
thank you!!

"Nans in Jacobian"

Dear Junior,
I wrote a modified model of LWZ(2013) and set two independent switching-regime for both structural parameters and volatility, but got the result,

dsge:: Exogenous Switching DSGE model in 4 regimes detected
dsge:: model has both backward and forward-looking components
--------------------------------------------------------------
---------Estimation of SP_zhu9 model-----------
--------------------------------------------------------------
Looking for good enough start values. Please wait...
1 :: Nans in Jacobian
2 :: Nans in Jacobian
3 :: Nans in Jacobian
....
497 :: Nans in Jacobian
498 :: Nans in Jacobian
499 :: Nans in Jacobian
错误使用 generic/find_posterior_mode (line 78)
find_posterior_mode:: No admissible starting value after 500 trials

出错 generic/estimate (line 283)
[x1,f1,H,x0,f0,viol,funevals,issue,obj]=find_posterior_mode(obj,x0,lb_short,ub_short);
%#ok

出错 dsge/estimate (line 47)
obj=estimate@generic_switch(obj,varargin{:});

出错 SP_Only_zhu (line 103)
estim_models{imod}=estimate(estim_models{imod},'optimizer','fmincon');

What's wrong with this? Are my initial value inappropriate?

SP_zhu9.txt

Another question is whether RISE have alternative optimization routine like 'csminwel' or 'fminsearch'?

Thank you!
Zixiang Zhu

How to do forecasting?

Dear Junior,

I have a question considering forecasting with an estimated dsge model. Simply doing 'forecast(model)' does not seem to work. What’s the right way to do this?

I guess I have to work on the usual forecasting problem first, but maybe already a follow up question, is it possible to use information on a mixed frequency when doing the forecast? For example, use information of an indicator (which determines the transition probabilities) which is available on a monthly basis to do the forecasting in an otherwise quarterly model?

Thank you in advance
Gerret

Posterior densities in the same plot

Hi Junior,
I couldn't find an option in the plot_priors_and_posteriors(.) or plot_posterios (.) functions to do a unique plot for parameters that are defined in different regimes. For example rho_coef_1, rho_coef_2.
Am I missing it or it is better to do it manually?
Many thanks in advance,

Leonard.

Different steady-state values for different regimes?

Hi Junior,

Hope everything is going well with you.

Recently I encountered two problems in specifying steady-state values in the steady_state_model block, and I was wondering if you could help me with them.

  1. I know how to specify different parameters values for different regimes in the parameterization block (e.g. bind(zlb,1), 0; and bind(zlb,2), 0;), but could I specify different steady-state values for different regimes in the steady_state_model block?

  2. It seems that if I only specify the steady-state values for a subset of endogenous variables in the steady_state_model, then RISE will automatically set the steady-state values for the rest of endogenous variables to zero. Is that true?

Cheers,
Zexi

Different estimation results using different computers but the same files

Dear Junior,
I ‘d be grateful if you could give me your opinion about a problem I am having using Rise. Though I am not sure it comes from the toolbox itself.
I have two computers I am working on and I use dropbox where my RISE toolbox is stored together with the files I am working with.
Say I estimate model M on computer 1. I save the results and I check if I can improve my mode. For this I do:
load M
M_new = estimate(M,'optimizer', 'csminwelwrap', 'kf_init_variance', 5 ,'kf_presample', 16, 'estim_start_from_mode', true).
The second estimation starts exactly from the log_post of the estimated model M. No need even to put 'estim_start_from_mode', true. Everything’s good. If I do this on computer 2, it does the same thing. It starts from the previous mode.
But if I estimate model M using computer 2 (the same exactly model with the same priors and initial values as on the computer 1) then the estimation results are completely different. It delivers much better results: higher log_post, higher log_lik and higher data density. But if I do ‘re_estimation’ (M_new = estimate(M,…)) it doesn’t work on none of the computers. Matlab starts estimation with weird values and never converges. The only hint I have is that log data density of model M estimated on computer 1 is always negative if you check in M.estimation.posterior_maximization, while on computer 2 it is positive.

Do you have an idea what’s happening?
Thanks a lot in advance.
Kind regards,

Problem plot_posteriors

Hi Junior,

I followed your instructions for Xiaofeng but I did not have success. The instructions are reproduced following:
create an objective function for posterior simulation
[objective,lb,ub,x0,SIG]=pull_objective(mest);

Set up the options for the Metropolis Hasting algorithm
ndraws_mcmc = 1500; % number of parameter draws through MCMC.
ndraws_burnin = floor(0.1*ndraws_mcmc); % number of parameter draws to be burned
mcmc_options=struct('burnin',ndraws_burnin,'N',ndraws_mcmc,'thin',1);

Run the Metropolis hastings algorithm to sample from the posterior distribution
Results=mh_sampler(objective,lb,ub,mcmc_options,x0,SIG);

Plot the posterior distribution of the parameters
plot_posteriors(mest,Results.pop)

I tried to follow these steps to plot the posterioris, but I got the following error message:

Error using mh_sampler>(parfor body) (line 560)
Matrix must be positive definite.

Error in mh_sampler/scale_times_sqrt_covariance_updating (line 542)
parfor (ichain=1:nchain,NumWorkers)

Error in mh_sampler (line 368)
scale_times_sqrt_covariance_updating()

Caused by:
Error using chol
Matrix must be positive definite.

Someone could help me?

Thank you very much in advance
Best
Luís

Steady state specification

Hi!

in RISE_toolbox-master/examples/MarkovSwitching/GavinKeenRichterThrockmorton/globdynzlb.rs

The steady state block has the (imposed) attribute: steady_state_model(imposed)

RISE does not like this attribute, so I have removed it. But then the program cannot find the steady state anymore

Error using dsge/compute_steady_state>prepare_steady_state_program (line 968)
With an initial guess for the steady state, the parameters cannot be modified in the steady state model or file
Error in dsge/compute_steady_state (line 129)
[obj,sscode,blocks,unsolved]=prepare_steady_state_program(obj);
Error in dsge/solve/solve_zeroth_order (line 593)
            [obj,structural_matrices,retcode]=compute_steady_state(obj);
Error in dsge/solve (line 312)
retcode=solve_zeroth_order(); 

Which syntax should we use at this stage?

Thanks!

Angela

Error in endogenous transition probabilities

DearJunior:

Im actually incorporating regime switching in the Curdia Woodford (2009) model. The model I did has an endogenous transition matrix which depends in a variable that has unique steady state.the model is successfully solved in first order but when I try to solve in second order ( with automatic derivatives) there is a problem in the derivatives. In the error appears the transition matrix multiplying an expression that RISE don't recognize.

Thank you in advance

Error in dsge/forecast_real_time (line 62)

Struct contents reference from a non-struct array object.

Error in utils.time_series.concatenate_series_from_different_models>do_intersection (line 100)
dn1=this.date_numbers;

Error in utils.time_series.concatenate_series_from_different_models (line 26)
[varList,ncols,dn_start,dn_last]=do_intersection(dbcell);

Error in dsge/forecast_real_time (line 62)
ts_rmse=utils.time_series.concatenate_series_from_different_models(ts_rmse);

Error in Tao_report (line 393)
[ts_fkst,ts_rmse]=forecast_real_time(m);

Error in howto_report (line 41)
Tao_report(model_objects,rep_data)Struct contents reference from a non-struct array object.

Error in utils.time_series.concatenate_series_from_different_models>do_intersection (line 100)
dn1=this.date_numbers;

Error in utils.time_series.concatenate_series_from_different_models (line 26)
[varList,ncols,dn_start,dn_last]=do_intersection(dbcell);

Error in dsge/forecast_real_time (line 62)
ts_rmse=utils.time_series.concatenate_series_from_different_models(ts_rmse);

Error in Tao_report (line 393)
[ts_fkst,ts_rmse]=forecast_real_time(m);

Error in howto_report (line 41)
Tao_report(model_objects,rep_data)Struct contents reference from a non-struct array object.

Error in utils.time_series.concatenate_series_from_different_models>do_intersection (line 100)
dn1=this.date_numbers;

Error in utils.time_series.concatenate_series_from_different_models (line 26)
[varList,ncols,dn_start,dn_last]=do_intersection(dbcell);

Error in dsge/forecast_real_time (line 62)
ts_rmse=utils.time_series.concatenate_series_from_different_models(ts_rmse);

Error in Tao_report (line 393)
[ts_fkst,ts_rmse]=forecast_real_time(m);

Error in howto_report (line 41)
Tao_report(model_objects,rep_data)Struct contents reference from a non-struct array object.

Error in utils.time_series.concatenate_series_from_different_models>do_intersection (line 100)
dn1=this.date_numbers;

Error in utils.time_series.concatenate_series_from_different_models (line 26)
[varList,ncols,dn_start,dn_last]=do_intersection(dbcell);

Error in dsge/forecast_real_time (line 62)
ts_rmse=utils.time_series.concatenate_series_from_different_models(ts_rmse);

Error in Tao_report (line 393)
[ts_fkst,ts_rmse]=forecast_real_time(m);

Error in howto_report (line 41)
Tao_report(model_objects,rep_data)Struct contents reference from a non-struct array object.

Error in utils.time_series.concatenate_series_from_different_models>do_intersection (line 100)
dn1=this.date_numbers;

Error in utils.time_series.concatenate_series_from_different_models (line 26)
[varList,ncols,dn_start,dn_last]=do_intersection(dbcell);
Dear Junior
Thank you, the model has run after I modified. One thing that will be interesting is the forecasting bugs which read aspHow do I fixed this bugs.
Error in dsge/forecast_real_time (line 62)
ts_rmse=utils.time_series.concatenate_series_from_different_models(ts_rmse);

Error in Tao_report (line 393)
[ts_fkst,ts_rmse]=forecast_real_time(m);

Error in howto_report (line 41)
Tao_report(model_objects,rep_data)
Please how do I fixed these bugs.

Best,
Sam

rfvar

Dear Junior
Trusting you are doing well. I tried using rfvar and reports the bug below
Struct contents reference from a non-struct array object.
Error in generic_switch/reset/mark_parameters (line 65)
n=obj.parameters.number;
Error in generic_switch.reset (line 55)
mark_parameters()
Error in svar (line 87)
obj=generic_switch.reset(obj,out.endogenous,out.exogenous,...
Error in rfvar (line 76)
obj=obj@svar(varargin{:});
Error in howto (line 32)
rv=rfvar(tmpl,'data',data);

How to fix it.
Best,
Sam

Greetings

Hi, all,

Nice to meet you all here.

Best,

Richard Gu (China)

Plot normalized priors and posteriors

Hi Junior,

I'm trying to extract the normalized information for my model parameters after running a MH algorithm.
In the past I used this line to do that:
[ppdata]=plot_priors_and_posteriors(obj,Results.pop,myparams,'normalize2prior')

But it seems like the 'normalize2prior' instruction doesn't work anymore. There is another form to obtain this information?

Many thanks in advance.

Regards,

Leonard

Markov Chains in separated Files

Hi Junior,

I'm trying to setup the priors in a separate file using the syntax for Bayesian priors with mean an std. deviation:
P.pname={start_value,prior_mean,prior_stdev,'distribution',lower_bound,upper_bound};

It works correctly for the constant parameter case. But when I try to use markov chains don't know how to do the correct syntax for the parameters. The standard syntax say:
lambda_1(coef,1)={...};
lambda_1(coef,2)={...} ;
does not work. How can I do it in the correct form?

Thanks in advance,
Leonard.

external functions and endogenous probabilities

Hi Junior,
I'm working with a regime switching DSGE with endogenous probabilities. I would like to make these probabilities dependent on the deviations of a given variable (let's call it x) from its SS; even if x has different SS values in each regime, I guess this shouldn't be a problem since x_hat_ss is zero in both regimes.

  1. the first question concerns the use of external functions in RISE in general. In Dynare you would use the "external_function(name = myfun, nargs =integer)" command and then just use "myfun" in the code. How does it work in RISE?
  2. I would like to write the endogenous probabilities as:
    ! nk_tp_1_2 = myfun(x_hat,other_args); where myfun is an external matlab function of x_hat that returns a value between zero and one for each possible value of x_hat. Is it possible to specify the probabilities in this way in RISE?
    Thank you,
    Martin

A simple question about "parameterization"

Dear Junior,

I just want to know what does each entry represent in parameterization. For example, in the example “volatilityOnly_expanded”, there are:

....
parameterization
tau , 0.5376, 0.1000, 0.5000, gamma_pdf(.90);
kappa , 0.5800, 0.0500, 1.0000, gamma_pdf(.90);
beta_trans , 0.1000, 0.2000, 0.4000, beta_pdf(.90);
...

What does "0.5376" mean? Is it initial prior value?
What do "0.1000" and "0.5000" mean respectively? Are they the lower bound and upper bound of 90 percent confidence interval of gamma_pdf?

Thanks!
Zixiang Zhu

Solution algorithms while running the SW07 model with switch in the Taylor Rule parameters

Hi, me again :)

I am working with the example of the Smets and Wouters 07 model, with switches in the Taylor rule coefficients, found in this subfolder examples/MarkovSwitching/SmetsWouters

After changing usmodel.rs by removing the linear attribute to the model block, I get the following error when running line 14 in howto.m

Non-overloaded subscripting can produce only one result.
Error in dsge_solver_first_order_autoregress_h (line 152)
[Tz_pb,~,retcode]=options.solver(Gplus01,A0,Aminus,Q,T0);
Error in solve_first_order (line 11)
[Tz_pb,eigval,retcode,options]=dsge_solver_first_order_autoregress_h(dbf_plus,...
Error in dsge_solver_h (line 66)
[T.Tz,others,eigval,retcode,obj.options]=solve_first_order(structural_matrices,...
Error in dsge/solve (line 356)
[T,eigval,retcode,obj]=...
Error in howto (line 13)
sw=solve(sw,'solver','newton_kronecker_iteration');

It is a problem with the solver. Perhaps it just syntax.
I have tried running
(1) sw=solve(sw)
(2) sw=solve(sw,'solver', 'mfi');

In both cases I get the following when looking at the model solution

MODEL HAS NOT BEEN SOLVED AT LEAST UP TO THE FIRST ORDER

Any idea how to solve this?

Since I am here, what is the syntax to solve at different orders?

Thanks in advance,

Angela

Error Tao Zha Tutorial2 - rise_save_macro

I am the first :)

I am trying to run now Tutorial 2:
RISE_toolbox-master/examples/VariousModels/TaoZha/Tutorials/DSGE/Tutorial2

after fixing
/RISE_toolbox-master/examples/VariousModels/TaoZha/Tutorials/DSGE/Tutorial2/Models/fwz_est.rs
by removing the (linear) specification

howto.m (line 67) is calling for a property which is no longer available (I guess). I get the following error message:

Error using rise_generic/set/set_one_at_a_time (line 139)
'rise_save_macro' is not a settable option or property of class rise

I have tried commenting out the following line (68), the code runs but the results look very strange (very persistent smoothed probabilities) and not at all in line with the pdf available.

I guess this line is needed (as it stores the results). How can we fix this problem?

Best,

Angela

Variance Decomposition

Dear Junior,
In Liu, Waggoner and Zha(2011)’s paper ,they distinguish V.D. for regime 1 and regime 2. But in your @Generic switch V.D., there’s only one. Does it matter? Or how could I get different V.D. results for two regimes?
Thanks!
Best!
Zixiang Zhu

Error on IRF's of 2nd order approximation.

Hi all,
I am currently working on a NK model with regime switch. I constructed my model using Gali(2008) and added a fiscal rule with gov'n buget constraint.
The problem is that, when i try to solve model with 1st order approximation, i get the responses as usual. If i switch to 2nd order, IRF's goes to 10^270 etc. which does not make sense.
I am using the following lines in my main code:
m=rise(Nonlinear_NK_Gali_MF_2,'max_deriv_order',2) m=solve(m,'solve_order',2)
And here is my model:

Nonlinear_NK_Gali_MF_2.txt

Thanks for your help.

Problems in simulating model with ZLB

Hi Junior,

I tried to use RISE to solve and simulate a DSGE model with the ZLB, but it seems not working.

The model I use is a nonlinear version of the Smets and Wouters (2007) model. If no ZLB constraint is imposed, then the results obtained from RISE is the same as the results obtained from Dynare.

To include the ZLB constraint, four new parameters are introduced:
parameters ocb_tp_1_2 ocb_tp_2_1
parameters(ocb,2) bind

They are calibrated as follows:
p.bind_ocb_1 = 0;
p.bind_ocb_2 = 1;
p.ocb_tp_1_2 = 0;
p.ocb_tp_2_1 = 0;

In the original model, the nominal interest rate is expressed as R = Robs/100, with a steady state value of 0.0159. To include the ZLB constraint, I changed this expression to R = bind*0 + (1 - bind)*Robs/100;. Besides, I also added ? R >= 0; in the model part.

Finally, I extended the solve command, so that
m = solve(m,'solve_occbin',1,'steady_state_imposed',true,'steady_state_unique',true);.

There was no problem in solving this model. However, when I was trying to simulate the model using
mysims = simulate(m,'simul_honor_constraints',true);
I got the following error messages

Error using generic/simulate (line 166)
forecast: constraint violation

Error in dsge/simulate (line 21)
[varargout{1:nargout}] = simulate@generic_switch(obj,varargin{:});

I don't know where the problem comes from. Could you help me with this please? Thanks!

Best,
Zexi

A list of Problems about the Examples

Dear Junior,
Right now I am systematicly learning about how to use RISE as it really lowers the threshold about how to solve and estimate Markov-DSGE model. This is very good for beginners, thanks!

Now I am trying to run several examples included in the RISE and encountered some problems. Here they are:

(1)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/TaoZha/Tutorials/DSGE/Tutorial1

The results are:
....
Regime 2 : const = 1 & nk = 2
PAI R X ZD ZS
________ _______ ________ ____ ______

R{-1}     -0.70877    0.34035    -0.60807       0         0
ZD{-1}      1.6535     0.5933      1.2358    0.68         0
ZS{-1}      2.2564    0.70276     0.11434       0      0.82
ED         0.65652    0.23558      0.4907    0.27         0
ER         -0.2717    0.13047    -0.23309       0         0
ES          2.3943     0.7457     0.12133       0    0.8701
          ________    _______    ________    ____    ______

            PAI          R          X         ZD       ZS  

Error using isfield
Too many input arguments.

Error in dsge/print_solution (line 91)
if ~isfield(obj.solution,'Tz')||isempty(obj.solution.Tz{1})

Error in howto (line 71)
print_solution(m)

(2)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/TaoZha/Tutorials/DSGE/Tutorial3

The results are:

List of issues

none
--------------------------------------------------------------
----------- MCMC for svar_constant model-------------
--------------------------------------------------------------
Undefined function or variable 'posterior_simulator'.

Error in howto (line 121)
[obj{imod},postSims{imod}]=posterior_simulator(estim_models{imod},'mcmc_number_of_simulations',...

(3)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/MarkovSwitching/FarmerWaggonerZha2010

The results are:

Parameterization ::1, solver ::mfi

MODEL HAS NOT BEEN SOLVED AT LEAST UP TO THE FIRST ORDER
SOLVER :: mfi
Reference to non-existent field 'Tz'.

Error in dsge/print_solution>print_solution_engine/build_printing_array (line 211)
Tz=obj.solution.(Tzname){regime_index}(ids,:).';

Error in dsge/print_solution>print_solution_engine (line 152)
build_printing_array(ii,myprologue);

Error in dsge/print_solution (line 102)
print_solution_engine(obj(iobj),varlist,compact_form,orders);

Error in howto (line 62)
eval(['models_with_solver_',int2str(solver),'(ii,1).print_solution'])

(4)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/PeterIreland/Endogenous_JME2003

The results are:

none
file2blocks:: (gentle warning): I is also a matlab function
file2blocks:: (gentle warning): MU is also a matlab function
file2blocks:: (gentle warning): beta is also a matlab function
file2blocks:: (gentle warning): alpha is also a matlab function
Error using parser.capture_equations/capture_equations_engine (line 124)
capture_equations:: attributes to model block no longer permitted in file
emosp_linear at line 23

Error in parser.capture_equations (line 58)
[block,equation]=capture_equations_engine(block,listing(ii,:),block_name,equation);

Error in parser.parse_model (line 25)
[Model_block,dictionary]=parser.capture_equations(dictionary,blocks(current_block_id).listing,'model');

Error in parser.parse (line 195)
[Model_block,dictionary,blocks]=parser.parse_model(dictionary,blocks);

Error in dsge (line 320)
dictionary=parser.parse(model_filename,cmfArgins{:});

Error in rise (line 64)
obj=obj@dsge(varargin{:});

Error in master (line 59)
ml=rise('emosp_linear','rise_flags',{'original',true});

(5)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/PeterIreland/NKperspective_JMCB2011

The results are:

Error using generic/set/set_one_at_a_time (line 232)
forecast_start_date' is not a settable option or property of class rise

Error in generic/set (line 178)
set_one_at_a_time();

Error in dsge/set (line 132)
obj=set@generic_switch(obj,varargin{:});

Error in generic/forecast (line 107)
obj=set(obj,varargin{:});

Error in master (line 115)
fkst=forecast(mest,'data',pageify(serials(2)-1,db),...

(6)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/PeterIreland/productivity_RED2008

The results are:

Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.

Error in
parser.preparse>process_flow_controls/process_flow_control_engine/do_for/update_set
(line 324)
sset=info.set;

Error in parser.preparse>process_flow_controls/process_flow_control_engine/do_for
(line 308)
update_set()

Error in parser.preparse>process_flow_controls/process_flow_control_engine (line
289)
do_for()

Error in parser.preparse>process_flow_controls (line 279)
process_flow_control_engine()

Error in parser.preparse>preparse_expand (line 140)
[rawfile,has_macro]=process_flow_controls(rawfile,definitions,has_macro);

Error in parser.preparse (line 105)
[output,has_macro]=preparse_expand(RawFile,parsing_definitions);

Error in parser.parse (line 137)
RawFile=parser.preparse(FileName,DefaultOptions.rise_flags);

Error in dsge (line 320)
dictionary=parser.parse(model_filename,cmfArgins{:});

Error in rise (line 64)
obj=obj@dsge(varargin{:});

Error in master (line 6)
m=rise('pdk','rise_flags',{'Sektors',{'C','I'}},...

(7)/Users/zhuzixiang/Desktop/RISE_toolbox-master/examples/VariousModels/PeterIreland/sgusea_JEEA2013

The results are:

Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.

Error in
parser.preparse>process_flow_controls/process_flow_control_engine/do_for/update_set
(line 324)
sset=info.set;

Error in parser.preparse>process_flow_controls/process_flow_control_engine/do_for
(line 308)
update_set()

Error in parser.preparse>process_flow_controls/process_flow_control_engine (line 289)
do_for()

Error in parser.preparse>process_flow_controls (line 279)
process_flow_control_engine()

Error in parser.preparse>preparse_expand (line 140)
[rawfile,has_macro]=process_flow_controls(rawfile,definitions,has_macro);

Error in parser.preparse (line 105)
[output,has_macro]=preparse_expand(RawFile,parsing_definitions);

Error in parser.parse (line 137)
RawFile=parser.preparse(FileName,DefaultOptions.rise_flags);

Error in dsge (line 320)
dictionary=parser.parse(model_filename,cmfArgins{:});

Error in rise (line 64)
obj=obj@dsge(varargin{:});

Error in master12 (line 17)
m=rise('sgusea12',...

That's all.

Best

Zixiang Zhu

Initial values for solving the steady state

Hi!

I'm running the example with initial values for solving the steady state in a separate file (RISE_toolbox/examples/NonlinearModels/), but I get the error below when trying to solve the model. Is there a bug, or am I doing something wrong?

Best,

Tord

************************** ERROR MESSAGE *****************************

Undefined function or variable "nvar".

Error in locate_variables (line 40)
IDs=nan(nvar,1);

Error in dsge/compute_steady_state>prepare_steady_state_program (line 947)
locs=locate_variables(updated_param_list,obj.parameters.name);

Error in dsge/compute_steady_state (line 129)
[obj,sscode,blocks,unsolved]=prepare_steady_state_program(obj);

Error in dsge/solve/solve_zeroth_order (line 594)
[obj,structural_matrices,retcode]=compute_steady_state(obj);

Error in dsge/solve (line 313)
retcode=solve_zeroth_order();

DSGE:Tutorial 1

Hello everyone, I need explanation on how Tao Zha Tutorial 1 under DSGE brought in his Data into the program. Reading the code I could not get the section. Please provide help as it very crucial for my Msc thesis.

On finding a solution to RS-DSGE with analytical steady state

Dear Junior,
I am working with a RS-DSGE model and using a steady state file where I have analytically computed the model’s steady states (the model has 2 steady states, determined by the switching parameters). However, RISE does not find a solution when using any of the algorithms for regime switching models. It only solves the model when using the “rise_1” algorithm. If I use any other algorithm, the “solve” function will run and the “solution” structure that RISE produces will have the “ss” structure containing the steady state values of all variables in both regimes; however, the “Tz” structure is not created.
The model files are attached. Do you have any idea on what could be causing the problem and possible ways to get around this?
Many thanks,
Martin
cmr_model_rise.zip

Confidence bands for IRF's

Hi Junior,

I couldn't find a built-in function in RISE to generate confidence bands for IRF's in estimated models. Am I missing it or is this something that has not been incorporated yet into RISE?

Many thanks in advance,

Semih

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.