Session 2 Working with Dynare

Similar documents
Introduction to Coding DSGE Models with Dynare

Stochastic simulations with DYNARE. A practical guide.

Dynare. Wouter J. Den Haan London School of Economics. c by Wouter J. Den Haan

Lecture VI. Linearization Methods

First order approximation of stochastic models

The full RBC model. Empirical evaluation

Macroeconomics Theory II

Graduate Macro Theory II: Notes on Quantitative Analysis in DSGE Models

Introduction to Numerical Methods

DYNARE SUMMER SCHOOL

Linear and Loglinear Approximations (Started: July 7, 2005; Revised: February 6, 2009)

Money in the utility model

Lecture 7: Linear-Quadratic Dynamic Programming Real Business Cycle Models

DSGE-Models. Calibration and Introduction to Dynare. Institute of Econometrics and Economic Statistics

The Basic RBC model with Dynare

What are we going to do?

Lecture 15. Dynamic Stochastic General Equilibrium Model. Randall Romero Aguilar, PhD I Semestre 2017 Last updated: July 3, 2017

Deterministic Models

Solving Deterministic Models

Applications for solving DSGE models. October 25th, 2011

0 β t u(c t ), 0 <β<1,

Asset pricing in DSGE models comparison of different approximation methods

An Introduction to Perturbation Methods in Macroeconomics. Jesús Fernández-Villaverde University of Pennsylvania

Real Business Cycle Model (RBC)

Problem Set 4. Graduate Macro II, Spring 2011 The University of Notre Dame Professor Sims

Small Open Economy RBC Model Uribe, Chapter 4

Lecture 4 The Centralized Economy: Extensions

Graduate Macroeconomics - Econ 551

Comprehensive Exam. Macro Spring 2014 Retake. August 22, 2014

Solving LQ-Gaussian Robustness Problems in Dynare

Solution Methods. Jesús Fernández-Villaverde. University of Pennsylvania. March 16, 2016

Solving a Dynamic (Stochastic) General Equilibrium Model under the Discrete Time Framework

Computing first and second order approximations of DSGE models with DYNARE

Christiano 416, Fall 2014 Homework 1, due Wednesday, October Consider an economy in which household preferences have the following form:

1. Using the model and notations covered in class, the expected returns are:

Graduate Macro Theory II: Notes on Solving Linearized Rational Expectations Models

Bayesian Estimation of DSGE Models: Lessons from Second-order Approximations

MA Advanced Macroeconomics: 7. The Real Business Cycle Model

Solving DSGE Models with Dynare. Fabio Canova EUI and CEPR September 2014

Dynamic Stochastic General Equilibrium Models

Dynare Class on Heathcote-Perri JME 2002

Extracting Rational Expectations Model Structural Matrices from Dynare

When Inequality Matters for Macro and Macro Matters for Inequality

1 The Basic RBC Model

Lecture Notes 7: Real Business Cycle 1

Projection Methods. Michal Kejak CERGE CERGE-EI ( ) 1 / 29

Dynamic Identification of DSGE Models

Dynare Summer School - Accuracy Tests

Public Economics The Macroeconomic Perspective Chapter 2: The Ramsey Model. Burkhard Heer University of Augsburg, Germany

HOMEWORK #1 This homework assignment is due at 5PM on Friday, November 3 in Marnix Amand s mailbox.

High-dimensional Problems in Finance and Economics. Thomas M. Mertens

Economics 701 Advanced Macroeconomics I Project 1 Professor Sanjay Chugh Fall 2011

Advanced Macroeconomics II The RBC model with Capital

When Inequality Matters for Macro and Macro Matters for Inequality

Perturbation Methods I: Basic Results

Lecture 3: Growth Model, Dynamic Optimization in Continuous Time (Hamiltonians)

Dynamic Optimization Using Lagrange Multipliers

about this, go to the following web page: michel/dynare/

Approximation around the risky steady state

4- Current Method of Explaining Business Cycles: DSGE Models. Basic Economic Models

Perturbation Methods

Projection Methods. Felix Kubler 1. October 10, DBF, University of Zurich and Swiss Finance Institute

A simple macro dynamic model with endogenous saving rate: the representative agent model

G Recitation 9: Log-linearization. Contents. 1 What is log-linearization? Some basic results 2. 2 Application: the baseline RBC model 4

Macroeconomics II. Dynamic AD-AS model

Dynamic AD-AS model vs. AD-AS model Notes. Dynamic AD-AS model in a few words Notes. Notation to incorporate time-dimension Notes

Suggested Solutions to Homework #6 Econ 511b (Part I), Spring 2004

Lecture 2 The Centralized Economy

Graduate Macro Theory II: Notes on Using Dynare

HOMEWORK #3 This homework assignment is due at NOON on Friday, November 17 in Marnix Amand s mailbox.

