%% Estimation
% November 2021
clear; clc;
close all

load dataest.mat

T = length(c_obs);

%% Model Setting : Calibration

pars.betta       = 0.9752; % discount factor
pars.tau_k       = 0.35;  pars.tau_pi    = 0.35; % corporate tax rate 
pars.theta_k     = 0.33;  pars.theta_pi  = 0.33; % capital share
pars.delta_k     = 0.025; pars.delta_pi  = 0.025; % depreciation
pars.theta_u     = 1; % capital utilization
pars.iota        = 1;  % makes SS adjustment cost nonzero
pars.thek        = 0.37;  pars.thepi       = 4.6*4; % debt limit
pars.gamma_lt    = 1;     % for short-term debt     
pars.cpn         = 0;

pars.G_bar       = 0.18; % G/Y = 0.18 (according to estimate.mod)
pars.xi_bar      = 1;   

% Flow vs. stock of debt is limited (long-term bond)
pars.netissue = 0; % if = 1, new issuance is constrained / = 0, stock
pars.netissueirf = 0; % if = 1, show irf of net issuance / = 0, level 

% Polynomial for flow constraint
pars.am3  = 0; pars.am2  =0; pars.am1  = 0; pars.a0  = 1; pars.ap1 = 0;

% Polynomial for historical capital price
pars.am4q = 0; pars.am3q =0; pars.am2q = 0; pars.am1q = 0; pars.a0q = 1;

% Shut down sectoral stochastic processes (might be used later)!!!!
pars.rho_z_k     = 0.0;  pars.rho_z_pi    = 0.0;  % TFP
pars.siggz_k     = 0.0;  pars.siggz_pi    = 0.0;  

pars.rho_zeta_k  = 0.0;  pars.rho_zeta_pi = 0.0;  % MEI
pars.siggzeta_k  = 0.0;  pars.siggzeta_pi = 0.0;

pars.rho_dd      = 0.0;  pars.rho_dd_k    = 0.0; pars.rho_dd_pi   = 0.0; % demand shut down even for agg.
pars.siggdd      = 0.0;  pars.siggdd_k    = 0.0; pars.siggdd_pi   = 0.0;


% To be estimated

pars.siggma      = 1; % risk aversion
pars.epsilon     = 2; % Frisch elasticity
pars.h           = 0; % habit parameter
pars.phi         = 77; 
pars.phi_k       = 77; % Rotemberg price adjustment cost (Ireland 2001)
pars.phi_pi      = 77; % Rotemberg price adjustment cost (Ireland 2001)
pars.omega       = 0; % wage rigidity
pars.varrho      = 4;    
pars.psi         = 0; % curvature in utilization cost
pars.kappa       = 0.2; % equity payout cost
pars.upsilon_bar = 1.001; % SS wage markup

% share of pi-type firms
pars.share_pi = 0.8;

% stochastic processes
pars.rho_z       = 1.0;  
pars.rho_zeta    = 1.0;  
pars.rho_eta     = 0.95; pars.eta_bar     = 1.2;                           % price markup
pars.rho_gamma   = 0.95;                                                   % preference
pars.rho_xi      = 0;    pars.rho_xi_k    = 0; pars.rho_xi_pi   = 0;       % financial
pars.siggxi      = 0;    pars.siggxi_k    = 0; pars.siggxi_pi   = 0;
pars.rho_G       = 0.95; pars.rho_gz      = 0.95;                          % gov. spending
pars.rho_upsilon = 0.95;                                                   % wage markup

pars.rho_varsigma= 0.95; pars.rho_R       = 0;    
pars.nu_1        = 1.5;  pars.nu_2        = 0;    pars.nu_3        = 0;    % monetary & Taylor
pars.cmap        = 0;    pars.cmaw        = 0;                             % MA cofficients

%% Estimate model in Dynare
tic

save params pars
dynare NKfinal_one_stickiness_param 

toc
