An Introduction to DSGE Modeling in Dynare Andrew Lee Smith



This version: August 26, 2013 Dynamic Stochastic General Equilibrium (or DSGE) models represent state of the art macroeconomic modeling. Not without their critics, these models represent the collective efforts of academics and central bankers to build internally consistent macro models which can be used for both academic research and policy analysis. These models are however mathematically complicated which creates a significant hurdle for graduate students who are interested in working in this important area. Thanks to a wonderful collection of MATLAB files created, assembled and shared by Michel Julliard, Dynare significantly eases the transition from first order conditions to model analysis. As with many things, the only way to learn is to do! Therefore, this introduction will present a canonical New-Keynesian model from first order conditions to model analysis such as Impulse Response Functions (IRFs), Forecast Error Variance Decompositions (FEVDs) and variable correlations and auto-correlations.

1

Introduction

Although in this introduction the focus will be on a New-Keynesian model, such models were not the first generation of DSGE models. This line of work traces its roots to Kydland and Prescott’s 1982 classic, “Time to Build and Aggregate Fluctuations” which essentially takes a discrete time Ramsey Growth model and adds lags between the time investment in capital is made and when that capital can be used in production. The contribution of this paper was three-fold. First, the paper offered an alternative to the Keynesian viewpoint that recessions are demand-driven phenomena. KP show business cycles can be generated by real factors, changes in technology1 , hence this paper marked the beginning of Real Business Cycle (RBC) modeling. Second, the paper avoids the Lucas Critique leveled by Robert Lucas (1976). This critique cautions that performing policy analysis with reduced form models can be misleading since policy parameters are likely entangled into these reduced form parameters. For this reason, a change in policy may cause these reduced form parameters to change - however a reduced form policy analysis would fail to take this into account. By using a Ramsey style growth model, KP model consumer preferences and firm technology; what we call microfoundations. This keeps policy parameters such as tax rates separate from model primitives. Third, KP pioneered the strategy of calibration. Since, KP use microfoundations, to ∗ [email protected] PhD Candidate, University of Kansas, Department of Economics, 1460 Jayhawk Blvd. Lawrence, KS 66044. 1 This has deeper implications from a policy standpoint. In particular, recessions from this viewpoint are an ‘efficient’ or ‘Pareto-Optimal’ response to a change in the economy’s potential level of output and for this reason any attempt by policy makers to eliminate these recessions would be welfare decreasing.

1

analyze the model they had to assign values to parameters. How they chose these values was innovative. They chose values for parameters so that the model’s steady state matched key features of U.S. data. This approach essentially ties down the model’s long-run implications but allows the short-run dynamics to be determined by the model. These three substantial contributions led, in large part2 , to Kydland and Prescott’s Nobel Prize awarded in 2004. However, it also lead to a strong response by Keynesian economists who believed nominal factors can affect the real economy. In particular, by adding nominal rigidities to an otherwise standard RBC model, the resulting models featured the strong microfoundations emphasized by KP but also features a role for policy makers in responding to aggregate fluctuations as emphasized by Keynes. The resulting models are a synthesis of ideas and hence called a NewClassical/Keynesian or New-Keynesian synthesis. For a more careful argument as to why it is important to include nominal frictions see Gali (2008) which is an accessible introduction to NewKeynesian models. In the conclusion I will describe some other important approaches to modeling business cycles including non-rational expectations and financial frictions.

2

The Model

In this section the consumer and firm side of the model will be described. You are likely familiar with the consumer’s problem however the firm’s problem will likely be new to you. Also, the approach to general equilibrium modeling may be new to you, although it is ultimately the same as the production economies you saw in general equilibrium theory. All capital variables are real and and lowercase variables are nominal, including interest rates. Variables with a bar over them denote non-stochastic steady state variables.

2.1

Consumer

The consumer enters any period t = 0, 1, 2, ... with a portfolio consisting of 2 assets. The household holds maturing bonds Bt−1 , shares of monopolistically competitive firm i ∈ [0, 1] st−1 (i). The household can use the proceeds from the sale of these assets along with its paycheck, Wt ht and dividends received of shares owned in period t, Ft (i) to purchase more assets and the consumption good at price 1, Ct . The resulting budget constraint faced by the consumer summarizes this below. Bt−1 + πt

Z1

Z1 Qt (i)st−1 (i)di +

0

Ft (i)st (i)di + Wt ht = 0

Bt + rt

Z1 Qt (i)st (i)di + Ct

(1)

0

The household seeks to maximize their lifetime utility, discounted at rate β, subject to these constraints. The period flow utility of the household takes the following form. " # (1−θ ) Ct c ut = at + η (1 − ht ) 1 − θc 2 The Royal Swedish Academy of Sciences also cites their related paper, Kydland and Prescott (1977) which highlights the time-inconsistency problem associated with dynamic policy making.

2

The time-varying preference parameter at enters the linearized Euler equation as an IS shock. This process is assumed to follow an AR(1) (in logs), ln(at ) = ρa ln(at−1 ) + εat

εat ∼ N (0, σa ) .

(2)

The representative household faces the problem of maximizing its lifetime utility subject to its budget constraint.The household’s optimization problem can be recursively defined using Bellman’s method. #  " (1−θc )   Ct Vt Bt−1 , Mt−1 , st−1 (i) = max at + η (1 − ht ) 1 − θc [Ct ,ht ,Bt ,st (i)]   Z1 Z1 Bt−1 Bt + Λt  − + Qt (i)(st−1 (i) − st (i))di + Ft (i)st (i)di + Wt ht − Ct  πt rt 0 0 h  i + βEt Vt+1 Bt , st (i) The first order necessary conditions are given by the following equations. The system of equations (3)-(6) is under-determined in the sense that we have introduced various derivatives of the value function. However, we can complement these first order necessary conditions with the BienvenisteScheinkman Envelope Conditions to eliminate the value function from the system above. These envelope conditions are given in equations (7) and (8) below.

