Page 1 of 1

RAMSEY POLICY PROBLEM

PostPosted: Tue Jun 14, 2016 1:52 am
by emarquez
Hi,
I’m having some problems in computing the steady state under optimal policy with ramsey policy. Can you help me, please?
My problem is the following:
1. I have derived by hand the optimal values for the steady state of all endogenous variables (55 variables) given the optimal value of the policy instruments (6 instruments). I have entered these values in the “steady state model” block.
2. I have provided the optimal values of the instruments in the “initval” block. Actually, these values are the steady state values.
3. I have declared the name of the endogenous variables that are the instruments within the ramsey policy command (instruments=()).
4. I ran the .mod file with dynare unstable version: 13-Jun-2016. I’m using the unstable version because I read in the forum that the stable version 4.4.3. has a bug related to auxiliary variables when using instruments. The results I obtain are:

Code: Select all
evaluate_steady_state: The steady state for the Ramsey problem could not be computed.
evaluate_steady_state: The steady state computation stopped with the following instrument values::
    tauIVA_sec2     0.100000
    tauIVA_sec3     0.100000
    tauK_dec2       0.300000
    tauK_dec3       0.300000
    tauL_dec2       0.250000
    tauL_dec3       0.300000
evaluate_steady_state: The following equations have non-zero residuals:
    Auxiliary Ramsey equation number 1: -0.032906
    Auxiliary Ramsey equation number 2: -0.033535
    Auxiliary Ramsey equation number 3: 0.017759
    Auxiliary Ramsey equation number 4: 0.017131
    Auxiliary Ramsey equation number 5: -0.015146
    Auxiliary Ramsey equation number 6: -0.016404
    Auxiliary Ramsey equation number 7: 0.012183
    Auxiliary Ramsey equation number 8: 0.003006
    Auxiliary Ramsey equation number 9: 0.003866
    Auxiliary Ramsey equation number 10: 0.000507
    Auxiliary Ramsey equation number 11: 0.008317
    Auxiliary Ramsey equation number 12: 0.002499
    Auxiliary Ramsey equation number 13: 0.074317
    Auxiliary Ramsey equation number 14: -0.003846
    Auxiliary Ramsey equation number 15: -0.017203
    Auxiliary Ramsey equation number 16: -0.003085
    Auxiliary Ramsey equation number 17: -0.013428
    Auxiliary Ramsey equation number 18: 0.000196
    Auxiliary Ramsey equation number 19: 0.000070
    Auxiliary Ramsey equation number 20: -0.000171
    Auxiliary Ramsey equation number 21: -0.000172
    Auxiliary Ramsey equation number 22: -0.006400
    Auxiliary Ramsey equation number 23: 0.001580
    Auxiliary Ramsey equation number 24: -0.025349
    Auxiliary Ramsey equation number 25: 0.039403
    Auxiliary Ramsey equation number 26: -0.001604
    Auxiliary Ramsey equation number 27: -0.001282
    Auxiliary Ramsey equation number 28: 0.002554
    Auxiliary Ramsey equation number 29: 0.015522
    Auxiliary Ramsey equation number 30: 0.002554
    Auxiliary Ramsey equation number 31: -0.009827
    Auxiliary Ramsey equation number 32: -0.003846
    Auxiliary Ramsey equation number 33: 0.017102
    Auxiliary Ramsey equation number 34: 0.044655
    Auxiliary Ramsey equation number 35: 0.038571
    Auxiliary Ramsey equation number 36: 0.044655
    Auxiliary Ramsey equation number 37: 0.038762
    Auxiliary Ramsey equation number 38: 0.039403
    Auxiliary Ramsey equation number 39: 0.039403
    Auxiliary Ramsey equation number 40: 0.005252
    Auxiliary Ramsey equation number 41: -0.000832
    Auxiliary Ramsey equation number 42: -0.003386
    Auxiliary Ramsey equation number 43: 0.014827
    Auxiliary Ramsey equation number 44: 0.020721
    Auxiliary Ramsey equation number 45: 0.074847
    Auxiliary Ramsey equation number 46: 0.080740
    Auxiliary Ramsey equation number 47: 0.003053
    Auxiliary Ramsey equation number 48: 0.000400
    Auxiliary Ramsey equation number 49: 0.003121
    Auxiliary Ramsey equation number 50: 0.000938
    Auxiliary Ramsey equation number 51: 0.074318
    Auxiliary Ramsey equation number 52: 0.074318
    Auxiliary Ramsey equation number 53: 0.074313
    Auxiliary Ramsey equation number 54: 0.074317
    Auxiliary Ramsey equation number 55: -0.003386
    Equation number 1: 0.049710
    Equation number 2: 0.041753
    Equation number 3: -0.028472
    Equation number 4: -0.028475
    Equation number 5: -0.039529
    Equation number 6: -0.086000


HOWEVER, when I use dynare version 4.4.3 and I (i) set the optimal values for the steady state of all endogenous variables (including the 6 intruments) in the “initval” block instead of setting the optimal values in the “steady state model” block, and (ii) deleting the option “instruments” within the ramsey policy command, Dynare solves the model and reaches the steady state. Nevertheless, the “resid” command reports the following:

Code: Select all
Residuals of the static equations:

Equation number 1 : -0.03276
Equation number 2 : -0.033378
Equation number 3 : 0.017772
Equation number 4 : 0.017153
Equation number 5 : -0.014988
Equation number 6 : -0.016224
Equation number 7 : 0.011865
Equation number 8 : 0.002914
Equation number 9 : 0.0034553
Equation number 10 : 0.00036206
Equation number 11 : 0.0084097
Equation number 12 : 0.0025519
Equation number 13 : 0.0743
Equation number 14 : -0.0040414
Equation number 15 : -0.01709
Equation number 16 : -0.0032417
Equation number 17 : -0.013339
Equation number 18 : 0.0001925
Equation number 19 : 6.8891e-05
Equation number 20 : -0.00016844
Equation number 21 : -0.00016878
Equation number 22 : -0.0064069
Equation number 23 : 0.0015816
Equation number 24 : -0.025375
Equation number 25 : 0.039392
Equation number 26 : -0.0016012
Equation number 27 : -0.0012908
Equation number 28 : 0.0023655
Equation number 29 : 0.015537
Equation number 30 : 0.0023655
Equation number 31 : -0.0098379
Equation number 32 : -0.0040414
Equation number 33 : 0.017119
Equation number 34 : 0.044649
Equation number 35 : 0.038559
Equation number 36 : 0.044649
Equation number 37 : 0.03875
Equation number 38 : 0.039392
Equation number 39 : 0.039392
Equation number 40 : 0.0052569
Equation number 41 : -0.00083322
Equation number 42 : -0.0033918
Equation number 43 : 0.014724
Equation number 44 : 0.020623
Equation number 45 : 0.074932
Equation number 46 : 0.080831
Equation number 47 : 0.0054035
Equation number 48 : 0.00056621
Equation number 49 : 0.0062487
Equation number 50 : 0.0018961
Equation number 51 : 0.0743
Equation number 52 : 0.0743
Equation number 53 : 0.074295
Equation number 54 : 0.074299
Equation number 55 : -0.0033918
Equation number 56 : 0.049704
Equation number 57 : 0.041739
Equation number 58 : -0.028463
Equation number 59 : -0.028466
Equation number 60 : -0.039472
Equation number 61 : -0.08606


