Created
October 3, 2016 23:53
-
-
Save nikhildamodaran/c144ad1533bf26f4f3f2d285cc39bb99 to your computer and use it in GitHub Desktop.
baseline_v1: An open Economy DSGE model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% ----- -------------------------------------------------------------- | |
% Model Attempt 1 | |
% ----- -------------------------------------------------------------- | |
% Solving the model without calculating the steady state! Closing large open economy models | |
% ----- -------------------------------------------------------------- | |
% Endogenous Variables | |
% ----- -------------------------------------------------------------- | |
var nubeta nun nuc nui nup tauyd taun tauk taud taum gd gm g pid pi pidopt psigma f gpr x c cd cm n w r k i yd lambda2 mc lambda1 ydn | |
nubetas nuns nucs nuis nups tauyds tauns tauks tauds taums gds gms gs pids pis pidopts psigmas fs gprs xs cs cds cms ns ws rs ks is yds lambda2s mcs lambda1s ydns | |
num icu ygapcu picu tau ycu ycun | |
; | |
% ----- -------------------------------------------------------------- | |
% Exogenous Variables | |
% ----- -------------------------------------------------------------- | |
varexo ebeta en ec ei ep etauyd etaun etauk etaud etaum | |
epsg | |
ebetas ens ecs eis eps etauyds etauns etauks etauds etaums | |
epsgs | |
em | |
; | |
% ----- -------------------------------------------------------------- | |
% Parameters | |
% ----- -------------------------------------------------------------- | |
parameters rhob rhon rhoc rhoi rhop rhotauyd rhotaun rhotauk rhotaud rhotaum eg omg rhog xi mun pidss om muc sigma beta h kappa ej N alpha delta el | |
egs omgs oms | |
rhom psiygap rhoicu psipi | |
; | |
% ----- -------------------------------------------------------------- | |
% Parameters Values (Calibrated Parameters) | |
% ----- -------------------------------------------------------------- | |
rhob = 0.9; | |
rhob = rhon; | |
rhob = rhoc; | |
rhob = rhoi; | |
rhob = rhop; | |
rhob = rhotauyd; | |
rhob = rhotaun; | |
rhob = rhotauk; | |
rhob = rhotaud; | |
rhob = rhotaum ; | |
el = 1.1; | |
eg = el; | |
ej = 0.6; | |
om = 0.3; | |
omg = 0.3; | |
rhog = 0.8; | |
xi = 0.4; | |
mun = 0.023; | |
pidss = 0.02; | |
muc = 0.001; | |
sigma = 0.6; | |
beta = 0.9987; | |
h = 0.8; | |
kappa = 4.00; % Sims (2016) | |
ej = 2; % Doubt | |
N = 1/3; | |
alpha = 1/3; | |
delta = 0.025; | |
egs = eg; | |
oms = 0.2; | |
omgs = oms; | |
rhom = 0.7; | |
psiygap = 1; | |
psipi = 2.5; | |
rhoicu = 0.8; | |
% ----- -------------------------------------------------------------- | |
% Model Block | |
% ----- -------------------------------------------------------------- | |
model; | |
% 1st equation | |
nubeta *lambda1 = beta* nubeta(+1)*(1+icu)*lambda1(+1) *(1+pi)^(-1); | |
% 2nd equation | |
x = c - h * c(-1); | |
% 3rd equation | |
mun * n * nun = lambda1 * w * (1-taun); | |
% 4th equation | |
lambda1 = (x - muc*nuc)^(-sigma); | |
% 5th equation | |
lambda1*(1+pi(+1))*nubeta = lambda1s * (1+pis(+1))*nubetas; | |
% 6th equation | |
lambda1 = (lambda2 * (1-nui*(1- (kappa/2)*((i/i(-1)) - 1))^2 + (nui*i/i(-1))*kappa*((i/i(-1)) - 1))) + (beta * nubeta(+1) * lambda2(+1) * kappa * ((i(+1)/i) - 1)*(i(+1)/i)^2); | |
% 7th equation | |
lambda2 = beta* (nubeta(+1)/nubeta)*(r(+1)*lambda1(+1)*(1-tauk(+1))+lambda2*(1-delta)); | |
% 8th equation | |
(1+pid)^(1-ej) = ( xi*(1+pidss)^(1-ej) + (1-xi)*(1+pidopt)^(1-ej) ); | |
% 9th Equation | |
tau = ((1+pids)/(1+pid))* tau(-1); | |
%10th equation | |
(1+pi)^(1-el) = ( (((1-om)*(1+taud)^(1-el)+om*(1+taum)^(1-el)*tau^(1-el)))/(((1-om)*(1+taud(-1))^(1-el)+om*(1+taum(-1))^(1-el)*tau(-1)^(1-el))) ) * (1+pid)^(1-el); | |
% 11th Equation | |
yd = cd + gd + i + ((1-N)/N)*(cms + gms); | |
% 12th equation | |
cd = (((1-om)* x)/((1+taud)^(el))) * ((1-om)*(1+taud)^(1-el)+om*(1+taum)^(1-el)*tau^(1-el))^(el/(1-el)); | |
% 13 th equation | |
cm = (((om)* x)/((1+taum)^(el))) * ((1-om)*(1+taud)^(1-el)+om*(1+taum)^(1-el)*tau^(1-el))^(el/(1-el)); | |
% 14th equation | |
gd = (((1-omg)* g)/((1+taud)^(eg))) * ((1-omg)*(1+taud)^(1-eg)+omg*(1+taum)^(1-eg)*tau^(1-eg))^(eg/(1-eg)); | |
%15th equation | |
gm = (((omg)* g)/((1+taum)^(eg))) * ((1-omg)*(1+taud)^(1-eg)+omg*(1+taum)^(1-eg)*tau^(1-eg))^(eg/(1-eg)); | |
%16th equation | |
k(+1) = i + k*(1-delta) - nui*(1-(kappa/2)*((i/i(-1)) - 1)^2)*i; | |
% 17the equation | |
psigma = (1-tauyd)^(ej)*((1-xi)*((1+pidopt)/(1+pid))^(-ej) + xi* ((1+pid)/(1+pidss))^(ej)*psigma(-1)); | |
% 18th equation | |
(w*alpha)/(r*(1-alpha)) = (k/n); | |
% 19th equation | |
mc = (1/nup)*((n/k)^(alpha))*(w/(1-alpha)); | |
% 20th equation | |
f = nubeta*lambda1*(1-tauyd)^(ej)*mc*yd + xi*beta*((1+pid(+1))/(1+pidss))^(ej)*f(+1); | |
% 21st equation | |
gpr = nubeta*lambda1*(1-tauyd)^(ej)*yd + xi*beta*((1+pid(+1))/(1+pidss))^(ej)*gpr(+1); | |
% 22nd euqation | |
(1+pidopt) = (ej/(ej-1))*(f/gpr)*(1+pid); | |
% 23rd equation | |
taud = rhotaud*taud(-1) + etaud; | |
% 24th equation | |
taum = rhotaum*taum(-1) + etaum; | |
% 25th equation | |
tauk = rhotauk*tauk(-1) + etauk; | |
% 26th equation | |
taun = rhotaun*taun(-1)+ etaun; | |
% 27th equation | |
tauyd = rhotauyd * tauyd(-1) + etauyd; | |
%28th equation | |
g = rhog * g(-1) + epsg; | |
% 29th equation | |
icu = max(0, psiygap*(1-rhoicu)*ygapcu + psipi*(1-rhoicu)*picu + rhoicu*icu(-1)+num); | |
% 30th equation | |
nuc = rhoc*nuc(-1) + ec; | |
%31st equation | |
nun = rhon*nuc(-1) + en; | |
% 32nd equation | |
nubeta = rhob*nubeta(-1) + ebeta; | |
% 33rd equation | |
nui = rhoi*nui(-1) + ei; | |
% 34th equation | |
nup = rhop*nup(-1) + ep; | |
% 35 | |
num = rhom*num(-1) + em; | |
% 36 | |
nubetas*lambda1s = beta* nubetas(+1)*(1+icu)*lambda1s(+1) *(1+pis)^(-1); | |
% 37 | |
xs = cs - h*cs(-1); | |
% 38 | |
mun * ns * nuns = lambda1s * ws * (1-tauns); | |
% 39 | |
lambda1s = (xs - muc * nucs)^(-sigma); | |
% 40 | |
lambda1s = (lambda2s *(1-nuis*(1- (kappa/2)*((is/is(-1)) - 1))^2 + (nuis*is/is(-1))*kappa*((is/is(-1)) - 1))) + (beta * nubetas(+1) * lambda2s(+1) * kappa * ((is(+1)/is) - 1) * (is(+1)/is)^2); | |
% 41 | |
lambda2s = beta* (nubetas(+1)/nubetas)*(rs(+1)*lambda1s(+1)*(1-tauks(+1))+lambda2s*(1-delta)); | |
% 42 | |
(1+pids)^(1-ej) = ( xi*(1+pidss)^(1-ej) + (1-xi)*(1+pidopts)^(1-ej) ); | |
% 43 | |
(1+pis)^(1-el) = ( (((1-oms)*(1+tauds)^(1-el)+oms*(1+taums)^(1-el)*tau^(-1+el)))/(((1-oms)*(1+tauds(-1))^(1-el)+oms*(1+taums(-1))^(1-el)*tau(-1)^(-1+el))) ) * (1+pids)^(1-el); | |
% 44 | |
yds = cds + gds + is + (N/(1-N))*(cm + gm); | |
% 45 | |
cms = (((oms)* xs)/((1+taums)^(el))) * ((1-oms)*(1+tauds)^(1-el)+oms*(1+taums)^(1-el)*tau^(-1+el))^(el/(1-el)); | |
% 46 | |
cds = (((1-oms)* xs)/((1+tauds)^(el))) * ((1-oms)*(1+tauds)^(1-el)+oms*(1+taums)^(1-el)*tau^(-1+el))^(el/(1-el)); | |
% 47 | |
gms = (((omgs)* gs)/((1+taums)^(eg))) * ((1-omgs)*(1+tauds)^(1-eg)+omgs*(1+taums)^(1-eg)*tau^(-1+eg))^(eg/(1-eg)); | |
% 48 | |
gds = (((1-omgs)* gs)/((1+tauds)^(eg))) * ((1-omgs)*(1+tauds)^(1-eg)+omgs*(1+taums)^(1-eg)*tau^(-1+eg))^(eg/(1-eg)); | |
% 49 | |
ks(+1) = is + ks*(1-delta) - nuis*(1-(kappa/2)*((is/is(-1)) - 1)^2)*is; | |
% 50 | |
psigmas = (1-tauyds)^(ej)*((1-xi)*((1+pidopts)/(1+pids))^(-ej) + xi* ((1+pids)/(1+pidss))^(ej)*psigmas(-1)); | |
% 51 | |
(ws*alpha)/(rs*(1-alpha)) = (ks/ns); | |
% 52 | |
mcs = (1/nups)*((ns/ks)^(alpha))*(ws/(1-alpha)); | |
% 53 | |
fs = nubetas*lambda1s*(1-tauyds)^(ej)*mcs*yds + xi*beta*((1+pids(+1))/(1+pidss))^(ej)*fs(+1); | |
% 54 | |
gprs = nubetas*lambda1s*(1-tauyds)^(ej)*yds + xi*beta*((1+pids(+1))/(1+pidss))^(ej-1)*gprs(+1); | |
% 55 | |
(1+pidopts) = (ej/(ej-1))*(fs/gprs)*(1+pids); | |
% 56 | |
tauds = rhotaud*tauds(-1) + etauds; | |
% 57 | |
taums = rhotaum*taums(-1) + etaums; | |
% 58 | |
tauks = rhotauk*tauks(-1) + etauks; | |
% 59 | |
tauns = rhotaun*tauns(-1)+ etauns; | |
% 60 | |
tauyds = rhotauyd * tauyds(-1) + etauyds; | |
% 61 | |
gs = rhog * gs(-1) + epsgs; | |
% 62 | |
picu = N*pi + (1-N)* pis; | |
% 63 | |
nubetas = rhob*nubetas(-1) + ebetas; | |
% 64 | |
nuns = rhon*nucs(-1) + ens; | |
% 65 | |
nucs = rhoc*nucs(-1) + ecs; | |
% 66 | |
nuis = rhoi*nuis(-1) + eis; | |
% 67 | |
nups = rhop*nups(-1) + eps; | |
% 68 | |
ygapcu = ycu - ycun; | |
% 69 | |
ycun = n * ydn + (1-n) * ydns; | |
% 70 | |
ycu = n * yd + (1-n) * yds; | |
% 71 | |
ydns = 0; | |
% 72 | |
ydn = 0; | |
% 73 Equation linking intermediate output and domestic output (used for natural rate purposes) | |
nup*(k/n)^(alpha) * n = yd*(1-tauyd)^(ej)*psigma^(-1); | |
end; | |
% ----- -------------------------------------------------------------- | |
% Initial Value ~ Helps Converge to Steady State | |
% ----- -------------------------------------------------------------- | |
initval; | |
nubeta = 0; | |
nun = 0; | |
nuc = 0; | |
nui = 0; | |
nup = 0; | |
tauyd = 0; | |
taun = 0; | |
tauk = 0; | |
taud = 0; | |
taum = 0; | |
gd = 0; | |
gm = 0; | |
g = 0; | |
pid = 0; | |
pi = 0; | |
pidopt = 0; | |
psigma = 0; | |
f = 0; | |
gpr = 0; | |
x = 0; | |
c = 0; | |
cd = 0; | |
cm = 0; | |
n = 0; | |
w = 0; | |
r = 0; | |
k = 0; | |
i = 0; | |
yd = 0; | |
lambda2 = 0; | |
mc = 0; | |
lambda1 = 0; | |
nubetas = 0; | |
nuns= 0; | |
nucs = 0; | |
nuis = 0; | |
nups = 0; | |
tauyds = 0; | |
tauns = 0; | |
tauks = 0; | |
tauds = 0; | |
taums = 0; | |
gds = 0; | |
gms = 0; | |
gs = 0; | |
pids = 0; | |
pis = 0; | |
pidopts = 0; | |
psigmas = 0; | |
fs = 0; | |
gprs = 0; | |
xs = 0; | |
cs = 0; | |
cds = 0; | |
cms = 0; | |
ns = 0; | |
ws = 0; | |
rs = 0; | |
ks = 0; | |
is = 0; | |
yds = 0; | |
lambda2s = 0; | |
mcs = 0; | |
lambda1s = 0; | |
num = 0; | |
icu = 0; | |
ygapcu = 0; | |
picu = 0; | |
tau = 0; | |
end; | |
% ----- -------------------------------------------------------------- | |
% Shock Block | |
% ----- -------------------------------------------------------------- | |
shocks; | |
var epsg; | |
stderr 0.009; | |
end; | |
% ---- ------------------------------------------------------------ | |
% Steady State Solver, Eigenvalues Checker | |
% ---- ------------------------------------------------------------ | |
resid(1) ; | |
steady(solve_algo = 3); | |
check; | |
% -------- -------------------------------------------------------- | |
% Solution Block | |
% -------- -------------------------------------------------------- | |
%extended_path(periods=100,order=10); | |
simul(order = 2, relative_irf, irf=30) yd; | |
%write_latex_dynamic_model ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The working version of the paper is here. The solutions need further work.
(A) Creating the steady state file.
(B) Estimating the parameters. (For now, the parameters are fixed according to the literature).
For information on the model, please email nikhil.damodaran@gmail.com