Applied Macroeconomic Modeling OGResearch Tomas Motl March / ? 2020 About the model 2/34 About me • Masaryk university alumni, applied mathematics / economics • Two years PhD with prof. Vasicek, then left • Since 2012 with OGResearch – macro forecasting, model development, ... • Since 2013 technical assistance missions under the IMF to Africa, Asia, ... • Ad hoc work on macroeconomic modelling About the model 3/34 About the course • Point is to show you how macro forecasting is done • Showcase workhorse macro model, show what it can and cannot do • First, we’ll examine a generic model and learn the basics • Then, we’ll apply the model to Azerbaijan and recent, important period • I’ll be sending emails, out stuff into Study materials • ASK QUESTIONS, HAVE COMMENTS, BE ACTIVE About the model 4/34 To pass the course... • The point is for you to learn, I won’t force you • I’ll require three things: − prepare a presentation on Azerbaijan and what happened there since 2014 − do your own forecast for Azerbaijan − you are active during the lectures • Work will be in groups of 3-4 people • Deadlines will not be tight About the model 5/34 About the QPM models • The Quarterly Projection Model is a workhorse in applied macro modeling − QPM developed by Bank of Canada for MonPol analysis and forecasting • The key equations describe gaps (deviations from trends) • Trends described by simpler equations • Maleable, flexible structure to incorporate many different mechanisms • Semi-structural: blueprint based on DSGE (micro-foundations) but amended to remain flexible and describe data • New Keynesian tradition => nominal rigidities (sticky prices, monopolistic competition => suitable for monetary policy analysis • Rational expectations (with modifications if necessary) and endogenous monetary policy => suitable for monetary policy analysis • Parameters usually not estimated, but calibrated to achieve desired properties About the model 6/34 The QPM is a simple model • QPM building blocks are simple – that’s a virtue, we can work with the model • Simple structure leads to uncertainty of model parameters − That’s why we calibrate • Some important economic mechanisms missing − Balance sheet effects, revisions in perceived riskiness of bank assets − Supply side basically exogenous, labor supply, migration, tricky behavior of commodities − Fiscal risks, policies − Structural issues • We should not ”believe” the model, it’s only a tool to help us About the model 7/34 Output gap Output gap is a measure of the demand-side inflationary pressures and is described by the IS curve: yt = β1yt+1 + β2yt−1 − β3rt + εy t • Own lead and lag - why? • Real interest rate gap r, which represents the stance of monetary policy • Idiosyncratic shock εy - shocks, but also model imperfection, misspecification, … About the model 8/34 Supply side – inflation Core inflation is modelled using a New-Keynesian Phillips Curve (PC): πt = α1Eπt+1 + (1 − α1)πt−1 + α2(yt) + επ t • PC is homogenous α1 + (1 − α1) = 1. This is important, otherwise inflation would always go to zero. • Output gap represents demand pressures on inflation About the model 9/34 Monetary Policy Central bank follows inflation-forecast-based reaction function (IFBRF): rt = g1rt−1 + (1 − g1)(g2(Eπt+1 − πtar ) + g3yt) + εr t • It’s the real interest rate that matters - anyone knows how this is called? • Note that the inflation target here is a parameter, but it can be made into an equation About the model 10/34 So we have the equations – what now? • To work with the model, we need to have at least basic understanding of the mathematical methods in the background: − How is the model solved? − How is the model solution represented? − How are model parameters determined? − What methods are available to check the model parameterization? − How do we forecast with the model? • Let’s do a (very brief) primer into these topics About the model 11/34 Model solution, state-space representation • Using dummy variables for leads and lags, we can rewrite the model as: G(Xt, Xt−1, Xt+1, εt) = 0 • Xt is a vector of endogenous variables, εt of exogenous shocks Xt =   πt yt rt   , εt =   επ t εy t εr t   • We want to solve the model to obtain: Xt = g(Xt−1, εt) • For linear models, the solution can be written as Xt = AXt−1 + Bεt+B2Et[εt+1] + B3Et[εt+2] . . . • Remember this, I’ll refer to the model solution often About the model 12/34 Steady-state • A dynamic system is in steady-state if the variables do not change in time unless there are shocks Xt = A · Xt−1 = Xss • In our case: yss =? rss =? πss =? • Can be quite complicated for non-linear models, we need to use numerical solvers • Implication: in the absence of shocks, the model does nothng more than converge to steady-state! About the model 13/34 Impulse Response Functions • We now see shocks are important, we need to examine how they impact the model • To do that, we use the impulse-response functions (IRFs) • Given the initial condition Xt, we do a forecast Xk = Ak X0 + Ak−1 B0ε0 • The initial condition is usually chosen to be: − Steady-state − Deviation from steady-state (= zero for all variables) • Thourough analysis of the IRFs is always useful, let’s do it About the model 14/34 Impulse Response Functions – the code • Go to study materials, zipfile ”closed_model”, download, unzip • Go to study materials, zipfile ”IRIS_Tbx_20150119.zip”, download, unzip • Start matlab, navigate to the IRIS folder, type ”irisstartup” • Open files ”closed_model.model”, ”setparam.m”, ”run_toy_model_irf.m” • Let’s have a look at the files • Let’s do the IRFs and interpret them • Note: the model should return to steady-state About the model 15/34 Determining initial condition Xk = Ak X0 + k∑ i=1 Bi εi • Initial condition X0 is very important : − Is the output gap now positive or negative? − Is the MonPol stance now tight or easy? − Initial condition largely determines the forecast − Central banks put enormous effort into identification of the initial condition, and we should too • How we can determine the initial condition, given that many variables are unobservable? − Start from steady-state - not correct − Set the numbers by hand - cumbersome − Use unilateral filters (Hodrick-Prescott, …) − Best practice: Use multivariate filter and our model => the Kalman filter About the model 16/34 State Space Model Representation State space, denoted as M: Xt = AXt−1 + Bεt yt = ZtXt + ηt where • Xt is a vector of endogenous variables • εt a vector of exogenous structural shocks, εt ∼ N(0, Qt) • yt are a vector of observations in period t: − usually/always smaller size than Xt – we can observe πt, but not yt − the size of the vector can be changing • Zt is a matrix transforming the variables into observations, and • ηt are the measurement errors, ηt ∼ N(0, Ht) – in economics we generally set Ht = 0 About the model 17/34 Kalman smoother as LSQ • Now we have observations Yt = [y1, . . . , yT ], all the available observations denoted as YT • Kalman filter / smoother estimates are joint distributions p(Xt, ηt, εt|M, YT ) • For any given xt and YT , there is linear space of realizations of shocks ε and measurement errors η • Because shocks and measurement errors are distributed normally, there is only one realization in that space yielding the maximum likelihood, or equivalently the least square errors • The square errors are weighted according to the variance-covariance matrices Q and H => variance decomposition matters • Therefore, mean of xt|T is a constrained least square solution − the constraints come from the state space for each period − the optimization minimizes sum of square shocks and measurement errors wieghted by their respective standard errors About the model 18/34 Kalman smoother as LSQ • In practice we assume the following: Ht = 0, Qt =   σ1 0 0 0 σ2 0 0 0 σ3   • Basically, we solve the following optimization problem: min T∑ t=1 ( ε1 t σ1 )2 + ( ε2 t σ2 )2 + . . . s.t. : Xt = AXt−1 + Bεt yt = ZtXt • That’s a least squares problem similar to fitting a OLS About the model 19/34 Kalman filter – the code • Open file ”run_toy_kalman.m” • Let’s have a look at the resulting PDF files About the model 20/34 Open economy model • So far, we’re using very simple model that doesn’t have many important features: − No exchange rate − No nominal interest rates − No trends • Let’s fix that, we’ll build the smallest open economy model possible About the model 21/34 Exchange Rates • We assume open capital account. The exchange rates are thus determined through standard Uncovered Interest Parity (UIP) equation. it = (Est+1 − st) + i∗ t + premt + εt Est+1 = αst+1 + (1 − α)(zt + πss − π∗,ss ) • Can anyone explain the logic? • We also define the real exchange rate zt using price level pt zt = st + p∗ t − pt zt = zt + zt • What is real exchange rate? • Which exchange rate is more important? Which is more stable? Which is under control of the central bank? About the model 22/34 Exchange Rate Fundamentals • The medium-term fundamentals of the FX rate are given by the real exchange rate trend zt. • The RER trend accounts for a variety of factors influencing the real convergence of the block: terms of trade, productivity, ... zt = zt−1 + ∆zt + εz t ∆zt = ρz ∆zt−1 + (1 − ρz ) · zss + εz t • Country risk premium has similar, simple equation: premt = ρprem premt−1 + (1 − ρprem )premss + εprem t (1) About the model 23/34 RER in Czech Republic 1999:012001:012003:012005:012007:012009:012011:012013:012015:01 290 300 310 320 330 340 350 Czech Republic: Real Exchange rate against the Eurozone (100*log) RER HP Filter trend About the model 24/34 GDP Fundamentals • The medium-term fundamentals of the GDP are given by output potential yt. • It’s similar to RER trend: accounts for a variety of factors; terms of trade, productivity, ... yt = yt−1 + ∆yt + εy t ∆yt = ρy ∆yt−1 + (1 − ρy ) · yss + εy t • It’s important to understand the interpretation: − Output gap is a measure of how the economic activity affects inflation − Output potential is everything else – non-inflationary level of output About the model 25/34 Monetary policy in open economy • The central bank in reality sets short nominal interest rate it it = g1it−1 + (1 − g1)(rt + πtar + g2(Eπt+1 − πtar ) + g3yt) + εi t • The real interest rate is then given by the Fisher equation: rt = it − Eπt+1 • The real interest then again has gap and trend components: rt = rt + rt • And the trend is given as rt = r∗ t + ∆zt + premt About the model 26/34 What about IS curve and Phillips Curve? They change to yt = β1yt+1 + β2yt−1 − β3rt +β4zt +β5y∗ t + εy t and πt = α1Eπt+1 + (1 − α1 − α4)πt−1 + α2(yt) +α3zt +α4(∆st + π∗ t − πt) + επ t About the model 27/34 Open model IRFs • Let’s have a look • Open ”open_model.zip”, and run ”run_open_model_irf.m” About the model 28/34 Presentations for the next block • Groups of 3-4 people • Approx. 10 slides describing the economy of Azerbaijan in 2014: − What were the key sources of growth? − What were the sources of inflation volatility? − What happened to real exchange rate in 2005-2014? Why? − Who were the key trading partners? − What was the monetary policy regime? − Do not forget to have a look at balance of payments • We want to understand if the standard QPM model describes the Azeri economy well … • …and if not, what we should change About the model 29/34 Conditional forecasts Recall model solution: Xt = AXt−1 + Bεt Consider the following problem: • We have an information that something is going to happen • We know that the default model behavior is not right for the current situation, and we need to “rewrite” something • We condition on initial condition X0 • We condition on future “expert” information (εt, εt+1, . . .) • And also, we condition on the model as well (matrices A, B) About the model 30/34 Basic Set-up Consider the following model: [ x1 t x2 t ] = A · [ x1 t−1 x2 t−1 ] + B · [ ϵ1 t ϵ2 t ] We have endogenous (calculated by the model) variables and exogenous (given from outside) shocks. The simple, unconditioned forecast is then Period x1 x2 ϵ1 ϵ2 Init. Cond. t − 1 x1 t−1 x2 t−1 ϵ1 t−1 ϵ2 t−1 Forecast t x1 t x2 t 0 0 t + 1 x1 t+1 x2 t+1 0 0 t + 2 x1 t+2 x2 t+2 0 0 ... ... ... ... ... About the model 31/34 Soft Tunes • Soft tunes means that we impose non-zero value of the shock • The shock is still treated as exogenous input, and the model calculates the values of Xt • Suitable to represent for example: − Impact of VAT hike – we know what will be the (approximate) impact on inflation, but we do not know the resulting inflation outcome. − Model imperfection – we know the model fails to capture something in recent quarters and therefore filters shocks. We want to extend these shocks on the forecast. Period x1 x2 ϵ1 ϵ2 Init. Cond. t − 1 x1 t−1 x2 t−1 ϵ1 t−1 ϵ2 t−1 Forecast t x1 t x2 t 0 0 t + 1 x1 t+1 x2 t+1 0 0 t + 2 x1 t+2 x2 t+2 1.3 0 ... ... ... ... ... About the model 32/34 Hard Tunes • Hard tunes means that we directly impose the value of the variable • We exogenize one variable in one or more periods. For the equations to have a solution, we need to endogenize one shock in the corresponding periods: [ x1 t x2 t ] = A · [ x1 t−1 x2 t−1 ] + B · [ ϵ1 t ϵ2 t ] • Suitable to represent for example near-term forecast – we know the value of the variable, but we do not know how big the shock should be • But, we need to choose the shock ourselves. The choice of the shock matters! • General rule: hard tunes belong on short horizons, soft tunes on long horizons About the model 33/34 Hard Tunes cont. Assume we want to tune x1 t = 3: Period x1 x2 ϵ1 ϵ2 Init. Cond. t − 1 x1 t−1 x2 t−1 ϵ1 t−1 ϵ2 t−1 Forecast t 3 x2 t ? 0 t + 1 x1 t+1 x2 t+1 0 0 t + 2 x1 t+2 x2 t+2 0 0 ... ... ... ... ... Or we can choose the other shock: Period x1 x2 ϵ1 ϵ2 Init. Cond. t − 1 x1 t−1 x2 t−1 ϵ1 t−1 ϵ2 t−1 Forecast t 3 x2 t 0 ? t + 1 x1 t+1 x2 t+1 0 0 t + 2 x1 t+2 x2 t+2 0 0 ... ... ... ... ... About the model 34/34 Combining tunes We can combine both methods, as long as we do not ”overtune” = impose unsolvable conditions: • We will hard tune x1 t , explained by ϵ1 t • We will also impose soft tunes on ϵ2 Period x1 x2 ϵ1 ϵ2 Init. Cond. t − 1 x1 t−1 x2 t−1 ϵ1 t−1 ϵ2 t−1 Forecast t 3 x2 t ? 0.75 t + 1 x1 t+1 x2 t+1 0 0.5 t + 2 x1 t+2 x2 t+2 0 0.25 ... ... ... ... ... The system is flexible, but we need to know what we want to achieve.