I double checked the file “ed3_static.m” after running the 4.4.3 version and I founded the following similarities between the “resid” reports of the unstable and stable dynare versions:
(i) residual(1) to residual(55) equations correspond to the residuals of the Lagrange multipliers of my 55 endogenous variables (equivalent to the “Auxiliary Ramsey equation number 1 to 55”, in the resid report of the unstable version).
(ii) residual(56) to residual(61) equations are the Lagrange multipliers of my instruments (equivalent to “Equation number 1 to 6”, in the resid report of the unstable version).
(iii) residual(62) to residual(116) are the residuals of my 55 model equations. These residuals are zero according to the “ans” report generated in the matlab workspace. Consequently, the optimal values I derived for the steady state of all the endogenous variables (55 variables), given the value of the 6 policy instruments, are correct!. Moreover, when I disable the ramsey policy command and solve my model with the steady command (in both stable and unstable versions) I obtain the optimal steady state, residuals of the static equations are zero, and the rank condition is verified. It is, my initial values are right.
(iv) residual(117) to residual(124) are the residuals of the 8 auxiliary equations (all of them zero according to the “ans” report generated in the matlab workspace) generated by dynare. These equations are included in the “ed3_set_auxiliary_variables.m”

IT’S MY IMPRESSION AND I COULD BE WRONG, THAT THE dynare version 4.4.3 IGNORES THE RESULTS OF THE RESIDUAL EQUATIONS OF THE LAGRANGE MULTIPLIERS, AND ONLY TAKES INTO CONSIDERATION THAT THE RESIDUALS OF ALL ENDOGENOUS VARIABLES ARE ZERO FOR PROVIDING A SOLUTION. IT SEEMS THAT THE OPPOSITE HAPPENS FOR THE UNSTABLE VERSION…

QUESTIONS/HELP:
1. Is there a way of ignoring the residuals of the lagrange multipliers when using the unstable version?, or
2. Is there a way in which dynare can compute/solve with more precision the optimal values of the lagrange multipliers such that their residual equations be zero?

I know that probably one solution could be to use the stable version, set the optimal values of my entire endogenous variables and instruments in the initialval block, set the ramsey policy command without instruments, let that Dynare solves the problem, and don’t pay attention to the residuals of the auxiliary variables… However, I’m going to run a large model and I prefer to reduce computing time when setting the optimal values in the steady state model block, and let Dynare solve the problem with only as many unkowns as there are instruments, rather than solving the model with as many unknowns as there are endogenous variables in the case of setting the optimal values in the initialval block…

Thanks in advance,
Eduardo

ed3.mod
.MOD FILE
(16.85 KiB) Downloaded 138 times


pruebaparams.m
PARAMETERS OF THE MODEL
(3.18 KiB) Downloaded 110 times

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 1:23 am
by emarquez
Hi,
I think I have found the solution to my problem; however, I would like to double check with you… Would you mind to tell me if I’m correct, or if I’m saying something that it doesn’t make sense?

My problem was that I couldn’t obtain the steady state under optimal policy with ramsey policy command when using the dynare unstable version: 13-Jun-2016 and specifying the optimal steady state values of all endogenous variables in the “steady state model” block, and the optimal values of the instruments in the “initval” block.

In contrast, when using dynare 4.4.3. and specifying the optimal steady state values of all endogenous variables, and instrument values, in the “initval” block I was able to find the steady state.

I think the problem is in the “evaluate_steady_state.m” matlab file of the unstable version. Within the section ”%test whether it solves model conditional on the instruments” there is a loop for evaluating the residuals of all variables EXCEPT for the Lagrange multipliers:

Code: Select all
if max(abs(resids(n_multipliers+1:end))) > options.dynatol.f %does it solve for all variables except for the Lagrange multipliers


I don’t know how, but it seems that this loop is including the residuals of the Lagrange multipliers when testing if the optimal values of all endogenous variables, provided in the “steady state model” block, solve the model conditional on the instruments values.

How I know this? Well, I replaced the “evaluate_steady_state.m” of the unstable version by the “evaluate_steady_state.m” file of dynare version 4.4.3. Result: it works.

However, when I type the “resid” command after solution, I obtain the following report:

Code: Select all
Residuals of the static equations:

Equation number 1 : -0.032906
Equation number 2 : -0.033535
Equation number 3 : 0.017759
Equation number 4 : 0.017131
Equation number 5 : -0.015146
Equation number 6 : -0.016404
Equation number 7 : 0.012183
Equation number 8 : 0.0030062
Equation number 9 : 0.0038661
Equation number 10 : 0.00050685
Equation number 11 : 0.0083168
Equation number 12 : 0.0024993
Equation number 13 : 0.074317
Equation number 14 : -0.0038465
Equation number 15 : -0.017203
Equation number 16 : -0.0030854
Equation number 17 : -0.013428
Equation number 18 : 0.00019581
Equation number 19 : 7.0083e-05
Equation number 20 : -0.00017133
Equation number 21 : -0.0001717
Equation number 22 : -0.0064003
Equation number 23 : 0.0015799
Equation number 24 : -0.025349
Equation number 25 : 0.039403
Equation number 26 : -0.0016035
Equation number 27 : -0.0012816
Equation number 28 : 0.0025538
Equation number 29 : 0.015522
Equation number 30 : 0.0025538
Equation number 31 : -0.0098272
Equation number 32 : -0.0038465
Equation number 33 : 0.017102
Equation number 34 : 0.044655
Equation number 35 : 0.038571
Equation number 36 : 0.044655
Equation number 37 : 0.038762
Equation number 38 : 0.039403
Equation number 39 : 0.039403
Equation number 40 : 0.0052515
Equation number 41 : -0.00083236
Equation number 42 : -0.0033858
Equation number 43 : 0.014827
Equation number 44 : 0.020721
Equation number 45 : 0.074847
Equation number 46 : 0.08074
Equation number 47 : 0.0030534
Equation number 48 : 0.0004003
Equation number 49 : 0.0031209
Equation number 50 : 0.00093787
Equation number 51 : 0.074318
Equation number 52 : 0.074318
Equation number 53 : 0.074313
Equation number 54 : 0.074317
Equation number 55 : -0.0033858
Equation number 56 : 0.04971
Equation number 57 : 0.041753
Equation number 58 : -0.028472
Equation number 59 : -0.028475
Equation number 60 : -0.039529
Equation number 61 : -0.086


I’m pretty sure that these values correspond to the residuals of the Lagrange multipliers equations. It is my impression that dynare displays the max absolute value between the residual of equation x and the corresponding lagrange multiplier residual for equation x. However, the report doesn’t specify if the residual comes from the Auxiliary variable (multiplier) or from the residual of equation x; instead, it always displays: “Equation number x”. To be honest, I don’t know if it is a real bug and if it might happens in the “resid.m” file or in the “evaluate_steady_state.m” file

Summarizing, do you think there could be a bug (in the unstable version when testing whether the “steady state model” block solves the model and in both versions when using the “resid” command) or I’m totally out of order?

Thanks,
Eduardo

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 9:38 am
by jpfeifer
Dear Eduardo,
thanks for reporting this. We will look into it. Note that
Code: Select all
resid
is generally not suitable for Ramsey.

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 9:49 am
by jpfeifer
Dear Eduardo,
are you sure your steady_state_model is valid for all values of the instruments. When I set
Code: Select all
tauL_dec3=0.5;          //POLICY INSTRUMENT

