Working with Dynare Philipp Wegmüller∗ Seminar: Macroeconomics and International Economics, Spring ’14 1 Introduction In today’s class we will use the basic real business cycle model and analyze the impact of shocks in levels and shocks in logs. Finally we will linearize the model around the deterministic steady state and interpret the impulse responses. The goals of this session are: In this session we will use the tools learnt in the last session, that is we will take the basic RBC model that we derived as given and proceed from there on towards understanding the model in detail and work with the Dynare output. So far we have seen how in a decentralized economy (households and firms optimization) the general equilibrium representation is obtained and how we can derive the steady state of the economy. Once we know the steady state, we can analyze the impact of shocks to the economy and analyze how the endogenous variables deviate from the steady state. Remember the following from last time:1 Learning Outcomes The students ... • ... simulate the model in levels and in logs. • ... take a first order Taylor expansion around the steady state. • ... understand the timing convention of Dynare. Endogenous variables are determined within the system. • ... read the Dynare output and extract information out of it. Exogenous variables are the drivers of the economy and are determined outside of the system2 Parameter are set to some value. Parameters are so called calibrated, that is we borrow values for the parameters from micro evidence and macro-data. Steady State Stable equilibrium of the model and long run solution. ∗ Task written by Philipp Wegmüller, University of Bern from Microarticle: What was the difference of endogenous and exogenous variables again? 2 Usually we assume a normal distribution with mean zero and some variance σ 2 1 Question 1 Working with Dynare 2 2 The RBC model from session 1 with growth In the following we will use the model of last section and add Harrod neutral technological progress to it3 . A short description of the decentralized general equilibrium shall recap what we have seen. 2.1 Households The household has preferences over a bundle of consumption goods Ct and leisure lt . He chooses the amount of consumption and labor he wants to supply to the private sector such to maximize the expected present discounted value of utility, max E0 ∞ X β t U (Ct , lt ), (1) t=0 (2) where Ct is consumption expenditure, It is investment and Wt nt is the labor income, Rt Kt the rent from holding capital and Πt the profits from the firms. The household is also subject to the capital accumulation equation Kt+1 = It + (1 − δ)Kt (3) The total time endowment is normalized to unity and the household is subject to the time constraint lt = 1 − n t . (4) Un (Ct , 1 − nt ) = Λt Wt (5) Λt = βEt [Λt+1 (Rt+1 + (1 − δ))] (6) BC holding with equality (7) transversality condition (8) Firms The firm produces a homogenous good by means of capital and labor services according to a constant returns to scale technology. The technology is represented by F (kt , Γt nt ) = Yt = Ktα (Γt nt )1−α , (9) where Γt denotes Harrod neutral technological progress, which is assumed to grow at the exogenous constant gross rate γ > 1: subject to the budget constraint Ct + It ≤ Wt nt + Rt Kt + Πt , 2.2 Uc (Ct , 1 − nt ) = Λt Γt = γΓt−1 . (10) The firm determines its production plan by maximizing its profit, max Πt (Kt , Γt nt ) = At F (Kt , Γt nt ) − Wt nt − Rt Kt . (11) The temporary component to productivity At is assumed to follow an autoregressive process of order one (AR(1)). The first order conditions are Yt = At F (Kt , Γt nt ) (12) Wt = At Fn (Kt , Γt nt ) (13) Rt = At FK (Kt , Γt nt ). (14) The resource constraint of the economy is given by Lagrangian optimization yields the first order conditions: 3 Question from Microarticle: How do I have to deal with growth in my model? Yt = Ct + It . (15) Working with Dynare 2.3 3 General equilibrium Assume the functional form for utility U (Ct , lt ) = log(Ct ) + θ log(lt ). (16) then the equilibrium is given by Task 1 Identify the variables that grow. 1 = Λt Ct θ = Λt Wt 1 − nt (17) (18) Λt = βEt [Λt+1 (Rt+1 + (1 − δ))] (19) Kt+1 = It + (1 − δ)Kt (20) Yt = Ct + It (21) Yt = At Ktα (Γt nt )1−α Wt = (1 − α) Rt = α So far in the first session we have done steps 1 and 2. Now note that as long as we have growth in the model, the economy does not converge to a steady state but keeps growing along a balanced growth path! We need to eliminate the growth component which is achieved by deflating the model. But which variables grow? Yt nt Yt . Kt (22) (23) 1. Find the general equilibrium representation. 2. Find the deterministic steady state. 3. Take a log-linear approximation of the model around this deterministic steady state. 5. Solve the system a stochastic linear difference equations. xt = Xt Γt (25) for all variables that grow and are deflated. Λt decreases at the same rate as Γt , such that we define λt = Γt Λt . (24) together with the law of motion for the exogenous variables At , Γt . Remember that the steps to solving a non-linear stochastic general equilibrium were the following : 4. Assign values to parameters. Define next Task 2 Characterize the deflated equilibrium (remember Γt = γΓt−1 ): Working with Dynare 2.4 Steady state Task 3 Find the steady state: 4 • ... you tell Dynare to find the steady state; • ... Dynare linearizes the model around the steady state; • ... and solves the recursive equilibrium laws of motion of the linearized model. • .... you analyze the model via impulse responses, stochastic simulations and moments. Dynare will produce policy and transition functions for the endogenous variables of the model in state space form. Policy functions : how the period t values of the variables depend on the period t − 1 values of the state variables, and the shock. Transition functions : how the period t values of the state variables depend on the period t − 1 values of the state variables, and the shock. Task 4 A model in levels: Remember: In the steady state, variables have constant level over time. 1. kt+1 = kt = k̄, ct+1 = ct = c̄, λt+1 = λt = λ̄ 3 2. Start with Euler Equation, then use capital accumulation equation and solve for k/y, then go on. 3. Use great ratios k/y, i/k, i/y, c/y and so on. Getting to work with Dynare 1. Open up the file rbc growth.mod. 2. Specify a process for the productivity shock which is At = ρA At−1 + A,t Run the model and have a look at the output. 3. What do the impulse responses tell you? Now as we are at this point, we know that • ... you tell Dynare what the variables, shocks and parameters (+parameter values) of your model are4 ; • ... you write down the model equations; 4 The expectation operator E is not used in Dynare code. Dynare ’knows’ when one t has to take expectations, we do not have to tell this explicitly. (26) Working with Dynare 5 4. What does the model summary tell you? 4. What does the model summary tell you? 5. Given an interpretation for the policy and transition function of ct . 5. Given an interpretation for the policy and transition function of ct . Task 5 A model with the shock in logs: 4 Towards a linearized model It is important that you understand that each equation belonging to the system that characterizes the equilibrium can be written as: 1. Generate a new file rbc growth log.mod. 2. Specify a process for the productivity shock which is Et [φ(X)] = 0, log(At ) = ρA log(At−1 ) + A,t Run the model and have a look at the output. (27) (28) where X denotes the vector of variables dated either t or t + 1. Let us denote X ∗ the value of X in the deterministic steady state. Note that by definition of the steady state, the φ(·) function satisfies: 3. What do the impulse responses tell you? φ(X ∗ ) = 0. (29) To start with lets define: xt = log(Xt ) ⇒ exp(xt ) = exp(log(Xt )) = Xt . Task 6 A model with everything in logs: 1. Generate a new file rbc growth all log.mod. Working with Dynare 6 2. Change all your equations by using the definition above.5 As an example lets look at equation 1, which will now read: (1/exp(c))=exp(lb); 4.1 Linearization Technique, Log conversion In this section we take our model and linearize it around its (log-)linear steady state. Taylor expansion: f (xt ) ≈ f (x̄) + fx (x̄)(xt − x̄) + 12 fxx (x̄)(xt − x̄)2 + O, with: x̂t = xt − x̄. Run the model and have a look at the output. n X ∂f (x) x̂i f (xt ) ' x̄i ∂xi x=x̄ i=1 3. What do the impulse responses tell you? Example: f (ct , λt ) ≡ c−σ − λt = 0 t ∂f (ct , λt ) = −σct−σ−1 , ∂ct and ∂f (ct , λt ) = −1 ∂λt f (ct , λt ) ' −σc̄−σ−1 ∗ c̄ ∗ ĉt + (−1) ∗ λ̄ ∗ λ̂t = 0 4. What does the model summary tell you? The steady state c̄−σ = λ̄ cancels out, so: − σĉt = λ̂t Task 7 Take the general equilibrium and log-linearize it around the steady state: 5. Given an interpretation for the policy and transition function of ct . 5 The shock is now specified as in the model in level, as the shock is defined in logs. Watch out for the correct initial values, i.e. adjust to c=log(css), y=log(yss) etc. Working with Dynare 5 7 Appendix 5.1 • Another way of doing the same: Timing convention var y, k, i; predetermined variables k; ... model; k(+1) = i + (1-delta)*k; end; There is a timing convention in Dynare that requires that we (slightly) rewrite the model.6 In particular, Dynare requires that predetermined variables (like the capital stock ) show up as dated t − 1 in the time t equations and t in the t + 1 equations. This is how you tell Dynare if a variable is a state variable or not. • Time indices are given in parenthesis; • Xt+1 is written X(+1); 5.2 • Xt−1 is written X(-1); • Xt is written X (no time index needed for the current period); Dynare will automatically recognize predetermined and nonpredetermined variables, but you must observe a few rules: The time index refers to the period when the value of the variable is determined. The value of the capital stock, which is used in production in period t, is determined in period t − 1. • Two ways of writing the following equation kt+1 = it + (1 − δ)kt • The standard way: Et {f (xt+1 , xt , xt−1 , ut ; θ)} = 0 • where f () are functions • xt is a vector of endogenous variables that contains both forward looking variables and predetermined variables • ut is a vector of exogenous shocks • θ are exogenous parameters • In a stochastic framework, the unknowns are the policy functions: var y, k, i; ... model; k = i + (1-delta)*k(-1); end; 6 Question The general problem in Microarticle: How do I define predetermined variables? xt = g(xt−1 ; ut ) • this equation is approximated by xt = x̄ + Ax̂t−1 + But where x̂t = xt − x̄ and x̄ is the steady state. Working with Dynare 5.2.1 8 Multivariate Solution Method – Eigenvalues and Stability General equation system: • Output is also stored in a separate structure, called oo • The structure oo contains (for example) • The steady state (oo .steady state ) −1 −1 AYt+1 = BYt + CXt → Yt+1 = A | {z B} Yt + A CXt W • The variance-covariance matrix (oo .var) • Generally: Need as many eigenvalues within the unit circle as there are predetermined variables. • The autocorrelations (oo .autocorr) • If A is invertible: Apply Blanchard-Kahn: det[W − λI] • The coefficients of the policy and transition functions (oo .dr) • If A is not invertible: Apply Generalized Eigenvalues: det[Aλ − B] • Results (time paths of endogenous variables) from stochastic simulations (oo .endo simul) • Then solve for the characteristic equation ρ(λ) = λ2 −tr(W )λ+det(W ) • Then check for ρ(0),ρ(1),ρ(±∞), and plot. 1. If NI = NB and NO = NF , unique solution (saddle path); 2. If NI > NB (and NO < NF ), indeterminacy (multiple equilibria, sink); 3. If NI > NB (and NO > NF ), no equilibrium (source) 5.3 Dynare output The output includes • Policy and transition functions of the (log)linearized model • Moments of the endogenous variables: mean, variance, standard deviation, skewness, kurtosis, matrix of contemporaneous correlations, coefficients of autocorrelation • Impulse responses: If if you have included the periods option in stoch simul(order = 1, periods = 1000, irf = 100) • Output also includes the results (time paths of endogenous variables) from the stochastic simulation. • The impulse responses (oo .irf s)
© Copyright 2024 Paperzz