Dynamic (Stochastic) General Equilibrium and Growth

PANEL DISCUSSION: THE ROLE OF POTENTIAL OUTPUT IN POLICYMAKING

ADVANCED MACRO TECHNIQUES Midterm Solutions

Solving Heterogeneous Agent Models with Dynare

Perturbation and Projection Methods for Solving DSGE Models

Advanced Econometrics III, Lecture 5, Dynamic General Equilibrium Models Example 1: A simple RBC model... 2

Chapter 11 The Stochastic Growth Model and Aggregate Fluctuations

Endogenous Growth. Lecture 17 & 18. Topics in Macroeconomics. December 8 & 9, 2008

MA Advanced Macroeconomics: 6. Solving Models with Rational Expectations

Practical Dynamic Programming: An Introduction. Associated programs dpexample.m: deterministic dpexample2.m: stochastic

A User Guide for Matlab Code for an RBC Model Solution and Simulation

Perturbation and Projection Methods for Solving DSGE Models

SMOOTHIES: A Toolbox for the Exact Nonlinear and Non-Gaussian Kalman Smoother *

Modelling Czech and Slovak labour markets: A DSGE model with labour frictions

A Monte Carlo Analysis of the VAR-Based Indirect Inference Estimation of DSGE Models

Matlab Programming and Quantitative Economic Theory

Assumption 5. The technology is represented by a production function, F : R 3 + R +, F (K t, N t, A t )

Monetary Economics: Solutions Problem Set 1

Lecture notes on modern growth theory

Lecture 7: Stochastic Dynamic Programing and Markov Processes

Macroeconomics II Dynamic macroeconomics Class 1: Introduction and rst models

Title. Description. Remarks and examples. stata.com. stata.com. Introduction to DSGE models. intro 1 Introduction to DSGEs and dsge

DSGE (3): BASIC NEOCLASSICAL MODELS (2): APPROACHES OF SOLUTIONS

Lecture 1: Overview, Hamiltonians and Phase Diagrams. ECO 521: Advanced Macroeconomics I. Benjamin Moll. Princeton University, Fall

Linearized Euler Equation Methods

ADVANCED MACROECONOMIC TECHNIQUES NOTE 1c

... Solving and Estimating Dynamic General Equilibrium Models Using Log Linear Approximation

Dynamic Programming Theorems

DSGE Methods. Estimation of DSGE models: Maximum Likelihood & Bayesian. Willi Mutschler, M.Sc.

ECON607 Fall 2010 University of Hawaii Professor Hui He TA: Xiaodong Sun Assignment 2

Transcription:

Session 2 Working with Dynare Seminar: Macroeconomics and International Economics Philipp Wegmüller UniBern Spring 2015 Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 1 / 20

Dynare Recap Where can I get the program and some help? Dynare is preprocessor and a collection of Matlab (and GNU Octave) routines, which solves DSGE models The Dynare home page is http://www.dynare.org/ The Dynare manual is available at http://www.dynare.org/documentation-and-support/manual Dynare can be downloaded at http://www.dynare.org/download Instructions how to install Dynare can be found in the manual (Chapter 2, Installation and configuration) See also the Dynare Tutorial http://www.dynare.org/documentation-and-support/tutorial Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 2 / 20

You tell Dynare what the variables, shocks and parameters (+parameter values) of your model are You write down the model equations You tell Dynare to find the steady state Dynare (log)linearizes the model around the steady state... and solves the recursive equilibrium laws of motion of the linearized model Finally, the model is analyzed via impulse responses, stochastic simulations and moments Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 3 / 20

The structure of a typical Dynare (.mod) file var (list of endogenous variables ); varexo (list of shocks) ; parameters (parameters + parameter values + transformations); model; model equations; end; initval; (initial guesses for computing the steady state) steady; (compute the steady state) shocks; (the shock structure of the model ) var (what variables are shocked); stderr (the standard error of the shocks); end; stoch simul(order=1,irf=100) ly lh lc li lk z; (analyzing the model) Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 4 / 20

Timing convention Time indices are given in parenthesis X t+1 is written X(+1), X t 1 is written X(-1) X t 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. Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 5 / 20

Example for capital accumulation Two ways of writing the following equation The standard way: Another way of doing the same: k t+1 = i t + (1 δ)k t var y, k, i;... model; k = i + (1-delta)*k(-1); end; var y, k, i; predetermined variables k;... model; k(+1) = i + (1-delta)*k; end; Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 6 / 20

Some tricks and hits Dynare linearizes the model around the steady state It does not log-linearize the model Remember the advantages of log-linearizations: We are dealing with percentage deviations from the steady state (or the balanced growth path) Log-deviations (or percentage deviations) are easy to interpret (is a deviation small or large?) Similar measures are used in empirical examination of the data (e.g. applying HP filter to log(gdp)) A useful trick: Write down the model in terms of logarithmic transformations of the original variables When Dynare linearizes the model in terms of the logarithmic transformations, it log-linearizes the model in terms of the original variables Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 7 / 20