I get
evaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.
evaluate_steady_state: Conditional on the following instrument values:
tauIVA_sec2 0.100000
tauIVA_sec3 0.100000
tauK_dec2 0.300000
tauK_dec3 0.300000
tauL_dec2 0.250000
tauL_dec3 0.500000
evaluate_steady_state: the following equations have non-zero residuals:
Equation number 23: 2.000000
Equation number 24: 2.000000
Equation number 33: -11.884216
Equation number 34: -1.715784
Equation number 35: 12.240000
Equation number 36: 1.360000

Moreover, with the values you provide, I get

> In dyn_ramsey_static>dyn_ramsey_static_1 (line 152)
In dyn_ramsey_static>@(x)dyn_ramsey_static_1(x,M,options_,oo) (line 43)
In dyn_ramsey_static (line 70)
In evaluate_steady_state (line 120)
In resol (line 104)
In stoch_simul (line 83)
In ramsey_policy (line 25)
In ed3 (line 1034)
In dynare (line 223)
Warning: Rank deficient, rank = 54, tol = 3.517636e-12.

after which the error message your report appears. Therefore it seems the steady state of the Ramsey problem cannot be found. Dynare 4.4.3 did not check whether a solution was actually found.

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 7:19 pm
by emarquez
Hello Johannes,

Thanks so much for your quick response!

Yes, I'm sure the model works for all values of the instruments. However, when you want to change the value of one instrument is necessary to (i) disable the “steady_state_model” block and (ii)change the instruments from the “variables” block to the “varexo” block.

I changed “tauL_dec3=.5” and dynare obtains the following steady state:

Code: Select all
STEADY-STATE RESULTS:

L_dec2_sec2               48.1495
L_dec2_sec3               48.1495
L_dec3_sec2               19.8828
L_dec3_sec3               47.8828
LS_sec2                   68.0323
LS_sec3                   96.0323
KS_sec2                   77.7512
KS_sec3                   39.1969
K_dec2_sec2               8.70724
K_dec2_sec3               19.2842
K_dec3_sec2               69.044
K_dec3_sec3               19.9127
PK                        1.83487
XS_sec2                   181.743
XS_sec3                   173.25
VA_sec2                   145.783
VA_sec3                   135.229
W_sec2                    1
W_sec3                    1
R_sec2                    1
R_sec3                    1
E_sec2                    8.125
E_sec3                    75.925
M_sec3                    30
ER                        1
V_sec2                    21.5021
V_sec3                    24.3776
D_sec2                    173.618
D_sec3                    100.875
X_sec2                    173.618
X_sec3                    130.875
XD_sec2                   181.743
XD_sec3                   176.8
PD_sec2                   1
PD_sec3                   1
P_sec2                    1
P_sec3                    1
PM_sec2                   1
PM_sec3                   1
PWE_sec2                  1
PWE_sec3                  1
ZG                        121.143
c_dec2_sec2               4.00376
c_dec2_sec3               2.06842
c_dec3_sec2               3.49336
c_dec3_sec3               1.29614
I_dec2_sec2               6.78893
I_dec2_sec3               15.0356
I_dec3_sec2               25.2113
I_dec3_sec3               7.27109
rho_dec3_sec2             1.83487
rho_dec3_sec3             1.83487
rho_dec2_sec2             1.83487
rho_dec2_sec3             1.83487
TR_dec1                   10.9432

Approximated value of planner objective function
    - with initial Lagrange multipliers set to 0: 531.293
    - with initial Lagrange multipliers set to steady state: 531.293


Thanks,
Eduardo

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 7:36 pm
by jpfeifer
I was explicitly referring to the steady_state_model-block, not the model. Whatever you put for the instruments into initval, the steady_state_model-block must deliver the correct steady state. What you describe with using initval just means Dynare is able to compute the steady state numerically.

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 8:01 pm
by emarquez
Sorry for my mistake, I misunderstood your question… I just run the model with tauL_dec3=.5, and you are right the steady_state_model-block delivers the correct steady state. It is the result:

Code: Select all
STEADY-STATE RESULTS:

L_dec2_sec2               50
L_dec2_sec3               50
L_dec3_sec2               20
L_dec3_sec3               48
LS_sec2                   70
LS_sec3                   98
KS_sec2                   80
KS_sec3                   40
K_dec2_sec2               20
K_dec2_sec3               20
K_dec3_sec2               60
K_dec3_sec3               20
PK                        1.83487
XS_sec2                   187
XS_sec3                   176.8
VA_sec2                   150
VA_sec3                   138
W_sec2                    1
W_sec3                    1
R_sec2                    1
R_sec3                    1
E_sec2                    8.125
E_sec3                    75.925
M_sec3                    30
ER                        1
V_sec2                    22
V_sec3                    25
D_sec2                    178.875
D_sec3                    100.875
X_sec2                    178.875
X_sec3                    130.875
XD_sec2                   187
XD_sec3                   176.8
PD_sec2                   1
PD_sec3                   1
P_sec2                    1
P_sec3                    1
PM_sec2                   1
PM_sec3                   1
PWE_sec2                  1
PWE_sec3                  1
ZG                        123.8
c_dec2_sec2               3.68888
c_dec2_sec3               1.75354
c_dec3_sec2               3.80666
c_dec3_sec3               1.60944
I_dec2_sec2               15.5938
I_dec2_sec3               15.5938
I_dec3_sec2               21.9089
I_dec3_sec3               7.30298
rho_dec3_sec2             1.83487
rho_dec3_sec3             1.83487
rho_dec2_sec2             1.83487
rho_dec2_sec3             1.83487
TR_dec1                   13.6
tauIVA_sec2               0.1
tauIVA_sec3               0.1
tauK_dec2                 0.3
tauK_dec3                 0.3
tauL_dec2                 0.25
tauL_dec3                 0.5

Approximated value of planner objective function
    - with initial Lagrange multipliers set to 0: 521.8321
    - with initial Lagrange multipliers set to steady state: 523.2493



Attached you will find the file again

Thanks for your help!,
Eduardo

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 9:33 pm
by jpfeifer
When i run your file on the unstable version, it says
evaluate_steady_state: the following equations have non-zero residuals:
Equation number 23: 2.000000
Equation number 24: 2.000000
Equation number 33: -11.884216
Equation number 34: -1.715784
Equation number 35: 12.240000
Equation number 36: 1.360000

Dynare 4.4.3 did not check for correctness of the provided values. The unstable version does. And the latter complains that your steady_state_file is not correct. So how did you obtain the above results in your last post?

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 10:13 pm
by emarquez
I'm obtaining these results when I replaced the “evaluate_steady_state.m” of the unstable version with the “evaluate_steady_state.m” file of dynare version 4.4.3.

What I think, and I might be wrong, is that the “evaluate_steady_state.m” of the unstable version is evaluating the residuals of the Lagrange multipliers when testing if the values provided in the “steady state model” block solve the model conditional on the instruments values, and this shouldn't happen. Again, probably I'm wrong....

In section ”%test whether it solves model conditional on the instruments” of the “evaluate_steady_state.m” there is a loop for evaluating the residuals of all variables EXCEPT for the Lagrange multipliers:

Code: Select all
if max(abs(resids(n_multipliers+1:end))) > options.dynatol.f %does it solve for all variables except for the Lagrange multipliers


