Skip to content

Instantly share code, notes, and snippets.

@jmoy
Created March 6, 2015 13:06
Show Gist options
  • Save jmoy/71da20d706d5d741197d to your computer and use it in GitHub Desktop.
Save jmoy/71da20d706d5d741197d to your computer and use it in GitHub Desktop.
library(QZ)
# Parameters
sigma = 1 #log utility
phi=1 #unitary Frisch elasticity
phi_pi = 1.5 #inflation feedback Taylor Rule
phi_y = .5/4 #output feedback Taylor Rule
theta=2/3 #Calvo parameter
rho_nu = 0.5 #autocorrelation monetary policy shock
rho_a = 0.9 #autocorrelation technology shock
beta = 0.99 #discount factor
eta = 4 #semi-elasticity of money demand
alpha = 1/3 #capital share
epsilon=6 #demand elasticity
# Composite parameters
Omega=(1-alpha)/(1-alpha+alpha*epsilon) #defined on page 47
psi_n_ya=(1+phi)/(sigma*(1-alpha)+phi+alpha) #defined on page 48
lambda=(1-theta)*(1-beta*theta)/theta*Omega #defined on page 47
kappa=lambda*(sigma+(phi+alpha)/(1-alpha)) #defined on page 49
# Equations
# Variable order: pi,y_gap,a,b=a[-1],nu,y,i
# Jump variables: pi,y_gap,a
# Predetermined variables: b, nu, y, i
D = matrix(0,nrow=7,ncol=7)
E = matrix(0,nrow=7,ncol=7)
# pi=beta*pi(+1)+kappa*y_gap
D[1,1] = beta
E[1,1] = 1
E[1,2] = -kappa
#y_gap=-1/sigma*(i-pi(+1)-r_nat)+y_gap(+1)
#y_gap=-1/sigma*(i-pi(+1)-sigma*psi_n_ya*(a(+1)-a))+y_gap(+1)
D[2,1] = 1/sigma
D[2,2] = 1
D[2,3] = psi_n_ya
D[2,7] = -1/sigma
E[2,2] = 1
E[2,3] = psi_n_ya
#i=phi_pi*pi+phi_y*y_gap+nu
D[3,5] = -1
D[3,7] = 1
D[3,6] = -phi_y
E[3,1] = phi_pi
# b = a(-1)
D[4,4] = 1
E[4,3] = 1
#nu=rho_nu*nu(-1)+eps_nu
D[5,5] = 1
E[5,5] = rho_nu
#a=rho_a*a(-1)+eps_a;
E[6,3] = 1
E[6,4] = -rho_a
# y = phi*a + y_gap
E[7,3] = phi
E[7,2] = 1
D[7,6] = 1
ans<-geigen(E,D,only.values=TRUE)
cat(round(ans$ALPHA/ans$BETA,4),sep="\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment