%% Non-linear steady state 

clear all
close all
clc


%% Parameters

beta   = 1.03^-0.25;
theta  = 0.75; %Calvo parameter
sigma  = 1;
eta    = 1;
psi    = 0;
epsilon= 6; %= 10 % reducirlo hasta 2 a medida que vamos incrementando la inflación de ss; 10
                   % efecto en el markup de ss: eps/(1-eps)
rho_a  = 0.9;
rho_m  = 0.9;
ALPHAPAI = 15;


%% Steady state 1 (initial ss)
A_ss       = 1;
infl_ss    = 0.04;
PAI_ss     = (1.0 + infl_ss)^(1/1)
i_ss       = (1/beta)*(PAI_ss)-1;
PAI_R_ss   = (((PAI_ss)^(1-epsilon))/((1-theta)*(1+theta+theta^2+theta^3+theta^4)))^(1/(1-epsilon));
vp_ss      = (1-theta)*((PAI_ss)/(PAI_R_ss))^epsilon*(1+theta+theta^2+theta^3+theta^4);
w_ss       = PAI_R_ss*(epsilon-1)/epsilon;
mc_ss      = w_ss/A_ss
markup_ss  = 1/mc_ss;
Y_ss       = (w_ss*(A_ss^psi)*((PAI_ss/PAI_R_ss)^(-epsilon*psi)))^(1/(sigma+psi));
C_ss       = Y_ss;
N_ss       = Y_ss*vp_ss/A_ss;
pai_ss     = PAI_ss-1;
pai_R_ss   = PAI_R_ss-1;
m_ss       = (C_ss^sigma)*(1+i_ss)/i_ss;
dm_ss      = m_ss - m_ss;
rgm_ss     = PAI_ss;  % rate growth of money

A_ss_1      = A_ss;
infl_ss_1   = infl_ss;
PAI_ss_1    = PAI_ss;
i_ss_1      = i_ss;
PAI_R_ss_1  = PAI_R_ss;
vp_ss_1     = vp_ss;
w_ss_1      = w_ss;
mc_ss_1     = mc_ss;
markup_ss_1 = markup_ss;
Y_ss_1      = Y_ss;
C_ss_1      = C_ss;
N_ss_1      = N_ss;
pai_ss_1    = pai_ss;
pai_R_ss_1  = pai_R_ss;
m_ss_1      = m_ss;
dm_ss_1     = dm_ss;
rgm_ss_1    = rgm_ss;


%% Steady state 2 (final ss)
A_ss       = 1;
infl_ss    = 0.02;
PAI_ss     = (1.0 + infl_ss)^(1/1)
i_ss       = (1/beta)*(PAI_ss)-1;
PAI_R_ss   = (((PAI_ss)^(1-epsilon))/((1-theta)*(1+theta+theta^2+theta^3+theta^4)))^(1/(1-epsilon));
vp_ss      = (1-theta)*((PAI_ss)/(PAI_R_ss))^epsilon*(1+theta+theta^2+theta^3+theta^4);
w_ss       = PAI_R_ss*(epsilon-1)/epsilon;
mc_ss      = w_ss/A_ss
markup_ss  = 1/mc_ss;
Y_ss       = (w_ss*(A_ss^psi)*((PAI_ss/PAI_R_ss)^(-epsilon*psi)))^(1/(sigma+psi));
C_ss       = Y_ss;
N_ss       = Y_ss*vp_ss/A_ss;
pai_ss     = PAI_ss-1;
pai_R_ss   = PAI_R_ss-1;
m_ss       = (C_ss^sigma)*(1+i_ss)/i_ss;
dm_ss      = m_ss - m_ss;
rgm_ss     = PAI_ss;  % rate growth of money


A_ss_2      = A_ss;
infl_ss_2   = infl_ss;
PAI_ss_2    = PAI_ss;
i_ss_2      = i_ss;
PAI_R_ss_2  = PAI_R_ss;
vp_ss_2     = vp_ss;
w_ss_2      = w_ss;
mc_ss_2     = mc_ss;
markup_ss_2 = markup_ss;
Y_ss_2      = Y_ss;
C_ss_2      = C_ss;
N_ss_2      = N_ss;
pai_ss_2    = pai_ss;
pai_R_ss_2  = pai_R_ss;
m_ss_2      = m_ss;
dm_ss_2     = dm_ss;
rgm_ss_2    = rgm_ss;

save parameters beta sigma eta psi epsilon theta rho_a rho_m ALPHAPAI...
                C_ss_1 Y_ss_1 w_ss_1 mc_ss_1 A_ss_1 N_ss_1 vp_ss_1 pai_ss_1 pai_R_ss_1 PAI_ss_1 PAI_R_ss_1...
                m_ss_1 dm_ss_1 rgm_ss_1 i_ss_1...
                C_ss_2 Y_ss_2 w_ss_2 mc_ss_2 A_ss_2 N_ss_2 vp_ss_2 pai_ss_2 pai_R_ss_2 PAI_ss_2 PAI_R_ss_2...
                m_ss_2 dm_ss_2 rgm_ss_2 i_ss_2;               

%% Dynare
dynare nonlin_stickyinfo_disinf