When I replace the .m file the model works. Actually, if you don't replace the “evaluate_steady_state.m” file of the unstable version, but changes the "options.dynatol.f" to "options_.dynatol.f = 1e-1;" in the "global_initialization.m" the model will work too.

Please let me know if you obtain the same results after replacing the .m file in the unstable version or by changing the "options.dynatol.f"

Again, thanks for helping me in this issue,
Eduardo

Re: RAMSEY POLICY PROBLEM

PostPosted: Wed Jun 15, 2016 10:41 pm
by jpfeifer
As I said: replacing the evaluate_steady_state-file is not a good idea. There was a reason we changed the file, because incorrect values could be accepted as steady states. Setting the tolerance to a large number has the same effect: you are accepting a non-steady state as the steady state. Do you have good reason to believe there is a bug here, because I think the current behavior is correct and your steady_state_model-block is wrong. To see this, fix the instruments to their initval-values in the model-block. This model should have the same steady state for the endogenous variables as the Ramsey-model. But when I use your steady_state-file, Dynare complains.
I use
Code: Select all
// THIS MODEL IS “ed3.mod”
 
 
//VARIABLES, PARAMETERS AND EXOGENOUS VARIABLES DECLARATION

//------------------------- 
// A) VARIABLES
//-------------------------
var
L_dec2_sec2 L_dec2_sec3 L_dec3_sec2 L_dec3_sec3 LS_sec2 LS_sec3 KS_sec2 KS_sec3 K_dec2_sec2 K_dec2_sec3 K_dec3_sec2 K_dec3_sec3  PK XS_sec2 XS_sec3 VA_sec2 VA_sec3 W_sec2 W_sec3 R_sec2 R_sec3 E_sec2 E_sec3 M_sec3 ER V_sec2 V_sec3 D_sec2 D_sec3 X_sec2 X_sec3 XD_sec2 XD_sec3 PD_sec2 PD_sec3 P_sec2 P_sec3 PM_sec2 PM_sec3 PWE_sec2 PWE_sec3 ZG

c_dec2_sec2 c_dec2_sec3 c_dec3_sec2 c_dec3_sec3
I_dec2_sec2 I_dec2_sec3 I_dec3_sec2 I_dec3_sec3
rho_dec3_sec2 rho_dec3_sec3
rho_dec2_sec2 rho_dec2_sec3
 
TR_dec1

///////////////////////////////////////////////////////////////////////////////////////
tauIVA_sec2 tauIVA_sec3 tauK_dec2 tauK_dec3 tauL_dec2 tauL_dec3    //POLICY INSTRUMENTS
///////////////////////////////////////////////////////////////////////////////////////

;
 
//-----------------------------------------------------------
// B) EXOGENOUS VARIABLES.
//-----------------------------------------------------------
varexo
epsG


;
 

//----------------------------------------------------------------
// C) PARAMETERS.
//----------------------------------------------------------------
parameters
gamma_dec2_sec2 gamma_dec2_sec3 gamma_dec3_sec2 gamma_dec3_sec3 beta_dec2_sec2 beta_dec2_sec3 beta_dec3_sec2 beta_dec3_sec3 betatilde_dec2 betatilde_dec3 delta_dec2 delta_dec3 phi_ME phi_C sigma_sec2 sigma_sec3 mu_sec2 mu_sec3 b_sec2 b_sec3 va_sec2 va_sec3 c_sec2 c_sec3 a_sec2_secB2 a_sec3_secB2 a_sec2_secB3 a_sec3_secB3 alpha_sec2 alpha_sec3 psi_dec2 psi_dec3 N_dec2_sec2 N_dec2_sec3 N_dec3_sec2 N_dec3_sec3 G_sec2 G_sec3 Phat_sec2 Phat_sec3 Ehat_sec2 Ehat_sec3 Fhat eta_sec2 eta_sec3 M_sec2 tauM_sec2 tauM_sec3 s_sec2 s_sec3

pi_dec2
pi_dec3

rhoG
sigmaG

;


//--------------------------
// D) CALIBRATION
//--------------------------

pi_dec2=.5;               // SOCIAL PLANNER WEIGHT OR FAVOURITISM TOWARDS DECILE2 AGENTS
pi_dec3=.5;               // SOCIAL PLANNER WEIGHT OR FAVOURITISM TOWARDS DECILE3 AGENTS
 
rhoG = 0.96;                // demand-side shock persistence
sigmaG = 0.1;               // demand-side shock standard deviation

//

load pruebaparams;
set_param_value('a_sec2_secB2',a_sec2_secB2)
set_param_value('a_sec2_secB3',a_sec2_secB3)
set_param_value('a_sec3_secB2',a_sec3_secB2)
set_param_value('a_sec3_secB3',a_sec3_secB3)
set_param_value('alpha_sec2',alpha_sec2)
set_param_value('alpha_sec3',alpha_sec3)
set_param_value('b_sec2',b_sec2)
set_param_value('b_sec3',b_sec3)
set_param_value('beta_dec2_sec2',beta_dec2_sec2)
set_param_value('beta_dec2_sec3',beta_dec2_sec3)
set_param_value('beta_dec3_sec2',beta_dec3_sec2)
set_param_value('beta_dec3_sec3',beta_dec3_sec3)
set_param_value('betatilde_dec2',betatilde_dec2)
set_param_value('betatilde_dec3',betatilde_dec3)
set_param_value('c_sec2',c_sec2)
set_param_value('c_sec3',c_sec3)
set_param_value('delta_dec2',delta_dec2)
set_param_value('delta_dec3',delta_dec3)
set_param_value('gamma_dec2_sec2',gamma_dec2_sec2)
set_param_value('gamma_dec2_sec3',gamma_dec2_sec3)
set_param_value('gamma_dec3_sec2',gamma_dec3_sec2)
set_param_value('gamma_dec3_sec3',gamma_dec3_sec3)
set_param_value('mu_sec2',mu_sec2)
set_param_value('mu_sec3',mu_sec3)
set_param_value('phi_C',phi_C)
set_param_value('phi_ME',phi_ME)
set_param_value('va_sec2',va_sec2)
set_param_value('va_sec3',va_sec3)

psi_dec2=2;
psi_dec3=2;
sigma_sec2=1.2;
sigma_sec3=1.2;
N_dec2_sec2=55;
N_dec2_sec3=55;
N_dec3_sec2=25;
N_dec3_sec3=53;
G_sec2=55.1;
G_sec3=55.1;
Phat_sec2=1;
Phat_sec3=1;
Ehat_sec2=8.125;
Ehat_sec3=75.925;
Fhat=-54.05;
eta_sec2=0.15;
eta_sec3=0.025;
M_sec2=0;
tauM_sec2=0;
tauM_sec3=0;
s_sec2=0;
s_sec3=0;
 
 

 
//-------------------------------------------
// E) MODEL EQUATIONS
//-------------------------------------------
 
model;

#C_dec2_sec2 = exp(c_dec2_sec2);         //estamos asignando variable auxiliar
#C_dec2_sec3 = exp(c_dec2_sec3);         //estamos asignando variable auxiliar
#C_dec3_sec2 = exp(c_dec3_sec2);         //estamos asignando variable auxiliar
#C_dec3_sec3 = exp(c_dec3_sec3);         //estamos asignando variable auxiliar
 
 
 
// PRICE SYSTEM
 