at Ct−θc − Λt = 0

(3)

−at η + Λt Wt = 0

(4)

0 −Λt + βEt [Vt+1,Bt (Bt , st (i))] = 0 rt

(5)

0

−Λt Qt (i) + Λt Ft (i) + βEt [Vt+1,st (i) (Bt , st (i))] = 0

(6)

Envelope Conditions:

0

Vt,Bt−1 (Bt−1 , st−1 (i)) =

Λt πt

0

Vt,st−1 (i) (Bt−1 , st−1 (i)) = Λt Qt (i)

(7) (8)

Now update (7) and (8) and substitute the resulting equations into (5) and (6) yielding:   Λt+1 −Λt + βEt =0 rt πt+1

(9)

−Λt Qt (i) + Λt Ft (i) + βEt [Λt+1 Qt+1 (i)] = 0

(10)

The conditions (3), (4), (9) and (10) define the consumer’s optimal behavior. 3

2.2

The Goods Producing Sector

The goods producing sector features a final goods firm and an intermediate goods firm. There are a unit measure of intermediate goods producing firms indexed by i ∈ [0, 1] who produce a differentiated product. The final goods firm produces Yt combining inputs Yt (i) using the constant returns to scale technology, θ  1  θ−1 Z θ−1 Yt =  Yt (i) θ di 0

in which θ > 1 governs the elasticity of substitution between inputs, Yt (i). The final goods producing firm sells its product in a perfectly competitive market, hence solving the profit maximization problem, θ  θ−1  1 Z1 Z θ−1 − Pt (i)Yt (i)di. max Pt  Yt (i) θ di Yt (i)i∈[0,1]

0

0

The resulting first order condition defines the demand curve for each intermediate goods producing firm’s product.  −θ Pt (i) Yt (i) = Yt (11) Pt

Intermediate Goods Producing Firm Given the downward sloping demand for its product in (11), the intermediate goods producing firm has the ability to set the price of its product above marginal cost. Unlike the final goods market, the intermediate goods market is not purely competitive as evident by the downward sloping demand for its product in equation (11). To permit aggregation and allow for the consideration of a representative intermediate goods producing firm i, we assume all such firms have the same constant returns to scale technology which implies linearity in the single input labor ht (i), Yt (i) = Zt ht (i).

(12)

The Zt term in (12) is an aggregate technology shock that follows an AR(1) (in logs), ln(Zt ) = ρZ ln(Zt−1 ) + εZ t

εZ t ∼ N (0, σZ ) .

(13)

The price setting ability of each firm is constrained in two ways. First, each intermediate goods producing firm faces a demand for its product from the representative final goods producing firm defined in (11). Second, each intermediate goods producing firm faces a convex cost of price adjustment proportional one unit of the final good defined by Rotemberg (1982) to take the form,  2 φ Pt (i) Φ(Pt (i), Pt−1 (i), Pt , Yt ) = − 1 Yt . 2 Pt−1 (i) The intermediate goods producing firm maximizes its period t real stock price, Qt (i). Using the representative household’s demand for firm i0 s stock (10) and iterating forward defines the real 4

(no-bubbles) share price as the discounted sum of future dividend payments.   ∞ X Λt+j Ft+j (i) . Qt (i) = Et  βj Λt j=0

(14)

Though the firm maximizes period t share price, the costly price adjustment constraint makes the intermediate goods producing firm’s problem dynamic. Mathematically summarizing, each intermediate goods producing firm solves to following dynamic problem. This reveals that each period the firm discounts period t + j profits using the consumer’s stochastic discount factor, Λ DF St+j = Λt+j . t max

{Yt (i),ht (i),Pt (i)}∞ t=0

Et

∞ X j=0

" DF β j St+j

 2 # φ Pt (i) Pt (i) Yt (i) − Wt ht (i) − − 1 Yt Pt 2 Pt−1 (i)

subject to  Yt (i) =

Pt (i) Pt

−θ Yt

