lrem is a package which has follwing 4 functions.

1.lre_auto 2.lre_ar 3.simulate 4.impluse

1.lre_auto

lre_auto lre_auto solves LRE model without inputs. (not only things in lre_auto/Rmd) $$ EE_t\begin{bmatrix} x^1_{t+1}\ x^2_{t+1} \end{bmatrix} = A\begin{bmatrix} x^1_{t}\ x^2_{t} \end{bmatrix} $$ E and A are matrix.The above equation is transformed into the following equaton. $$ \begin{aligned} x_t^2 &= g(x_t^1)\ x_{t+1}^1 &= h(x_t^1) + ξ_{t+1} \end{aligned} $$ $ξ_{t+1}$ is prediction error.

You can get these g and h functions by lre_auto. g and h is solved by QZ decomposition in A and E. For example,

E <- matrix(c(
  0.7000000, 0.000000, 1.2000000,
  0.6363636, 1.909091, 0.1818182,
  -2.0000000, -1.000000, 1.0000000
), byrow = TRUE, nrow = 3)

A <- matrix(c(
  0.7000000, 0.000000, 1.2000000,
  0.6363636, 1.909091, 0.1818182,
  0.0000000, -1.000000, 1.0000000
), byrow = TRUE, nrow = 3) 

sol <- lre_auto(A, E, nx = 3)
g <- sol$g
h <- sol$h

You get g and h.

2.lre_ar When you solve the following equation, you can use lre_ar. $$ EE_t\begin{bmatrix} x^1_{t+1}\ x^2_{t+1} \end{bmatrix} = A\begin{bmatrix} x^1_{t}\ x^2_{t} \end{bmatrix}+Bu_t\\ u_{t+1} = Φu_t+ ε_{t+1} $$ g and h is the following equations. $$ \begin{bmatrix} u_{t+1}\ x^1_{t+1} \end{bmatrix} = h(u_t, x^1_t)+\begin{bmatrix} I\ 0 \end{bmatrix}ε_{t+1}\

x^2_{t+1} = g(u_t,x^1_t)

$$

For example,

alpha = 0.33
beta = 0.99
delta = 0.023
chi = 1.75
rho = 0.95
q0 = (1 - beta + beta * delta) / alpha / beta
q1 = q0 ^ (1 / (1 - alpha))
q2 = q0 - delta

kbar = (1 - alpha) * q1 ^ (- alpha)
kbar = kbar / ((1 - alpha) * q0 + chi * q2)

cbar = q2 * kbar
nbar = q1 * kbar
zbar = 1
E = matrix(0, 3, 3)
A = matrix(0, 3, 3)
B = matrix(0, 3, 1)
Phi = matrix(rho, 1, 1)

E[1, 1] = alpha * (alpha - 1) * q0
E[1, 2] = alpha * q0
E[1, 3] = - (1 - delta + alpha * q0)
E[2, 1] = 1

A[1, 3] = E[1, 3]
A[2, 1] = - A[1, 3]
A[2, 2] = (1 - alpha) * q0
A[2, 3] = - q2
A[3, 1] = alpha
A[3, 2] = (- alpha - (1 - alpha) * nbar) / (1 - nbar)
A[3, 3] = -1

B[1, 1] = - alpha * q0 * rho
B[2, 1] = q0
B[3, 1] = 1
policy <- lre_ar(A, E, B, Phi, nx = 1)
g <- policy$g
h <- policy$h

you can get g and h.

3.simulate

simulate function can get the variation of g and h over time.

simulate

4.impulse

You can get the impulse response of g and h which you get by lre_auto or lre_ar.



TakahiroYamane/lrem documentation built on May 20, 2019, 2:43 p.m.