PM_sec2 = Phat_sec2*(1+ tauM_sec2)*ER;
 
PM_sec3 = Phat_sec3*(1+ tauM_sec3)*ER;
 
//
 
PWE_sec2= (PD_sec2/((1+ s_sec2)*ER));
 
PWE_sec3= (PD_sec3/((1+ s_sec3)*ER));
 
//
 
PD_sec2 = ((va_sec2*(1+tauIVA_sec2))/(c_sec2))*(((R_sec2/alpha_sec2)^alpha_sec2)*(( W_sec2/(1- alpha_sec2))^(1- alpha_sec2))) + ( a_sec2_secB2*P_sec2 + a_sec2_secB3*P_sec3);
 
PD_sec3 = ((va_sec3*(1+tauIVA_sec3))/(c_sec3))*(((R_sec3/alpha_sec3)^alpha_sec3)*(( W_sec3/(1- alpha_sec3))^(1- alpha_sec3))) + ( a_sec3_secB2*P_sec2 + a_sec3_secB3*P_sec3);
 
//
 
//Psec2 equation has been modified because imports are zero for this sector
P_sec2 = (1/b_sec2)*(PD_sec2 / ((1-mu_sec2)^(sigma_sec2/(sigma_sec2 - 1))));
 
P_sec3 = (1/b_sec3)*((PD_sec3 + PM_sec3*(((mu_sec3/(1-mu_sec3))*(PD_sec3/PM_sec3))^sigma_sec3))/(((1-mu_sec3)+mu_sec3*(((mu_sec3/(1- mu_sec3))*( PD_sec3/PM_sec3))^(sigma_sec3-1)))^(sigma_sec3/(sigma_sec3-1))));
 
 
 
 
// INTERMEDIATE DEMAND
 
V_sec2 = a_sec2_secB2*XS_sec2 + a_sec3_secB2*XS_sec3;
 
V_sec3 = a_sec2_secB3*XS_sec2 + a_sec3_secB3*XS_sec3;
 
 
// FOREIGN SECTOR EQUATIONS
 
E_sec2 = Ehat_sec2*(((Phat_sec2)/(PWE_sec2))^eta_sec2);
 
E_sec3 = Ehat_sec3*(((Phat_sec3)/(PWE_sec3))^eta_sec3);
 
//
 
//M_sec2 is a parameter. Imports are always zero.
 
M_sec3=(X_sec3/b_sec3)*((mu_sec3/ PM_sec3)^(sigma_sec3))*((mu_sec3^sigma_sec3)*(PM_sec3^(1- sigma_sec3))+ ((1- mu_sec3)^sigma_sec3)*(PD_sec3^(1- sigma_sec3)))^(sigma_sec3/(1- sigma_sec3));
 
//
 
(Phat_sec2*M_sec2 + Phat_sec3*M_sec3) - (PWE_sec2*E_sec2 + PWE_sec3*E_sec3) =  Fhat;
 
 
// EQUILIBRIUM IN MARKET OF GOODS
 
 
//Dsec2 equation has been modified because imports are zero for this sector
D_sec2 = XS_sec2 - E_sec2;
 
D_sec3=(X_sec3/b_sec3)*(((1-mu_sec3)/ PD_sec3)^(sigma_sec3))*((mu_sec3^sigma_sec3)*(PM_sec3^(1- sigma_sec3))+((1- mu_sec3)^sigma_sec3)*(PD_sec3^(1- sigma_sec3)))^(sigma_sec3/(1- sigma_sec3));
 
//
 
 
//Xsec2 equation has been modified because imports are zero for this sector
X_sec2 = b_sec2*((1-mu_sec2)^(sigma_sec2/(sigma_sec2-1)))*D_sec2;
 
X_sec3 = b_sec3*(mu_sec3* (M_sec3^(( sigma_sec3-1)/ sigma_sec3)) + (1-mu_sec3)* (D_sec3^(( sigma_sec3-1)/ sigma_sec3)))^(sigma_sec3/(sigma_sec3-1));
 
//
 
XD_sec2 = (D_sec2 + E_sec2);
 
XD_sec3 = (D_sec3 + E_sec3);
 
 
 
// CONSUMER EQUATIONS
 
// Labor supply
 
L_dec2_sec2 = N_dec2_sec2-(((1-gamma_dec2_sec2)/gamma_dec2_sec2)*(P_sec2*C_dec2_sec2/((1- tauL_dec2)*W_sec2)));
 
L_dec2_sec3 = N_dec2_sec3-(((1-gamma_dec2_sec3)/gamma_dec2_sec3)*(P_sec3*C_dec2_sec3/((1- tauL_dec2)*W_sec3)));
 
//
 
L_dec3_sec2 = N_dec3_sec2-(((1-gamma_dec3_sec2)/gamma_dec3_sec2)*(P_sec2*C_dec3_sec2/((1- tauL_dec3)*W_sec2)));
 
L_dec3_sec3 = N_dec3_sec3-(((1-gamma_dec3_sec3)/gamma_dec3_sec3)*(P_sec3*C_dec3_sec3/((1- tauL_dec3)*W_sec3)));
 
 
// Decisions about intertemporal consumption-investment.
 
rho_dec2_sec2(+1)*I_dec2_sec2=(betatilde_dec2)*I_dec2_sec2(-1)*((1-tauK_dec2(+1))*R_sec2(+1)+(1-delta_dec2)* rho_dec2_sec2(+1));
 
rho_dec2_sec3(+1)*I_dec2_sec3=(betatilde_dec2)*I_dec2_sec3(-1)*((1-tauK_dec2(+1))*R_sec3(+1)+(1-delta_dec2)* rho_dec2_sec3(+1));
 
//
 
rho_dec3_sec2(+1)*I_dec3_sec2=(betatilde_dec3)*I_dec3_sec2(-1)*((1-tauK_dec3(+1))*R_sec2(+1)+(1-delta_dec3)* rho_dec3_sec2(+1));
 
rho_dec3_sec3(+1)*I_dec3_sec3=(betatilde_dec3)*I_dec3_sec3(-1)*((1-tauK_dec3(+1))*R_sec3(+1)+(1-delta_dec3)* rho_dec3_sec3(+1));
 
 
//Equilibrium condition for investment decision
 
 
(rho_dec2_sec2 - rho_dec2_sec2*((psi_dec2)/2)*((((betatilde_dec2/rho_dec2_sec2)*(rho_dec2_sec2*(1- delta_dec2)+( 1- tauK_dec2)*R_sec2))-1)^2) - rho_dec2_sec2*((betatilde_dec2/rho_dec2_sec2)*(rho_dec2_sec2*(1- delta_dec2)+( 1- tauK_dec2)*R_sec2))*(psi_dec2)*(((betatilde_dec2/rho_dec2_sec2)*(rho_dec2_sec2*(1- delta_dec2)+( 1- tauK_dec2)*R_sec2))-1)) + (rho_dec2_sec2/(rho_dec2_sec2(+1)*(1-delta_dec2)+(1-tauK_dec2(+1))*R_sec2(+1)))*(rho_dec2_sec2(+1)*(((betatilde_dec2/rho_dec2_sec2(+1))*(rho_dec2_sec2(+1)*(1- delta_dec2)+( 1- tauK_dec2(+1))*R_sec2(+1)))^2)*(psi_dec2)*(((betatilde_dec2/rho_dec2_sec2(+1))*(rho_dec2_sec2(+1)*(1- delta_dec2)+( 1- tauK_dec2(+1))*R_sec2(+1)))-1))=PK;
 
