Matrix is singular_deterministic model_with external SS

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 :

. 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 "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?

H_8_deterministic.mod (6.92 KB)
H_7_deterministic.mod (6.41 KB)

Pleae upload everything into one zip-file. Also note that 10 periods is not sufficient to have the model converge back to steady state.

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, (8.36 KB)

With the unstable version, you can simply go for brute force:

perfect_foresight_setup(periods=100); options_.simul.robust_lin_solve=1; perfect_foresight_solver(stack_solve_algo =0);
That worked in my case.

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, (7.52 KB)

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.

Dear Professor Jpfeifer,
Your answer was so effective. Thanks a lot for your great help.

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, (5.41 KB)

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?

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.