Matrix is singular_deterministic model_with external SS

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Matrix is singular_deterministic model_with external SS

Postby leonard007 » Tue Nov 29, 2016 6:43 pm

Dear Professor Pfeifer,
I am coding a tax policy model on housing and intermediary(Something like ALPAND,ZUBAIRY 2015). I found the steady state in an external file and put them as intval; into Dynare. I want to shock my model and change deductibility of tax on housing by changing I_m=1 to I_m=1.1; ( uploaded file : H_7_deterministic) But unfortunately I get the error :
Simulation terminated with NaN or Inf in the residuals or endogenous variables. There is most likely something wrong with your model.
. My external steady stead file can find perfectly the new steady state.hence I tried to use endval; and put the new steady states in this block. Now Dynare can find the steady state but I get still the same error. ( uploaded file : H_8_deterministic with endval;).
I use
Code: Select all
"model_diagnostics(M_,options_,oo_)"
but there is no result. when there is no shock every thing work well.
What do you think about this error and what could I deal with it?
PS: the extension .mat is not allowed to upload here so I probably you could not be able to run the codes. What I can do?

Sincerely,
Attachments
H_8_deterministic.mod
(6.92 KiB) Downloaded 69 times
H_7_deterministic.mod
(6.41 KiB) Downloaded 77 times
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm

Re: Matrix is singular_deterministic model_with external SS

Postby jpfeifer » Tue Nov 29, 2016 9:29 pm

Pleae upload everything into one zip-file. Also note that 10 periods is not sufficient to have the model converge back to steady state.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Matrix is singular_deterministic model_with external SS

Postby leonard007 » Tue Nov 29, 2016 11:02 pm

Thank you.
Actually at first I put 1000 periods, but I change to 10 just to check it works or not(because after 3 iterations there is the error), but the goal is 1000 period.
I attach all file here. H_7 has a shock for 10 periods, and H_8 has a permanent shock with endval; and new steady state.

Sincerely,
Attachments
Dynar.zip
(8.36 KiB) Downloaded 81 times
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm

Re: Matrix is singular_deterministic model_with external SS

Postby jpfeifer » Thu Dec 01, 2016 4:14 pm

With the unstable version, you can simply go for brute force:
Code: Select all
perfect_foresight_setup(periods=100);
options_.simul.robust_lin_solve=1;
perfect_foresight_solver(stack_solve_algo =0);

That worked in my case.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Matrix is singular_deterministic model_with external SS

Postby leonard007 » Fri Dec 02, 2016 4:44 pm

Dear Professor jpfeifer,
Thank you. It works with the unstable version. I just replaced simul; with your codes. Just for check could you please check that it is correct.
I have some question. Why the results for H_7 (with shock block and shock for period 1:100) is different with a result with a permanent shock and endval;( in H_8 for the same period). and in your opinion which one is more reliable?
also when I change the number of period to more than 100 i.g 500 or 1000, applicably it takes lots of time and sometimes there is an error. Is it normal?

In the next level, I would like to change the model to stochastic one with a stochastic shock on government expenditure, would you think I could use the same method to avoid singularity?

Sincerely,
Attachments
Dynar.zip
(7.52 KiB) Downloaded 104 times
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm

Re: Matrix is singular_deterministic model_with external SS

Postby jpfeifer » Fri Dec 02, 2016 8:20 pm

It looks OK to me. The one with endval is correct. What Dynare does under perfect foresight is solve a system of N equations for T periods in N*T variables. You also need initial and terminal conditions for backward and forward-looking variables. You set those with initval and endval. In the first mod-file with the shocks-block, you set a permanent shock, but you don't set the necessary terminal condition for all other variables that depend on this shock. That is what the endval block does in the second file.

If you go to a stochastic model, the solution technique is completely different and the set of potential problems is also very different.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Matrix is singular_deterministic model_with external SS

Postby leonard007 » Sat Dec 03, 2016 9:51 pm

Dear Professor Jpfeifer,
Your answer was so effective. Thanks a lot for your great help.
Sincerely,
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm

Re: Matrix is singular_deterministic model_with external SS

Postby leonard007 » Thu Dec 08, 2016 4:12 pm

Dear Professor Jpfeifer,
If you remember I tried to plot Perfect foresight solution between two initval; and endval; block. When I plot the IRFs, always there is a very big jump from the initial steady state at time 0 and the next point in the path at time 1. avoiding this big jump, I have added a adjustment cost to the model in the regular form ((psi/2)(X-X(-1))^2/X_bar (Iacoviello 2014)) for budget constraint of households and bank asset (Equ # 5,6,9 that affect also their optimal condition equations).
The problem is even this adjustment cost could not help Dynar find a smooth path unless I choses very big "psi". I am interested to see the permanent shocks on deductibility of mortgage interest,"I_m" and leverage ratio ,"phi". big "psi" works for I_m, but "psi>1" does not work for phi and dynar gets an error saying it could not find the perfect foresight solution even with the endval;
the attached mod.file is with the high "psi" at line #113,114. If you run the m file RUN_basic_1, you would see the jump that I am talking about(if you choose small psi).
so I would like to know what I could do to have a smooth solution for this perfect foresight model.

Sincerely,
Attachments
Dynar.zip
(5.41 KiB) Downloaded 67 times
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm

Re: Matrix is singular_deterministic model_with external SS

Postby jpfeifer » Thu Dec 08, 2016 7:01 pm

Why do you want it to be smooth? If a shock hits the economy, the endogenous variables will react immediately. That is part of the optimal response. Why should penalizing that jump via additional costs imposed on the model make economic sense?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Matrix is singular_deterministic model_with external SS

Postby leonard007 » Sat Dec 10, 2016 6:31 pm

Thank you for the reply.
Actually The baseline model has the adjustment cost for household and banking system. It is for avoiding the household to change his houses very fast. I have canceled out this adjustment cost to make the model easier for dynare. and Now I need to see that effect on the responses.
Sincerely,
leonard007
 
Posts: 54
Joined: Tue May 26, 2015 12:30 pm


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 4 guests