(rho_dec2_sec3 - rho_dec2_sec3*((psi_dec2)/2)*((((betatilde_dec2/rho_dec2_sec3)*(rho_dec2_sec3*(1- delta_dec2)+( 1- tauK_dec2)*R_sec3))-1)^2) - rho_dec2_sec3*((betatilde_dec2/rho_dec2_sec3)*(rho_dec2_sec3*(1- delta_dec2)+( 1- tauK_dec2)*R_sec3))*(psi_dec2)*(((betatilde_dec2/rho_dec2_sec3)*(rho_dec2_sec3*(1- delta_dec2)+( 1- tauK_dec2)*R_sec3))-1)) + (rho_dec2_sec3/(rho_dec2_sec3(+1)*(1-delta_dec2)+(1-tauK_dec2(+1))*R_sec3(+1)))*(rho_dec2_sec3(+1)*(((betatilde_dec2/rho_dec2_sec3(+1))*(rho_dec2_sec3(+1)*(1- delta_dec2)+( 1- tauK_dec2(+1))*R_sec3(+1)))^2)*(psi_dec2)*(((betatilde_dec2/rho_dec2_sec3(+1))*(rho_dec2_sec3(+1)*(1- delta_dec2)+( 1- tauK_dec2(+1))*R_sec3(+1)))-1))=PK;
 
//
 
(rho_dec3_sec2 - rho_dec3_sec2*((psi_dec3)/2)*((((betatilde_dec3/rho_dec3_sec2)*(rho_dec3_sec2*(1- delta_dec3)+( 1- tauK_dec3)*R_sec2))-1)^2) - rho_dec3_sec2*((betatilde_dec3/rho_dec3_sec2)*(rho_dec3_sec2*(1- delta_dec3)+( 1- tauK_dec3)*R_sec2))*(psi_dec3)*(((betatilde_dec3/rho_dec3_sec2)*(rho_dec3_sec2*(1- delta_dec3)+( 1- tauK_dec3)*R_sec2))-1)) + (rho_dec3_sec2/(rho_dec3_sec2(+1)*(1-delta_dec3)+(1-tauK_dec3(+1))*R_sec2(+1)))*(rho_dec3_sec2(+1)*(((betatilde_dec3/rho_dec3_sec2(+1))*(rho_dec3_sec2(+1)*(1- delta_dec3)+( 1- tauK_dec3(+1))*R_sec2(+1)))^2)*(psi_dec3)*(((betatilde_dec3/rho_dec3_sec2(+1))*(rho_dec3_sec2(+1)*(1- delta_dec3)+( 1- tauK_dec3(+1))*R_sec2(+1)))-1))=PK;
 
(rho_dec3_sec3 - rho_dec3_sec3*((psi_dec3)/2)*((((betatilde_dec3/rho_dec3_sec3)*(rho_dec3_sec3*(1- delta_dec3)+( 1- tauK_dec3)*R_sec3))-1)^2) - rho_dec3_sec3*((betatilde_dec3/rho_dec3_sec3)*(rho_dec3_sec3*(1- delta_dec3)+( 1- tauK_dec3)*R_sec3))*(psi_dec3)*(((betatilde_dec3/rho_dec3_sec3)*(rho_dec3_sec3*(1- delta_dec3)+( 1- tauK_dec3)*R_sec3))-1)) + (rho_dec3_sec3/(rho_dec3_sec3(+1)*(1-delta_dec3)+(1-tauK_dec3(+1))*R_sec3(+1)))*(rho_dec3_sec3(+1)*(((betatilde_dec3/rho_dec3_sec3(+1))*(rho_dec3_sec3(+1)*(1- delta_dec3)+( 1- tauK_dec3(+1))*R_sec3(+1)))^2)*(psi_dec3)*(((betatilde_dec3/rho_dec3_sec3(+1))*(rho_dec3_sec3(+1)*(1- delta_dec3)+( 1- tauK_dec3(+1))*R_sec3(+1)))-1))=PK;
 
 
 
 
// Intra-Temporal consumption demands.
 
P_sec2*C_dec2_sec2=beta_dec2_sec2*((1- tauL_dec2)*( W_sec2* L_dec2_sec2 + W_sec3* L_dec2_sec3 ) + (1- tauK_dec2)*( R_sec2* K_dec2_sec2(-1)+ R_sec3* K_dec2_sec3(-1))- rho_dec2_sec2*I_dec2_sec2(-1) - rho_dec2_sec3*I_dec2_sec3(-1) +TR_dec1);
 
P_sec3*C_dec2_sec3=beta_dec2_sec3*((1- tauL_dec2)*( W_sec2* L_dec2_sec2 + W_sec3* L_dec2_sec3 ) + (1- tauK_dec2)*( R_sec2* K_dec2_sec2(-1)+ R_sec3* K_dec2_sec3(-1))- rho_dec2_sec2*I_dec2_sec2(-1) - rho_dec2_sec3*I_dec2_sec3(-1) +TR_dec1);
 
//
 
P_sec2*C_dec3_sec2=beta_dec3_sec2*((1- tauL_dec3)*( W_sec2* L_dec3_sec2 + W_sec3* L_dec3_sec3 ) + (1- tauK_dec3)*( R_sec2* K_dec3_sec2(-1)+ R_sec3* K_dec3_sec3(-1))- rho_dec3_sec2*I_dec3_sec2(-1) - rho_dec3_sec3*I_dec3_sec3(-1));
 
P_sec3*C_dec3_sec3=beta_dec3_sec3*((1- tauL_dec3)*( W_sec2* L_dec3_sec2 + W_sec3* L_dec3_sec3 ) + (1- tauK_dec3)*( R_sec2* K_dec3_sec2(-1)+ R_sec3* K_dec3_sec3(-1))- rho_dec3_sec2*I_dec3_sec2(-1) - rho_dec3_sec3*I_dec3_sec3(-1));
 
 
// Capital accumulation equations.
 
 
K_dec2_sec2=(1-delta_dec2)*K_dec2_sec2(-1)+ (1-(psi_dec2/2)*(((betatilde_dec2/rho_dec2_sec2)*(rho_dec2_sec2*(1- delta_dec2)+( 1- tauK_dec2)*R_sec2)-1)^2))*I_dec2_sec2(-1);
 
K_dec2_sec3=(1-delta_dec2)*K_dec2_sec3(-1)+ (1-(psi_dec2/2)*(((betatilde_dec2/rho_dec2_sec3)*(rho_dec2_sec3*(1- delta_dec2)+( 1- tauK_dec2)*R_sec3)-1)^2))*I_dec2_sec3(-1);
 
//
 
K_dec3_sec2=(1-delta_dec3)*K_dec3_sec2(-1)+ (1-(psi_dec3/2)*(((betatilde_dec3/rho_dec3_sec2)*(rho_dec3_sec2*(1- delta_dec3)+( 1- tauK_dec3)*R_sec2)-1)^2))*I_dec3_sec2(-1);
 
K_dec3_sec3=(1-delta_dec3)*K_dec3_sec3(-1)+ (1-(psi_dec3/2)*(((betatilde_dec3/rho_dec3_sec3)*(rho_dec3_sec3*(1- delta_dec3)+( 1- tauK_dec3)*R_sec3)-1)^2))*I_dec3_sec3(-1);
 
 
 