Some tricks and hits Adopt the notation ly = log(y ), lc = log(c), lk = log(k) etc. Also remember the Dynare conventions pertaining to time indexation Then the resource constraint can be written as Y t = C t + K t+1 (1 δ)k t exp(ly ) = exp(lc) + exp(lk) - (1 - delta) * exp(lk(-1)) Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 8 / 20

Some tricks and hits The expectation operator E t is not used in Dynare code. Dynare knows when one has to take expectations, we do not have to tell this explicitly. Thus the consumption Euler equation [ ] Ct+1 E t = β(1 + r t ) C t is written as exp(lc(+1)-lc) =beta*(1+exp(r)); Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 9 / 20

The general problem where f () are functions E t {f (x t+1, x t, x t 1, u t ; θ)} = 0 x t is a vector of endogenous variables that contains both forward looking variables and predetermined variables u t is a vector of exogenous shocks θ are exogenous parameters In a stochastic framework, the unknowns are the policy functions: this equation is approximated by x t = g(x t 1 ; u t ) x t = x + Aˆx t 1 + Bu t where ˆx t = x t x and x is the steady state. Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 10 / 20

Neoclassical growth model as example Everything is given in levels! We are given the equations: max s.t. {β s U(c t+s )} with U(c t ) = c1 σ t 1 σ s=0 y t = c t + i t k t+1 = i t + (1 δ)k t y t = z t k α t z t = ρ z z t 1 + ϵ t with ϵ t iid N(0, σ 2 ϵ ) (1) Objective: Obtain a linear approximation to the policy functions that satisfy the 1st order conditions. Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 11 / 20

Neoclassical growth model To start, set up the Lagrangian: {( ) } L = β t ct 1 σ + λ t [z t kt α + (1 δ)k t c t k t+1 ] 1 σ t=0 Optimize with respect to c t, k t+1, λ t, note that U (c t ) = λ t = c σ t. The model equations then are ct σ = βe t [c σ t+1 (αz t+1k α 1 t+1 + 1 δ)] (2) c t + k t+1 = z t kt α + (1 δ)k t (3) z t = ρ z z t 1 + ϵ t (4) As a sidemark: If you tipe your model in levels only, then the shock has to be specified as z t = (1 ρ z ) + ρ z z t 1 + ϵ t such that in steady state z 0. Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 12 / 20

Neoclassical growth model 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 Using the linearization technique in Annex 3 we will get: c t = c + a c,k (k t 1 k) + a c,z (z t z) k t = c + a k,k (k t 1 k) + a k,z (z t z) z t = ρ z z t 1 + ϵ t (5) or applying ˆx t = x t x (%age deviation from steady state) : ĉ t = a c,k ˆkt 1 + a c,z ẑ t ˆk t = a k,k ˆkt 1 + a k,z ẑ t ẑ t = ρ z ẑ t 1 + ϵ t (6) Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 13 / 20

Linearization Technique, Log conversion Linearization around (log-)linear steady state. define: x t = log(x t ) exp(x t ) = exp(log(x t )) = X t. Taylor expansion: f (x t ) f ( x) + f x ( x)(x t x) + 1 2 f xx( x)(x t x) 2 + O, with: ˆx t = x t x. Example: f (c t, λ t ) c t f (x t ) n i=1 x i f (x) x i ˆx i x= x f (c t, λ t ) c σ t λ t = 0 = σc σ 1 t, and f (c t, λ t ) λ t = 1 f (c t, λ t ) σ c σ 1 c ĉ t + ( 1) λ ˆλ t = 0 The steady state c σ = λ cancels out, so: σĉ t = ˆλ t Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 14 / 20

Neoclassical growth model Let s do the simulation! δ = 0.025, σ = 2, α = 0.36, β = 0.99, ρ = 0.95, σ e = 0.07 Now do the same with productivity in logs! That is write exp(z t ) Now do the same with all the variables in logs! That is write exp(c t ), exp(k t ), exp(z t ) Compare the IRFs of the three different solutions Dynare gives linear system in what you specify the vars to be! Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 15 / 20

Dynare output Now we can have a look at IRFs: Level deviation from s.s Level deviation from s.s 0.014 0.012 0.01 Response of c e 0.008 0.08 0.06 Response of c e 0.04 0.4 0.2 Response of k e 0 1.5 1 0.5 Response of k e 0 0.015 0.01 0.005 0.015 0.01 0.005 Response of z e 0 Response of z e 0 % deviation from s.s 4.5 5 x 10 3Response of c e 4 3.5 0.01 0.005 Response of k e 0 0.01 Response of z e 0 Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 16 / 20

Dynare output 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. Philipp Wegmüller (UniBern) Session 2 Working with Dynare Spring 2015 17 / 20