Yt (i) = Zt ht (i) The problem can be simplified by substituting the inverse of the technology constraint for ht (i) and then substituting the factor demand into the resulting expression for Yt (i) so that now the representative intermediate goods producing firm solves the following recursive problem defined by Bellman’s equation. ( "  2 # 1−θ  −θ P (i) P (i) W P (i) φ t t t t −1 Vt (Pt−1 (i)) = max StDF Yt − − Pt Zt Pt 2 Pt−1 (i) Pt (i) ) h i + βEt Vt+1 (Pt (i)) The first order necessary condition for the problem is given by −θ  −1−θ Pt (i) 1 Wt Pt (i) + θStDF Yt Pt Pt Pt Zt Pt   0 P (i) 1 t −φStDF Yt −1 + βEt [Vt+1 (Pt (i))] = 0 Pt−1 (i) Pt−1 (i)π

(1 − θ)StDF Yt



Once again invoking the Bienveniste-Scheinkman Envelope Condition we have   0 Pt (i) Pt (i) DF Vt (Pt−1 (i)) = St Yt φ −1 2. Pt−1 (i) (Pt−1 (i))

5

(15)

(16)

Updating (16) one period and substituting into (15) and then multiplying the resulting equation t yields by SPDF t

 (1 − θ)

Pt (i) Pt

−θ

 −1−θ   Wt Pt (i) Pt (i) Pt −φ −1 Zt Pt Pt−1 (i) Pt−1 (i) " #   DF St+1 Yt+1 Pt+1 (i) Pt Pt+1 (i) +βφEt −1 =0 2 Pt (i) StDF Yt (Pt (i))



(17)

In a symmetric equilibrium where Pt (i) = Pt ∀i ∈ [0, 1], (17) can be log-linearized in which case it takes the form of a New-Keynesian Phillips Curve relating current inflation to the average real marginal cost and expected future inflation.

2.3

Monetary Policy

The nominal economy as defined is under-determined in the sense that there are more equations than variables. The extra variable is inflation, πt . To close the model (impose as many equations as variables), we must specify the behavior of the central bank. As is standard, we will describe monetary policy with an interest rate feedback rule of the form specified by Taylor (1993) augmented to include interest rate smoothing. rt = r¯



rt−1 r¯

φr  φπ  φY Yt πt εrt Y¯

(18)

The equation above includes a white noise monetary policy disturbance which will allow us to examine how the model’s endogenous variables respond to unexpected increases the central bank’s policy rate.

2.4

Market Clearing

Now that we have described the optimizing behavior of consumers and firms we can define the conditions needed to ensure all markets clear in this economy. First notice there are uncountably many intermediate goods producing firms, however we have specified that they all have the same technology and the same market share. Therefore, it is useful to first impose this symmetry in the intermediate goods producing sector. Thus, the equilibrium we are defining is a symmetric equilibrium. In particular, for all intermediate goods producing firms i ∈ [0, 1] at every time t we have, Yt (i) = Yt

(19)

ht (i) = ht

(20)

Pt (i) = Pt

(21)

Ft (i) = Ft

(22)

Qt (i) = Qt

(23)

st (i) = st .

(24)

6

The above definition imposes the the labor market clearing, since we have used the same variables for labor supply (the ht in the household’s utility function) and labor demand (the ht = ht (i) in the firm’s production function). However, there are three other markets in the model. First, the stock market clears when all shares are owned by the consumer. Also, the market for bonds can only clear when there are no bonds outstanding. In particular, if the consumer wanted to hold a positive quantity of bonds, there would have to be an agent willing to supply those bonds. However, since only household’s buy and sell bonds, and there is only a single representative agent, it is impossible to have them simultaneously want to buy and sell bonds. This suggests if we want to have a real bond market in the model we have to introduce heterogeneity between agents who hold bonds (see Iacoviello (2005)). We can summarize the conditions by imposing at every time t, st = st−1 = 1 Bt−1 = Bt = 0.

(25) (26)

Finally, there is one market left to clear, the goods market. It turns out that in an economy with N markets, if N − 1 markets clear and the household has locally non-satiated preferences3 , then the household’s budget constraint will bind and implicitly force the last market to clear. I encourage you to verify this, but it turns out these conditions imply the goods market will clear, in other words,  2 φ Pt (i) − 1 Yt . (27) Yt = Ct + 2 Pt−1

3 This is easily verified here since the preferences are strongly monotonic, which implies monotonic, which implies locally non-satiated

7

2.5

The Complete Set of Non-Linear Model Equations

In this section we will combine the model’s equations to define a set of non-linear equations describing the equilibrium of the model. The Consumer Wt = ηCtθc (

at Ct−θc = βEt rt sDF = t

(28) −θc at+1 Ct+1 πt+1

)

at Ct−θc −θc at−1 Ct−1

(29) (30)

The Firm

0 = (1 − θ) + θ

Wt − φ(πt2 − πt ) + βφEt Zt



 sDF t+1 Yt+1 2 (π − π ) t+1 t+1 sDF t Yt

Yt = Zt ht

(31) (32)

Monetary Policy φr  φπ  φY Yt εrt πt Y¯

(33)

φ 2 [πt − 1] Yt 2

(34)

ln(at ) = ρa ln(at−1 ) + εat

(35)

rt = r¯



rt−1 r¯

Market Clearing

Yt = Ct + Exogenous Shock Processes

ln(Zt ) = ρZ ln(Zt−1 ) +

8

εZ t

(36)

3

Solving the Model

The phrase, ‘Solving the Model’ in terms of a non-linear DSGE model is rather unclear. In general though, we want to study the behavior of the model’s endogenous variables in response to exogenous shocks. Therefore, by solving the model, we want to express the endogenous variables as functions of the exogenous shocks - such equations are called decision rules.4 It turns out that solving even this small, 9 variable non-linear model is exceptionally difficult.5 . One of the primary problems lies in the existence expectations of nonlinear functions. Even when projection methods are used to solve these models, the resulting solution is an approximation to the decision rules of the exact non-linear model. Another strategy, which is far more common relies on perturbation methods. The basic idea is to find a Taylor approximation (possibly of order k) to the non-linear model and then find exact decision rules to the approximate model. The most common, and by far simplest, is to take a linear (first order) Taylor approximation to the model and find exact decision rules for the approximation to the model.

3.1

Where Does Dynare come into Play?

This linear solution method is the one we will implement in this example. It turns out doing so still requires solving for the model’s non-stochastic steady state. Hence, we still have to solve a system of 9 non-linear equations, but we don’t have to worry about expectations since we are solving for the non-stochastic steady state. In general, a model may have many steady states and the dynamics of a model may be different depending upon which steady state we choose to approximate around. In any case, as long as the steady state solution is accurate, Dynare can linearize the model for us and solve the resulting linear rational expectations problem (assuming a solution exists and is unique, more on this later).

3.2

Solving for the Steady State

Due to the powerful capabilities of Dynare, solving for the model’s steady-state has become the most difficult part for a practitioner. Indeed, it is a non-trivial problem to solve a system of possibly n non-linear equations. When a closed form solution for the model’s steady-state can not be found, which is typically the case, we must resort to numerical methods. The basic strategy is as follows: 1. Eliminate as many variables as possible and boil the system down to a subset of equations for which there is no closed form solution. Sometimes this may be only a few equations, however other times it may be almost all of the equations (I have been there). 2. Assign values to the model’s parameters and use one of MATLAB’s non-linear equation solvers such as fsolve or setup your own function which defines the variables residuals and use MATLAB’s fminsearch function to minimize this residual. I prefer the later, however this is really 4 In more general model’s there may be endogenous state variables (such as capital) in addition to exogenous state variables (exogenous shocks). Therefore, it is more generally correct to say that solving a model means expressing endogenous variables in terms of state variables. 5 One exception in which an exact solution to the fully non-linear model can be found is for an RBC model with log-utility, 100% capital depreciation and log-normal technology shocks

9

personal preference due to my experience with fsolve, but others have had success. Hint: Use a variable transformation to bound variables when possible so MATLAB is searching over a smaller space. For example steady-state hours worked can not exceed 1, which implies steady state output can not exceed 1 and therefore steady state consumption can not exceed 1. 3. Given the solution to this smaller set of equations, solve the model’s remaining equations. 4. Assign new parameter values. It is unlikely the parameters you chose in (2) above were satisfactory. Now that you know the full-steady state adjusts those parameter values until the model’s steady state matches desired targets. This is essentially calibration. In the model described above, an exact closed form steady-state exists. Some of the steady-state values are chosen by the modeler. In particular, I have implicitly set the steady-state value for (gross) inflation equal to 1. This is a choice. I am also assuming all of the model’s stochastic processes are stationary, that is the model does not have a unit-root nor a time trend. That is to say, | ρZ |< 1 and | ρa |< 1. It may be a reasonable assumption for some models, however there is significant evidence that output has a unit root which could be captured by setting ρZ = 1. See for example, Ireland (2004b). Another choice is that output doesn’t have a unit-root but instead it has a linear time trend. See for example, Iacoviello and Neri (2010). The study of unit roots and testing for the presence of unit roots will be studied extensively by Professor Keating this semester. I only point out to you now that such specifications can be fully handled in the realm of DSGE models. I however caution you that finding steady states and specifying the model to Dynare requires that you first detrend the model and remove such non-stationarities. Without further digression, I now state the model’s steady state which can be easily verified by setting εit = 0 for all t and for all i ∈ {a, Z, r}.

10

3.3

The Model’s Non-Stochastic Steady State

The Consumer

C¯ =



θ−1 θ

  θ1 1 c η

1 β =1

(38)

r¯ = s¯DF

(37)

(39)

The Firm ¯ = θ−1 W θ   1 θ − 1 1 θc ¯ h= θ η

(40) (41)

Monetary Policy

π ¯=1

(42)

Market Clearing

Y¯ =



θ−1 θ

  θ1 1 c η

(43)

Exogenous Shock Processes

a ¯=1 ¯ Z=1

11

(44) (45)

3.4

Choosing Parameters: Calibration

Choosing values for the model’s parameters can be done by assigning values to the parameters so that the model’s steady-state and other moments matches features of the target economy’s data (this is called calibration) or the model can be estimated using maximum likelihood methods (See Ireland (2004a)) or Bayesian methods (See Smets and Wouters (2007) or An and Schorfheide (2007)). Here we will simply assign values to the model’s parameters, hence calibrate the model. We must decide which country’s economy we want top calibrate the model to and how we will interpret the length of one time period in the economy. For this example we will match the model to U.S. data and interpret each time period as one quarter. The interest rate on one period bonds in the model is the policy rate controlled by the central bank. Setting β = .99 matches the steady state policy rate equal to 4% per year, the average of the federal funds rate since 1984. Setting η = 2.5 matches the steady state share of hours worked equal to 1/3, the U.S. average. Setting θc equal to 1 implies log-utility, a benchmark calibration. This parameter calibrates both the coefficient of relative risk aversion and intertemporal elasticity of substitution, spawning a well-known equity premium / risk-free rate puzzle (Mehra and Prescott, 1985). Setting θc = 1 is a closer to the low-value of θc needed to match the risk-free rate Euler than it is towards the high value needed to match the equity premium Euler. Since we don’t have any risky assets in this economy, setting θc = 1 seems a bit more sensible in this case, although it should be known this is not without debate. Although these values determine the model’s steady state, it is useful to go ahead and assign values to parameters that will be needed to study the model’s dynamics. In particular, the ratio (θ−1)θc pins down the slope of the New-Keynesian Phillips Curve. For this specification, we follow φ Ireland (2004b) and set φ = 50 and θ = 6. These values combined with our choice of θc = 1 implies a frequency of price-adjustment in a Calvo environment of prices changing once every 3.75 quarters. Ireland (2004b) estimates ρa = .9579, σa = .0188, ρZ = .9903, σZ = .0098 and σr = .0025. He also estimates the monetary policy rule and finds that φr = .5481, φπ = .5680 and φy = 0.

4

Dynare

4.1

What exactly do I need to tell Dynare?

Dynare accepts a special type of file called a ‘mod’ file, short for model. A model file has a particular syntax but is essentially a text file saved as ‘.mod’ . The basic layout of a .mod file is as follows. 1. var 2. varexo 3. parameters 4. model 5. initval 6. shocks

12

7. stoch simul The ‘var’ portion declares the endogenous variables (be careful, this includes at and Zt ). The r ‘varexo’ portion declares exogenous shocks: εat , εZ t and εt . The parameters section requires we list all the model’s parameters and then state the values assigned to them. The model block asks us to write the model’s non-linear equations. The steady state block requires that we write the non-linear equations described in Section 2.5. In the initval block we write the steady state values of the model’s endogenous variables as described in Section 3.3. In the shocks block of the code we write the covariance matrix of the model’s shocks. This is typically a diagonal matrix, however you can choose to model the exogenous shocks as correlated in which case you would have to specify the covariance between the shocks. The last line of code specifies the particularities of the stochastic simulation. In particular, you can specify whether you want Dynare to compute theoretical or simulated moments, the length of impulse responses you want calculated and the number of autocorrelations computed, amongst other options. The following code is what the .mod file looks like for this model.

13

4.2

The .mod File

%% MOD FILE %% %% VARIABLE BLOCK %% var w, c, sdf, infl, y, h, r, a, z; %% %% EXOGENOUS VARIABLES BLOCK %% varexo er, ea, ez; %% %% PARAMETER BLOCK %% parameters beta, eta, theta_c, phi, theta, phi_r, phi_infl, phi_y, rhoa, rhoz, sigmar, sigmaa, sigmaz; %% beta = .99; eta = 2.5; theta_c = .1; phi = 50; theta = 6; phi_r = .5481; phi_infl = .5680; phi_y = 0; rhoa = .9579; rhoz = .9903; sigmar = .0025; sigmaa = .0188; sigmaz = .0098;

14

%% %% MODEL BLOCK %% model; %% THE CONSUMER exp(w) = eta*exp(theta_c*c); exp(a - theta_c*c - r) = beta*exp(a(+1) - theta_c*c(+1) - infl(+1)); exp(sdf) = exp(a - a(-1) - theta_c*(c - c(-1))); %% THE FIRM 0 = (1-theta) + theta*exp(w - z) - phi*(exp(2*infl) - exp(infl)) + beta*phi*exp((sdf(+1) - sdf) + (y(+1) - y))*(exp(2*infl(+1)) - exp(infl(+1))); exp(y) = exp(z + h); %% MONETARY POLICY exp(r - STEADY_STATE(r)) = exp(phi_r*(r(-1) - STEADY_STATE(r)) + phi_infl*(infl - STEADY_STATE(infl)) + phi_y*(y - STEADY_STATE(y)) + er); %% MARKET CLEARING exp(y) = exp(c) + (phi/2)*((exp(infl) - 1)^2)*exp(y); %% EXOGENOUS SHOCK PROCESSES exp(a) = exp(rhoa*a(-1) + ea); exp(z) = exp(rhoz*z(-1) + ez); end; %% %% DEFINE STEADY STATE VALUES (REMEBER ALL VARIABLES ARE LOGGED) %% initval; c = log((((theta-1)/theta)*(1/eta))^(1/theta_c)); r = log(1/beta); sdf = log(1); w = log((theta-1)/theta); h = log((((theta-1)/theta)*(1/eta))^(1/theta_c)); infl = log(1); y = log((((theta-1)/theta)*(1/eta))^(1/theta_c)); a = log(1); z = log(1); end;

15

%% %% ASK DYNARE TO PRINT RESIDUALS (THEY SHOULD BE EXACTLY 0 AT THE STEADY STATE SUPPLIED) %% resid; steady; %% %% ASK DYNARE TO PRINT THE RESULTS OF THE DETERMINACY CONDITION (BLANCHARD AND KAHN CONDITIONS) %% check; %% %% SHOCK BLOCK %% shocks; var er = sigmar^2; var ea = sigmaa^2; var ez = sigmaz^2; end; %% %% SPECIFY PARTICULARS OF STOCHASTIC SIMULATION %% stoch_simul(order=1,irf=20) y c infl r h w;

16

4.3

A Few Notes on the .mod File

A few notes are in order at this point. First, the % character comments out any notes we want to make. Second, I chose to write the model in logs. Hence, every variable x you see in the model is written in exp(x) form. This is a choice I made, you could also write the model in levels. I chose logs so that impulse response functions can be interpreted as percent changes. Moreover, some equations are naturally log-linear in economics, such as the Euler in this model or the production function. The third thing to notice is the way leads and lags of variables are denoted. If we want to express Ct+1 we simply write c(+1). Notice we do not have to write expectations. Dynare assumes if we write a variable with a (+1) then this variable has an expectation on it.

4.4

Running the .mod File

To run the mod file we need to use MATLAB, or an open source free version of MATLAB called Octave. The computers in the economics computer lab have MATLAB installed on them. In addition to having MATLAB, we need to have Dynare downloaded on the computer we are using (or on our flashdrive if you want to use the computers in the lab). To do this, go to http: //www.dynare.org/ and click on the download link. Download Dynare to your C-drive. Once it is correctly downloaded create a folder in c:\dynare called ‘econ 911’ or whatever you want to name it. It is important there are no spaces or dashes in the folder name. Save the .mod file in c:\dynare\econ_911 . I chose to name the .mod file, ‘new keynesian.mod’. Summarizing, you should have:

17

Now we are ready to run our .mod file! We simply open MATLAB and at the command prompt we type three simple lines of code. EDU>> addpath c:\dynare\4.3.3\matlab EDU>> cd c:\dynare\econ_911 EDU>> dynare new_keynesian Summarizing again, you should see:

Finally! Press ‘enter’ and the .mod file will run and Dynare will produce our requested output.

4.5 4.5.1

Dynare’s Output Impulse Response Functions

You probably noticed after running the mod file Dynare immediately produced three graphs, one for each set of impulse response functions. These graphs plot the response of the requested stoch_simul(order=1,irf=20) y c infl r h w; endogenous variables. Below, I present these IRFs as produced by Dynare. The Response to a Monetary Policy Tightening In response to a monetary tightening, an increase in the nominal policy rate, the interest rate increases (due to sticky prices). This increase in the real interest rate induces consumers to decrease consumption today. Since consumers want to consume less today they choose to work less and

18

−3

0

−3

y

x 10

0

−2

−2

−4

−4

−6

5 −4

0

10

15

−6

20

5 −3

infl

x 10

c

x 10

3

−2

10

15

20

15

20

15

20

r

x 10

2

−4 1

−6 −8

5 −3

0

10

15

0

20

x 10

0

−2

−2

−4

−4

−6

5

10

5 −3

h

15

−6

20

10 w

x 10

5

10

Figure 1: Model’s Response to a Monetary Policy Shock hence hours worked fall. The decreases demand, and hence output today. Since marginal costs are proportional to output, marginal cost falls and hence inflation decreases. Notice one interesting fact from the IRFs. Although we hit the monetary policy rule with ∂rt an increase in interest rates of σr = .0025, the initial increase in the policy rate, ∂ε r = .0021. t Why don’t interest rates increase by the full amount of the shock? The reason is due to the endogenous response to inflation. As inflation falls in response to the monetary tightening, the policy rule dictates the central bank should immediately cut interest rates, hence the policy rate doesn’t increase the full amount of the shock due to the endogenous fall in inflation. Question: How would the economy’s response to a monetary policy shock change if we increased φ? Decreased φ? Why? Hint: Think about the slope of the New-Keynesian Phillips Curve? Question: What happens if we change the parameters on the monetary policy rule so that φπ = .2? Does there exist a unique rational expectations equilibrium? Play with the parameters φr and φπ and try to figure out the magic rule for the ratio φφπr that guarantees the existence and uniqueness of a rational expectations equilibrium? Can you give an intuitive interpretation of this rule? Hint: Think about the Fisher equation together with this rule.

19

−3

4

−3

y

x 10

4

3

3

2

2

1

1

0

5 −3

3

10

15

0

20

3

2

2

1

1

0

5 −3

4

10

15

3

3

2

2

1

1

0

5

10

5 −3

4

15

15

20

10

15

20

15

20

w

x 10

0

20

10 r

x 10

0

20

h

x 10

5 −3

infl

x 10

c

x 10

5

10

Figure 2: Model’s Response to an Aggregate Demand Shock The Response to an increase in Aggregate Demand When the economy is hit with an unexpected increase in aggregate demand agents choose to consume more today and hence they increase their hours worked. Since consumption is increasing, aggregate demand increases and hence wages rise. As output increases with consumption, marginal costs rise and inflation increases. The Fed responds to this increase in inflation by raising their policy rate. The Response to an increase in Technology There is a considerable debate in the literature as to how hours worked respond to an increase in technology. (See (Gali, 1999) or (Christiano, Eichenbaum, and Vigfusson, 2004)) In this model the effect is indeed sensitive to the calibration. On the one hand, a higher level of technology implies higher wages which would induce workers to work more today, this is the substitution effect. However, there is also a wealth effect. When wages rise, consumers can work less and consume the same amount today. Hence, the key question here is how willing are consumers to substitute income today versus income tomorrow? Or, how willing are consumers to substitute consumption today versus consumption tomorrow? The answer to this question depends on the intertemporal elasticity of substitution, IES =

20

1 θc .

If the IES is large agents are willing to substitute income between periods, if it is small, they want really smooth consumption. This makes intuitive sense! Look at the utility function and see what happens as θc → 0? Utility becomes linear in consumption, no longer strictly concave. Therefore, consumers will allow for large jumps in consumption between periods. At our baseline calibration, θc = 1 and hence, IES = 1. It turns out this IES is still not large enough to induce agents to consume a lot more today. Therefore, they respond to the higher wages by working less, not allowing consumption to change much. y

c

0.01

0.01

0.005

0.005

0

5 −4

0

10

15

0

20

infl

x 10

0

−2

−2

−4

−4

−6

5 −4

0

10

5 −4

15

−6

20

15

20

15

20

15

20

r

x 10

5

h

x 10

10

10 w

0.01

−2 0.005 −4 −6

5

10

15

0

20

5

10

Figure 3: Model’s Response to a Technology/Aggregate Supply Shock Question: How would the response of hours worked change if we lowered θc = .1? Find out for yourself and see what happens. Can you explain why? 4.5.2

Moments, Variance Decompositions, Decision Rules

Dynare also produces theoretical moments from the model including means, variances, correlations and auto-correlations. This is a good opportunity to examine the empirical properties of your model and see how it matches up with the data. Most model’s will fail in some aspects and succeed in others. For example, this New-Keynesian model is designed to model the effects of monetary policy on the economy, so we shouldn’t expect it to explain the growth of output since we have modeled technology as exogenous.

21

The solution to a DSGE model takes the form of a VAR(1). That is, the solution is of the form: Xt = BXt−1 + Cεt .

(46)

This allows you to compute the variables of interest yourself including cross auto-correlations, conditional moments (these are needed for welfare analysis) or variance decompositions at different horizons (the variance decompositions pictured on the screen are long-run variance decompositions), which are not produced automatically by Dynare. The matrices B6 and C are stored as: B = oo_.dr.ghx C = oo_.dr.ghu .

4.6

What Can go Wrong?

Well, lots of things. The truth is your .mod file will rarely run the first time after write it. There will be some typos such as a missing multiplication, a missing parameter, or even a missing semi-colon. All of these issues will prevent your .mod file from successfully running. There can be other more subtle problems as well. In particular, we should not take for granted the idea that Determinacy will be achieved. Some models may feature rich feedback effects which make them very interesting, but can make the determinacy regions small and sensitive to the calibration. Although Dynare is powerful, you must be careful that you really understand what is happening in the model you are building. Otherwise, it may be difficult to diagnose problems with your .mod file. Does your model have a near-non-stationarity? It may be the case the depreciation parameter in a model with investment is effectively small and this may create numerical problems. Yes, δ = .001 should still be stationary, however after inverting and decomposing a few matrices as is needed to solve the linear rational expectations problems, δ = .001 may start to look a lot like δ = 0. If you are having problems with your .mod file you can check Dynare’s forum at http:// www.dynare.org/phpBB3/ which is monitored fairly well by the Dynare staff but don’t expect an immediate answer. If your answer is not well thought out or clear, they may not help at all. Be sure to search the forum first for people who have asked similar questions, you may find an answer without needing to post a question. The site I directed you to has other resources including example programs of popular models others have written. Another great resource is Dynare’s User guide (which is also linked to on the Dynare forum site above) which explains in much more depth basically everything we have discussed today. Finally, some documentation for much of what Dynare is doing can be found in the Dynare reference manual http://www.dynare.org/manual/. 6 The matrix B is only 9 by 4 as stored by Dynare. The reason is that only 4 of the variables show up with a lag in the mod file: Ct−1 , rt−1 , Zt−1 andat−1 . Hence, we actually need to augment to B, five 9 by 1 columns of zeros. The exact location of these additional columns matters. Feel free to ask me if you are interested in recovering such a such a B matrix and are having difficulty figuring out how the variables are ordered.

22

4.7

What Else is Dynare Useful For?

If business cycle modeling is not your area of interest, Dynare does other things which may be of interest to you. For example, Dynare can examine transition dynamics in deterministic growth models. Taking Romer’s endogenous growth model, you can study what happens when the population growth rate increases using Dynare. Or, taking the Ramsey growth model as an example, you could find out what agents will do in response to an unexpected increase in the tax rate that is either permanent or temporary. The documentation for this can be found in the user guide linked to above.

5 5.1

Conclusion Other References

Although Dynare is very useful, you will eventually reach a point where Dynare can not do everything you want to do. In this case, you may need other references on DSGE modeling, solutions methods and estimation. In this case, here are a few books which will be useful in this area. Dave and DeJong (2010) is a wide ranging text and maybe the most-accessible in this area. Canova (2007) is thorough but advanced and sometimes difficult to use as a reference in my opinion. Many useful questions are left to the reader as an exercise. Although this may be a good idea in some cases, as a young researcher trying to figure out research methodology this can be frustrating.

5.2

Other Directions for Business Cycle Modeling

Although the New-Keynesian model presented here is a workhorse model for monetary policy analysis, there are other interesting approaches to modeling business cycles. Bernanke, Gertler, and Gilchrist (1999) develop an equilibrium model where the distribution of wealth affects the level of investment and hence output. The point of this paper is that financial frictions play a role in shaping the business cycle. Christiano, Motto, and Rostagno (2013) estimate a variation of BGG and find that exogenous changes in the riskiness of borrowers is the single largest factor in explaining the U.S. business cycle. Farmer (2010) argues the current class of equilibrium models fails to capture the possibility of permanently low output following a disturbance as Keynes stressed. Hence, Farmer takes a completely different approach in many regards and argues that irrational expectations about asset prices can result in permanent changes in the level of employment - something the current class of models fails to accommodate.

23

References An, S., and F. Schorfheide (2007): “Bayesian Analysis of DSGE Models,” Econometric Reviews, 26(2-4), 113–172. Bernanke, B. S., M. Gertler, and S. Gilchrist (1999): “The financial accelerator in a quantitative business cycle framework,” in Handbook of Macroeconomics, ed. by J. B. Taylor, and M. Woodford, vol. 1 of Handbook of Macroeconomics, chap. 21, pp. 1341–1393. Elsevier. Canova, F. (2007): Methods for Applied Macroeconomic Research, no. v. 13 in Methods for applied macroeconomic research. Princeton University Press. Christiano, L., R. Motto, and M. Rostagno (2013): “Risk Shocks,” NBER Working Papers 18682, National Bureau of Economic Research, Inc. Christiano, L. J., M. Eichenbaum, and R. Vigfusson (2004): “The Response of Hours to a Technology Shock: Evidence Based on Direct Measures of Technology,” Journal of the European Economic Association, 2(2-3), 381–395. Dave, C., and D. DeJong (2010): Structural Macroeconometrics. Princeton University Press. Farmer, R. (2010): Expectations, Employment and Prices. Oxford University Press, USA. Gali, J. (1999): “Technology, Employment, and the Business Cycle: Do Technology Shocks Explain Aggregate Fluctuations?,” American Economic Review, 89(1), 249–271. (2008): Monetary Policy, Inflation, and the Business Cycle: An Introduction to the New Keynesian Framework. Princeton University Press. Iacoviello, M. (2005): “House Prices, Borrowing Constraints, and Monetary Policy in the Business Cycle,” American Economic Review, 95(3), 739–764. Iacoviello, M., and S. Neri (2010): “Housing Market Spillovers: Evidence from an Estimated DSGE Model,” American Economic Journal: Macroeconomics, 2(2), 125–64. Ireland, P. N. (2004a): “Money’s Role in the Monetary Business Cycle,” Journal of Money, Credit and Banking, 36(6), 969–83. (2004b): “Technology Shocks in the New Keynesian Model,” The Review of Economics and Statistics, 86(4), 923–936. Kydland, F. E., and E. C. Prescott (1977): “Rules Rather Than Discretion: The Inconsistency of Optimal Plans,” Journal of Political Economy, 85(3), 473–91. (1982): “Time to Build and Aggregate Fluctuations,” Econometrica, 50(6), 1345–70. Lucas, R. J. (1976): “Econometric policy evaluation: A critique,” Carnegie-Rochester Conference Series on Public Policy, 1(1), 19–46. Mehra, R., and E. C. Prescott (1985): “The equity premium: A puzzle,” Journal of Monetary Economics, 15(2), 145–161.

24

Rotemberg, J. J. (1982): “Sticky Prices in the United States,” Journal of Political Economy, 90(6), 1187–1211. Smets, F., and R. Wouters (2007): “Shocks and Frictions in US Business Cycles: A Bayesian DSGE Approach,” American Economic Review, 97(3), 586–606. Taylor, J. B. (1993): “Discretion versus policy rules in practice,” Carnegie-Rochester Conference Series on Public Policy, 39(1), 195–214.

25

An Introduction to DSGE Modeling in Dynare

marked the beginning of Real Business Cycle (RBC) modeling. Second, the paper ... believed nominal factors can affect the real economy. In particular, by .... The Zt term in (12) is an aggregate technology shock that follows an AR(1) (in logs),.

778KB Sizes 5 Downloads 260 Views

Recommend Documents

Introduction to Credit Risk Modeling, An
Nonlinear Dynamics and Complex Systems, Brussels and at Siemens Research. Department in Munich. He has published ..... an ordered scale of ratings in terms of a letter system describing the creditworthiness of rated companies. ...... the difference b

Introduction to Credit Risk Modeling, An
most grateful. Disclaimer. This book reflects the personal view of the authors and not the opin- ion of HypoVereinsbank, Deutsche Bank, or Allianz. The contents of the book has been written for educational purposes and is neither an of- fering for bu

pdf-1468\decision-modeling-in-policy-management-an-introduction ...
Try one of the apps below to open or edit this item. pdf-1468\decision-modeling-in-policy-management-an-introduction-to-the-analytic-concepts.pdf.

An Introduction to Mathematical Modeling - Edward A. Bender.pdf ...
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. An Introduction ...

Sticky Information Models in Dynare
Mar 25, 2013 - as an alternative to the widely used Calvo sticky price framework. Agents update their ... compute the ergodic variance to initialize the Kalman filter. This is actually ... independent and normally distributed innovations. 3 Sticky ..

Sticky Information Models in Dynare
Mar 25, 2013 - widely used software package for solving dynamic stochastic .... In particular, in each period only a fraction λ of firms ... be used for other models with a small number of lagged expectation terms ... of T = 32 the amount of time sp

On DSGE Models
Nov 27, 2017 - †Northwestern University, Department of Economics, 2211 Campus Drive, Evanston, Illinois 60208, USA. ... case of reduced form methods, it is not always clear which parameters should be changed and which should ...... It is hard to im

A Graphical Representation of an Estimated DSGE Model
∗Economic Research Department, Reserve Bank of Australia. ... the impact of productivity and mark-up shocks and the role of fiscal multipliers.2 ... Conversely as the cost of price adjustment rises, ψ → 0, implying that the .... On the aggregate

Linear and Linear-Nonlinear Models in DYNARE
Apr 11, 2008 - iss = 1 β while in the steady-state, all the adjustment should cancel out so that xss = yss yflex,ss. = 1 (no deviations from potential/flexible output level, yflex,ss). The log-linearization assumption behind the Phillips curve is th

An Introduction to Digital Philosophy
DP is based on two concepts: bits, like the binary digits in a computer, correspond to the most .... DP predicts angular isotropy above the scale of quantization and predicts why the laws of physics are independent of the choice of ..... computer num

An Introduction to Digital Philosophy
modeling processes in the physical sciences?” “In physics ... look elsewhere with respect to the most fundamental models of physical processes. What we must ... models. Thus the unit of state is the bit, which is considerably simpler than a real

An introduction to probability theory
Feb 19, 2004 - We can do this by an electronic thermometer which consists of a ... calibration of the thermometer might not be correct, the quality of the power-.

An Introduction to BigQuery - GitHub
The ISB-CGC platform includes an interactive Web App, over a Petabyte of TCGA data in Google Genomics and Cloud Storage, and tutorials and code ...

An Introduction to Neighborhood Watch
It is one of the largest such programs in the country and has received national and international recognition. An Introduction to. Neighborhood Watch. Introduction. FAIRFAX .... observing suspicious activities, walking patrols are to contact the poli

(in)variance of dsge model parameters
a strong trend in the last half century. ... that of the households at the micro-level. ... anticipate that ν is different from the micro-elasticity of household labor supply ...

Private Money Creation and Equilibrium Liquidity - Dynare
Sep 10, 2016 - what was believed to be a safe security —and therefore liquid —did not ..... the intervention of brokers who receive a transaction fee for their ...

Choosing the variables to estimate singular DSGE ...
Jun 19, 2013 - potentially usable to construct the likelihood function is smaller. In other cases ..... and in the non-singular systems which are best according to the rank analysis - see next paragraph on ...... Identification and frequency domain Q

Family-Matters-An-Introduction-To-Family-Sociology-In-Canada.pdf ...
Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Family-Matters-An-Introduction-To-Family-Sociology-In-Canada.pdf. Family-Matters-An-Introduction-To-