// Price of capital
PK = ((P_sec2/phi_C)^phi_C) * ((P_sec3/phi_ME)^phi_ME);
 
 
// Aggregate labor
LS_sec2 = (L_dec2_sec2+ L_dec3_sec2);
 
LS_sec3 = (L_dec2_sec3+ L_dec3_sec3);
 
 
// Aggregate capital
KS_sec2 = (K_dec2_sec2+ K_dec3_sec2);
 
KS_sec3 = (K_dec2_sec3+ K_dec3_sec3);
 
 
// PRODUCTION EQUATIONS
 
XS_sec2 = (VA_sec2/va_sec2);
 
XS_sec3 = (VA_sec3/va_sec3);
 
//
 
VA_sec2 = c_sec2*(KS_sec2(-1)^alpha_sec2)*(LS_sec2^(1- alpha_sec2));
 
VA_sec3 = c_sec3*(KS_sec3(-1)^alpha_sec3)*(LS_sec3^(1- alpha_sec3));
 
//
 
W_sec2 = (1- alpha_sec2)*c_sec2*(((KS_sec2(-1))/(LS_sec2))^(alpha_sec2));
 
W_sec3 = (1- alpha_sec3)*c_sec3*(((KS_sec3(-1))/(LS_sec3))^(alpha_sec3));
 
//
 
R_sec2 = (alpha_sec2)*c_sec2*(((LS_sec2)/(KS_sec2(-1)))^(1-alpha_sec2));
 
R_sec3 = (alpha_sec3)*c_sec3*(((LS_sec3)/(KS_sec3(-1)))^(1-alpha_sec3));
 
 
// GOVERNMENT EQUATIONS
 
ZG=tauL_dec2*(W_sec2* L_dec2_sec2+ W_sec3* L_dec2_sec3 ) + tauL_dec3* (W_sec2* L_dec3_sec2+ W_sec3* L_dec3_sec3 ) + tauK_dec2*( R_sec2* K_dec2_sec2(-1) + R_sec3* K_dec2_sec3(-1))+ tauK_dec3*( R_sec2* K_dec3_sec2(-1) + R_sec3* K_dec3_sec3(-1))+ tauIVA_sec2*(W_sec2* LS_sec2 + R_sec2* KS_sec2(-1))+ tauIVA_sec3*(W_sec3* LS_sec3 + R_sec3* KS_sec3(-1));
 
TR_dec1=ZG-(G_sec2 + G_sec3);
 
//g = rhoG*g(-1)+epsG;
 
tauK_dec2=0.3;          //POLICY INSTRUMENT
tauK_dec3=0.3;          //POLICY INSTRUMENT
tauL_dec2=0.25;         //POLICY INSTRUMENT
tauL_dec3=0.5;          //POLICY INSTRUMENT
tauIVA_sec2=0.1;        //POLICY INSTRUMENT
tauIVA_sec3=0.1;        //POLICY INSTRUMENT
end;
 
 
//-----------------------------------------------------------------------
// F) INITIAL GUESSES FOR THE STEADY-STATE COMPUTATION. INFO FROM SAM
//-----------------------------------------------------------------------
 
% initval;
%
% ///////////////////////////////////////////
% tauK_dec2=0.3;          //POLICY INSTRUMENT
% tauK_dec3=0.3;          //POLICY INSTRUMENT
% tauL_dec2=0.25;         //POLICY INSTRUMENT
% tauL_dec3=0.5;          //POLICY INSTRUMENT
% tauIVA_sec2=0.1;        //POLICY INSTRUMENT
% tauIVA_sec3=0.1;        //POLICY INSTRUMENT
% ///////////////////////////////////////////
%
% epsG=0;
%
% end;
%
steady_state_model;
tauK_dec2=0.3;          //POLICY INSTRUMENT
tauK_dec3=0.3;          //POLICY INSTRUMENT
tauL_dec2=0.25;         //POLICY INSTRUMENT
tauL_dec3=0.5;          //POLICY INSTRUMENT
tauIVA_sec2=0.1;        //POLICY INSTRUMENT
tauIVA_sec3=0.1;        //POLICY INSTRUMENT

L_dec2_sec2=50;
L_dec2_sec3=50;
L_dec3_sec2=20;
L_dec3_sec3=48;
c_dec2_sec2=log(40);
c_dec2_sec3=log(5.775);
c_dec3_sec2=log(45);
c_dec3_sec3=log(5);
LS_sec2=70;
LS_sec3=98;
K_dec2_sec2=20;
K_dec2_sec3=20;
K_dec3_sec2=60;
K_dec3_sec3=20;
KS_sec2=80;
KS_sec3=40;
XS_sec2=187;
XS_sec3=176.8;
VA_sec2=150;
VA_sec3=138;
E_sec2=8.125;
E_sec3=75.925;
M_sec3=30;
ER=1;
V_sec2=22;
V_sec3=25;
D_sec2=178.875;
D_sec3=100.875;
XD_sec2=187;
XD_sec3=176.8;
PD_sec2=1;
PD_sec3=1;
P_sec2=1;
P_sec3=1;
PM_sec2=1;
PM_sec3=1;
PWE_sec2=1;
PWE_sec3=1;




//ESTIMATION OF SOME ENDOGENOUS VARIABLES IN THE STEADY STATE

W_sec2 = (1- alpha_sec2)*c_sec2*(((KS_sec2)/(LS_sec2))^(alpha_sec2));
W_sec3 = (1- alpha_sec3)*c_sec3*(((KS_sec3)/(LS_sec3))^(alpha_sec3));
R_sec2 = (alpha_sec2)*c_sec2*(((LS_sec2)/(KS_sec2))^(1-alpha_sec2));
R_sec3 = (alpha_sec3)*c_sec3*(((LS_sec3)/(KS_sec3))^(1-alpha_sec3));

I_dec2_sec2=delta_dec2*K_dec2_sec2;
I_dec2_sec3=delta_dec2*K_dec2_sec3;
I_dec3_sec2=delta_dec3*K_dec3_sec2;
I_dec3_sec3=delta_dec3*K_dec3_sec3;
PK=((P_sec3/phi_ME)^(phi_ME))*((P_sec2/phi_C)^(phi_C));

rho_dec2_sec2=PK;
rho_dec2_sec3=PK;
rho_dec3_sec2=PK;
rho_dec3_sec3=PK;

X_sec2 = b_sec2*((1-mu_sec2)^(sigma_sec2/(sigma_sec2-1)))*D_sec2;
X_sec3 = b_sec3*(mu_sec3* (M_sec3^(( sigma_sec3-1)/ sigma_sec3)) + (1-mu_sec3)* (D_sec3^(( sigma_sec3-1)/ sigma_sec3)))^(sigma_sec3/(sigma_sec3-1));

ZG=tauL_dec2*(W_sec2* L_dec2_sec2+ W_sec3* L_dec2_sec3 ) + tauL_dec3* (W_sec2* L_dec3_sec2+ W_sec3* L_dec3_sec3 ) + tauK_dec2*( R_sec2* K_dec2_sec2 + R_sec3* K_dec2_sec3)+ tauK_dec3*( R_sec2* K_dec3_sec2 + R_sec3* K_dec3_sec3)+ tauIVA_sec2*(W_sec2* LS_sec2 + R_sec2* KS_sec2)+ tauIVA_sec3*(W_sec3* LS_sec3 + R_sec3* KS_sec3);
TR_dec1=ZG-(G_sec2 + G_sec3);


//
 
 
end;
steady;

and get
Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0
Equation number 23 : 2
Equation number 24 : 2
Equation number 25 : 0
Equation number 26 : 0
Equation number 27 : 0
Equation number 28 : 0
Equation number 29 : 0
Equation number 30 : 0
Equation number 31 : 0
Equation number 32 : 0
Equation number 33 : -11.8842
Equation number 34 : -1.7158
Equation number 35 : 12.24
Equation number 36 : 1.36
Equation number 37 : 0
Equation number 38 : 0
Equation number 39 : 0
Equation number 40 : 0
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : 0
Equation number 44 : 0
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0
Equation number 48 : 0
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0
Equation number 52 : 0
Equation number 53 : 0
Equation number 54 : 0
Equation number 55 : 0
Equation number 56 : 0
Equation number 57 : 0
Equation number 58 : 0
Equation number 59 : 0
Equation number 60 : 0
Equation number 61 : 0

in both the unstable and Dynare 4.4.3

Re: RAMSEY POLICY PROBLEM

PostPosted: Thu Jun 16, 2016 1:41 am
by emarquez
I agree that setting the tolerance to a large number is not a good idea. Also, I'll be careful in not replacing the evaluate_steady_state-file.
When I used the last file you sent to me I realized that you have “tauL_dec3=0.5;”. However, the correct value of this instrument that solves the steady state of all endogenous variables in the steady_state_model block is “tauL_dec3=0.3;”. When doing this I obtain the steady state as entered in the steady_state_model block:

Code: Select all
STEADY-STATE RESULTS:

L_dec2_sec2          48.8493
L_dec2_sec3          48.8466
L_dec3_sec2          19.9228
L_dec3_sec3          47.9206
LS_sec2              68.7721
LS_sec3              96.7672
KS_sec2              78.6976
KS_sec3              39.5301
K_dec2_sec2          20.17
K_dec2_sec3          19.4786
K_dec3_sec2          58.5275
K_dec3_sec3          20.0515
PK                   1.83377
XS_sec2              183.845
XS_sec3              174.619
VA_sec2              147.47
VA_sec3              136.297
W_sec2               1.00068
W_sec3               1.00024
R_sec2               0.999402
R_sec3               0.999402
E_sec2               8.12093
E_sec3               75.9186
M_sec3               30.2717
ER                   0.996601
V_sec2               21.6968
V_sec3               24.6236
D_sec2               175.725
D_sec3               101.38
X_sec2               175.725
X_sec3               131.651
XD_sec2              183.845
XD_sec3              177.298
PD_sec2              0.999932
PD_sec3              0.999948
P_sec2               0.999932
P_sec3               0.999179
PM_sec2              0.996601
PM_sec3              0.996601
PWE_sec2             1.00334
PWE_sec3             1.00336
ZG                   122.193
c_dec2_sec2          3.89676
c_dec2_sec3          1.96218
c_dec3_sec2          3.48626
c_dec3_sec3          1.28979
I_dec2_sec2          15.7263
I_dec2_sec3          15.1872
I_dec3_sec2          21.3713
I_dec3_sec3          7.32179
rho_dec3_sec2        1.83377
rho_dec3_sec3        1.83377
rho_dec2_sec2        1.83377
rho_dec2_sec3        1.83377
TR_dec1              11.9935
Total computing time : 0h00m01s
Note: warning(s) encountered in MATLAB/Octave code
>> resid




Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0
Equation number 23 : 0
Equation number 24 : 0
Equation number 25 : 0
Equation number 26 : 0
Equation number 27 : 0
Equation number 28 : 0
Equation number 29 : 0
Equation number 30 : 0
Equation number 31 : 0
Equation number 32 : 0
Equation number 33 : 0
Equation number 34 : 0
Equation number 35 : 0
Equation number 36 : 0
Equation number 37 : 0
Equation number 38 : 0
Equation number 39 : 0
Equation number 40 : 0
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : 0
Equation number 44 : 0
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0
Equation number 48 : 0
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0
Equation number 52 : 0
Equation number 53 : 0
Equation number 54 : 0
Equation number 55 : 0


ans =
   1.0e-10 *
         0
         0
   -0.0002
   -0.0002
    0.0000
    0.0000
         0
    0.0000
         0
    0.0000
   -0.0001
   -0.0001
   -0.0144
    0.0007
         0
    0.0121
         0
    0.0034
   -0.0003
         0
    0.0166
    0.0157
    0.0001
    0.0001
    0.0001
         0
   -0.0001
   -0.0000
    0.0000
   -0.0000
         0
   -0.0000
    0.1091
    0.0157
   -0.0005
   -0.0000
   -0.0000
   -0.0000
         0
         0
         0
         0
   -0.0001
    0.0001
    0.0001
         0
         0
    0.0003
    0.0003
    0.0000
    0.0000
   -0.0000
   -0.0000
    0.0007
   -0.0000


What I still don't understand is why the residual equations of the lagrange multipliers, when using the ramsey command, do not enter into the tolerance level... I mean, they are close to zero but not a level of 1e-5

Re: RAMSEY POLICY PROBLEM

PostPosted: Fri Jun 17, 2016 5:04 pm
by jpfeifer
Let’s do this by backward induction and start at the end. Upon solving the Ramsey problem around the steady state, all residuals for all equations need to be 0. If this is not the case, we would be approximating the problem around the wrong point. In the Ramsey problem the multipliers are variables, therefore we also need their steady states. Therefore, if there are non-zero residuals in these equations, as is the case in the last loop you refer to, this indicates something went wrong before. This is why we have this check and I am still convinced it is correctly implemented.
Now the question is what goes wrong in your mod-file before this so that the steady state and the solution of the Ramsey problem cannot be found. The answer, as I wrote in the forum, is that your steady state file is plain wrong. The purpose of the steady state is to compute the steady state conditional on ANY given value of the instruments. This is not the case. Your file only returns the correct steady state when tauL_dec3=0.3. As you wrote:
correct value of this instrument that solves the steady state of all endogenous variables in the steady_state_model block is “tauL_dec3=0.3;”.

This is not the right concept of a conditional steady state. You do not know whether 0.3 is the steady state for the instrument in the Ramsey problem (it turns out, it is not). Now what the Ramsey solver in Dynare does is try to find the steady state including the one of the instruments. But when a value different from 0.3 is given to the steady state file, it returns a wrong conditional steady state. That is why Dynare is not able to solve the Ramsey problem. At the beginning of the evaluate_steady_state.m we check whether the steady_state-file solves the static model part given the initval for the instrument. This check returns no error because your steady state file works for that one particular value of the instrument, but not any other. This is why I told you to enter a different initval for the instrument. In this case, Dynare immediately returns an error in the first check.
I hope this clarifies the issue. Please try to fix the steady state file and see whether this helps. An example is at https://github.com/DynareTeam/dynare/blob/master/tests/optimal_policy/Ramsey/ramsey_ex.mod
Best,
Johannes

Re: RAMSEY POLICY PROBLEM

PostPosted: Sat Jun 18, 2016 1:42 am
by emarquez
Thanks, Johannes
I'll check my model again.

Regards,
Eduardo