# Bridging the Gap between Economic Modelling and Simulation: A Simple Dynamic Aggregate Demand-Aggregate Supply Model with Matlab

Authors: José M. Gaspar
Journal: Journal of Applied Mathematics
 (2018)

---

## Abstract

This paper aims to connect the bridge between analytical results and the use of the computer for numerical simulations in economics. We address the analytical properties of a simple dynamic aggregate demand and aggregate supply (AD-AS) model and solve it numerically. The model undergoes a bifurcation as its steady state smoothly interchanges stability depending on the relationship between the impact of real interest rate on demand for liquidity and how fast agents revise their expectations on inflation. Using code embedded into a unique function in Matlab, we plot the numerical solutions of the model and simulate different dynamic adjustments using different parameter values. The same function also accommodates the analysis of the impacts of fiscal and monetary policy and supply side shocks on the steady state and the transition dynamics of the model.


---

## Body

## 1. Introduction

This study seeks to provide a contribution of potential interest to researchers both within the economics profession and from different fields by highlighting the connection between analytical results and computer simulation. Our purposes are twofold: (i) we seek to show, starting from a simple dynamic inflation model used in Economics, how we can use the computer to provide “end user” programs that are potentially useful and also easy to use by analysts and (ii) sensitize researchers in economics and other mathematically intensive sciences to the fact that numerical simulations should not be shun away based on the ground that they are only useful when explicit or closed form analytical solutions cannot be obtained [1, 2] (however, we do not claim that there are no economists who made extensive use of computational capabilities, specially in the fields of agent-based modelling and simulation. See, e.g., Macal and North [3, 4] and Macal [5] for an overview on the state of the art). With this in mind, our paper analyses a simple dynamic inflation model, the aggregate demand-aggregate supply (AD-AS) model. We first derive analytical results and study the qualitative properties of its equilibria through local stability analysis. We then proceed to show numerical results to illustrate global dynamics and phase plots that depict transition dynamics that occur when we introduce changes in exogenous economic variables.The AD-AS model is one of the bulwarks used in economic theory to explain economic fluctuations and business cycles. Its dynamic version presented here can be used to assess the dynamic adjustments of output and inflation after different macroeconomic shocks. Due to the specification of the model, it is possible to verify that the equilibria of the model interchange stability depending on the relation between the sensitivity of the demand for liquidity to variations in the interest rate and how fast agents revise their expectations on inflation. In fact, we can characterize the model’s fixed points as stable or unstable spirals, or as stable or unstable nodes (we shall see in Section4 that unstable nodes turn out to be numerically ruled out). This qualitative change in the local flow near the equilibrium is explained by the existence of a (degenerate) Hopf bifurcation as the pair of eigenvalues yielded by the corresponding two-dimensional dynamic system crosses the imaginary axis along a smooth parameter path where the impact of the real interest rate on the agents' demand for real money steadily increases.Contrary to many business cycle studies (e.g., [6–12]), the absence of nonlinearity in our simpler setup rules out the possibility of limit cycles and other more complex economic behaviours (typically, a Hopf bifurcation requires the branching from an equilibrium into a periodic orbit. Here, we use the term “Hopf” just to highlight the fact that a fixed point looses stability as the eigenvalues of the Jacobian at the fixed point cross the imaginary axis of the complex plain). De Cesare and Sportelli [13], Neamtu et al. [14], Zhou and Li [15], and Sportelli et al. [16] provide an interesting study on how limit cycles generated by Hopf bifurcations may arise in inflation models when there exists a finite lag between the accrual and payment of taxes, which implies a qualitative study of delay differential equations.Using code embedded in a single function developed in Matlab, we portray the global dynamics of the model using different parameter values by means of an illustration that includes, not only the evolution of real output and inflation throughout time but also a phase diagram that fully describes the qualitative properties of its equilibria and the transition dynamics. This code also allows us to simulate different types of exogenous shocks, both individually and simultaneously, to the economy, and their impact on the economy’s main aggregate variables, that is, real output and inflation. The simulations numerically depict the transition dynamics and adjustment processes of the state variables after the shocks occur. We consider three types of shocks: monetary supply shocks, fiscal policy shocks, and supply side shocks. The first shocks operate through changes in the growth rate of money supply. Fiscal policy shocks are consequences of changes in either the level of public spending or the exogenous tax rate. The latter shocks are technological shocks that exogenously affect the level of natural output. The Matlab function also allows for the combination between the different shocks.As noted by Wilson [17], the purpose of illustrating mathematical results derived from models in a clear and appealing way is often defeated by the inherent intractability of more cumbersome frameworks. Thus, it is our contention that there is a need for a more open mindedness of economists (and also researchers in other fields). Therefore, we hope to motivate to the fact that analytical analysis and numerical assessment should be complementary, not substitutes (however, certifying this complementarity implies that previous model verification and validation are essential [18]). By means of a simple yet insightful macroeconomic model, our computational approach provides illustrations that are both intelligible and visually attractive. Therefore, it allows us to clearly convey the messages behind the analytical analysis of the model by means of a compact and complete illustration, thus contributing to further connect the bridge between modelling and computer simulation (our effort thus goes along the lines of the technical appendix developed by King et al. [19], who describe the methods and software used to analyse in detail the neoclassical economy in the seminal works in King et al. [20, 21]). From a prospective view, the choice of a simple dynamic inflation model is thus intentional. It also seeks to appeal to readers who are not acquainted with economic theory and its models but are still able to understand the economic intuition behind the results of the simple model presented here.The organization of the rest of this paper is as follows. Section2 derives the model and studies its analytical properties. Section 3 contains simulations for different parameter values, each specification pertaining to a different phase portrait. Section 4 addresses the simulation of different shock types. The last section is left for concluding remarks.


## 2. Model and Analysis

The model presented here loosely follows the one proposed by Shone [22, chap. 9] We begin by deriving the aggregate demand side, the “investment-saving” and “liquidity preference-money supply” (IS-LM) model. Starting with the goods market (IS curve), consumption is given by(1)c=c0+b1-τy,0<b,τ<1,where y is both real aggregate output and aggregate income, c0 corresponds to autonomous consumption, τ is the exogenous tax rate, and b is the fraction of disposable income, (1-τ)y, that agents wish to consume. Investment i is equal to(2)i=i0-hr-πe,h>0,where i0 corresponds to autonomous investment, r stands for the nominal interest rate, πe is the expected inflation rate, and h is a parameter that captures how agents are sensitive to variations in the real interest rate, r-πe. The higher the real interest rate, the lower the investment level.Real output is given by(3)y=c+i+g,where g corresponds to the exogenous level of government spending. Plugging (1) and (2) into (3) we are able to derive the IS curve.The money market (LM curve) is described by the following equations:(4)md=ky-dr(5)ms=m-p,where md represents real money demand in logs, ms is the real money supply in logs, p is the logarithm of the price level, m is the logarithm of nominal money supply, and d and k are the values of the money balances demand’s sensitivity to variations in the nominal interest rate and in real output, respectively. Equilibrium in the money market requires that md=ms. Using (1), (2), (3), and (5), we can solve for the equilibrium’s level of real output, y≡y∗ and the equilibrium’s real interest rate r≡r∗, which yields(6)y∗≡y=c0+i0+g+h/dm-p+hπe1-b1-τ+hk/d(7)r∗≡r=ky∗-m-pd.Hereinafter, we shall focus solely on y∗. Notice that (6) is linear in real money supply m-p and expected inflation πe. Therefore, we can rewrite (6) as(8)y=a0+a1m-p+a2πe,where(9)a0=c0+i0+g1-b1-τ+hk/d,a1=h/d1-b1-τ+hk/d,a2=h1-b1-τ+hk/d.Equation (8) represents our aggregate demand (AD) curve, since it denotes equilibrium in both the goods and money market.Turning to the aggregate supply side, we assume that the rate of inflation is proportional to the output gap and adjusted for expected inflation as follows:(10)π=αy-yn+πe,α>0,where yn is the natural level of output, α is a constant, and the output gap equals y-yn. This is our aggregate supply (AS) curve. It stems from the combination between an augmented Phillips curve π=πe-a(U-Un), which states that actual inflation π is decreasing in the deviation of unemployment rate U relative to its natural level Un (i.e., actual inflation equals expected inflation minus the variability in unemployment times the constant a) and Okun’s law, whereby U-Un=-b(y-yn), with a,b>0 (Okun’s law states that higher output gap leads to lower unemployment rates. I refer the reader to Lee [23] for a detailed explanation and also its robustness based on empirical evidence). The AS curve represents a situation where prices are completely flexible. Thus, in equilibrium, actual inflation π equals expected inflation πe and output y equals its natural level, yn, whatever the price level p.Introducing a dynamic adjustment for inflationary expectation and taking the derivative of (8) with respect to time, we get the full model:(11)y˙=a1m˙-π+a2πe˙,a1,a2>0(12)π=αy-yn+πe,(13)πe˙=βπ-πe,β>0,where dotted variables denote their derivatives with respect to time (we omit the explicit dependence of state variables on time to simplify notation, whenever reasonable). The parameters a1, a2 capture how the rate of change of output y˙ reacts to real money supply growth rate (m˙-π) (recall that m denotes nominal supply in logs. Hence, its derivate is approximate to its growth rate), on the rate of change of expected inflation πe˙, respectively. The parameter β measures how expected inflation changes according to the difference between actual inflation and expected inflation. The adaptive expectations scheme for expected inflation in the last equation shows that agents revise their expectations upwards whenever inflation at any given time is higher than the expected inflation at that same time. Equation (11) is the demand pressure curve. To consider the dynamics of the model, we shall reduce it to 2 differential equations. Using (12) and (13) together, we obtain(14)πe˙=αβy-yn.Next, we take (12) and (14) and plug them into (11) to get(15)y˙=a1m˙-αy-yn+πe+a2αβy-yn⟺y˙=a1m˙-αa1-a2βy-yn-a1πe.Thus, the dynamics of the model are fully described by the following two differential equations:(16)y˙=a1m˙-αa1-a2βy-yn-a1πe(17)πe˙=αβy-yn.Notice that the two state variables are real output y(t) and expected inflation πe(t). However, actual inflation π(t) can be readily obtained from the AS curve in (12). Hence(18)πt=αyt-yn+πet.A steady state implies that πe˙=0 and y˙=0. From the first condition and using (17), we get y=yn. Combining this result with the second condition we end up with πe=m˙. From the AS curve it immediately follows that π=πe=m˙ at steady state. That is, in equilibrium, real output is given by the natural level of output and actual inflation is equal to the growth rate of the money supply. Given the system in (17), from the πe˙=0 locus we can see that if y>yn, expected inflation πe is rising. Conversely, if y<yn, πe is declining. Considering the y˙=0 locus we have(19)πe=m˙-1-a2βa1y-yn.Thus, what happens to y above or below the y˙=0 locus depends on the slope of the previous equation. If 1-a2β/a1>0, the previous equation is negatively sloped. Hence, to the left or below the y˙=0 locus, y is increasing (this condition is assumed in Shone [22]. As we shall see further ahead, this condition is sufficient for stability of the equilibrium of the model. For the sake of numerical presentation, I do not assume this holds a priori). To the right, there are forces decreasing the level of output y.Now, consider again the dynamical system in (17). The Jacobian matrix of the system at equilibrium is given by(20)J=-αa1-a2β-a1αβ0.It is straightforward to check that the determinant of the matrix in (20) is equal to det(J)=a1αβ>0. Since it is positive, there are no eigenvalues with real parts of opposite sign. Hence there are no saddle points.The trace of the matrix is given by(21)trJ=-αa1-a2β⟺trJ=-αh1/d-β1-b1-τ+bk/d.Since b(1-τ)<1, the denominator of tr(J) is positive. Moreover, since α>0, the trace is negative if and only if 1/d>β. Hence, we can say that the equilibrium is stable if 1/d>β and unstable if 1/d<β. The condition that 1/d>β is exactly the same as requiring 1-a2β/a1>0. This means that if the y˙=0 locus is negatively sloped, the equilibrium (y∗,πe∗)=(yn,m˙) is stable. This is assumed ex-ante in Shone [22], but not here.A necessary and sufficient condition for the existence of complex eigenvalues requires4det⁡(J)-tr(J)2<0; that is,(22)4a1αβ>α2h1/d-β1-b1-τ+bk/d2⟺4βd>αh1/d-β21-b1-τ+bk/d.A low enough α favours oscillatory solutions. Finally, if d=1/β we get a null trace and complex eigenvalues because 4β/d>0. Moreover, the equilibrium is a stable (in the Lyapunov sense) centre, because the eigenvalues are purely imaginary. Thus, the equilibrium is stable if and only if 1/d≥β. From the preceding analysis, we can sum up the different qualitative properties of a steady state in the AD-AS model in the following proposition.Proposition 1.
Depending on the parameters chosen, a steady state in the dynamic AD-AS model can be characterized as a stable or unstable node, a stable or unstable focus (spirals), or a centre.The possibility of an interchange between diverging and converging oscillating trajectories suggests that the AD-AS model undergoes a bifurcation. Suppose that the agents’ preference for liquidity (i.e., money demand) becomes increasingly sensitive to changes in the real interest rate. Formally, we have the following assumption.Assumption 2.
Let us consider a smooth parameter path whered steadily increases; that is, d is a bifurcation parameter.Analysing the relationship between the sensitivity of money demand with respect to the real interest rated and the way agents revise their expectations on inflation based on the prediction error π-πe, which is captured by β, allows us to provide the following result.Proposition 3.
The system described by (17) undergoes a degenerate Hopf bifurcation at d=d0=1/β.Proof.
See AppendixA.The existence of a (degenerate) Hopf bifurcation explains the transition from a stable focus to an unstable focus, as the eigenvalues cross the imaginary axis at nonzero speed. On the other hand, the linearity of system (17) in its state variables forcibly precludes the existence of limit cycles branching from the steady state; that is, the only periodic orbits occur when d=d0 and the equilibrium is a Lyapunov stable centre. As the model undergoes the bifurcation, the value of the money balances demand’s sensitivity to variations in the nominal interest rate d is inversely proportional to how fast agents adjust their expectations on inflation.


## 3. Numerical Evaluation

In this section we present some numerical simulations with different parameter values, illustrating the four different types of equilibria and dynamic adjustments that may arise in the AS-AD model. All presented output is generated from a single function embedded in a Matlab script file (the codes in both html and pdf formats can be found through the link:https://sites.google.com/site/josemlopesgaspar/downloads. The description of the Matlab script file is added as a supplemantary material in both pdf and m-file formats (available here). ASADdynamic.m file is additionally available through Github: https://github.com/josemgaspar/Matlab-codes/blob/master/ADASdynamic.m).For the moment, we shall refrain from the introduction of shocks to the model, which is left for the next section. The function’s output is twofold. First, it presents the values of the parameters used, as well as the steady state values for real output and expected and actual inflation. For the sake of presentation, an illustration of the output shown in Matlab’s command window is presented in AppendixB. Second, it provides illustrations for the evolution of the solutions, along with an intuitive phase portrait.The first simulation, which uses the default parameter values in the program, depicts the transition dynamics for the solution when the equilibrium is a stable focus. The parameters used arec0=10;i0=5;G=5;b=0.8;k=0.05;d=0.05;h=0.1;τ=0.3;α=0.1;β=1;m˙=0.01;yn=1. The initial conditions are y(t0)=0.05 and πe(t0)=0.15, where t0=0 is the initial time.We have1/d>β; hence the steady state (y∗,πe∗)=(yn,m˙) is stable, as we can see from Figure 1. Also, the solutions are clearly oscillating. One can check that actual inflation oscillates more than the expected inflation and, naturally, the latter follows the first in its adjustment. Figure 2 illustrates the phase diagram which depicts the stable spiral.Figure 1
Simulation(1). (a) Solution for y(t). (b) π(t) and πe(t).
(a) (b)Figure 2
Simulation(1). Phase diagram depicts a stable focus.The second simulation presents a different dynamic adjustment. We setd=0.5 and β=2, all other parameter values remaining equal. Since 1/d=β the equilibrium is now a stable centre. The evolution of output and expected and actual inflation and the phase diagram are depicted in Figures 3 and 4, respectively.Figure 3
Simulation(2). (a) Solution for y(t). (b) Solutions for π(t) and πe(t).
(a) (b)Figure 4
Simulation(2). Phase diagram shows that the equilibrium is a stable centre.Both figures show that there is no convergence or divergence towards the steady state, as the latter is only stable in the Lyapunov sense. All solutions are periodic orbits with periodT=2π/ω, where ω is the imaginary part of the corresponding complex eigenvalues.Figure4 presents no y˙=0 locus, since its slope is equal to zero, as we can infer from the analysis in the previous section.For the third simulation, we now setd=1 and β=1.2, with all other parameter values equal to the default setup. Inasmuch as β>1/d we know that the equilibrium will be unstable. Moreover, because of this, y˙=0 is negatively sloped. Furthermore, with this set of parameters, the equilibrium can be shown to be an unstable focus (recall also that α is very low), so the solution oscillates away from the steady state. This is confirmed by Figures 5 and 6.Figure 5
Simulation(3). (a) Solution for y(t). (b) Solutions for π(t) and πe(t).
(a) (b)Figure 6
Simulation(3). Phase diagram illustrates an unstable focus.Once again, we can see that expected inflation follows up closely after actual inflation, reflecting the way by which expectations are formed.In the fourth simulation we setd=0.025 and dramatically decrease β to 0.1. Now the eigenvalues are real and, since 1/d>β, the equilibrium is a stable node.By inspection of Figure7 one can observe that, contrary to the previous cases, expectations are now formed correctly, as expected inflation now decreases steadily towards the steady state level, whereas actual inflation overshoots its equilibrium level, following the evolution of real output.Figure 7
Simulation(4). (a) Solution for y(t). (b) Solutions for π(t) and πe(t).
(a) (b)Figure8 shows the phase diagram where we can observe that the steady state is a stable node in the fourth simulation.Figure 8
Simulation(4). Phase diagram illustrates a stable node.Remark 4.
The parametrization required for the equilibrium to become an unstable node seems implausible as it imposes either exceedingly high values forα or implies trajectories assuming negative values for output. Therefore, we rule out this possibility.


## 4. Modeling Shocks

In this section we introduce three different types of shocks to the dynamic AS-AD model. A combination between any of the shocks is possible, but for the sake of presentation we simulate each separately and report the results. The baseline set for parameter values presented here is the same across all simulations and is equal to the default (first) setup presented in Section3.First, we run an expansionary fiscal policy shock, setting new values for public spending and the tax rate atG=5.5 and τ=0.25, respectively, after the program asks for the implementation of policy shocks. Previous to the shock, the economy is at equilibrium with π=πe=0.01 and y=1. After a permanent increase in the government spending and permanent decrease in the tax rate at the initial time t0, the economy must jump up to a higher level output. This is given by the AD curve in (8). At t0, real output y jumps to a new level y0=2.0799 (this result is given by the new initial condition y0 from the output in the command window from Matlab. See Appendix B.2 for more details). The economy is now further away from its equilibrium level. Since the level of natural output is unchanged, the economy will converge to its initial equilibrium level and will do so in an oscillatory fashion, after a very sharp decrease in output in the first periods. Conversely, inflation increases sharply after t0 (however, it does not change at t0) but then starts to converge to its initial value, also oscillating. This situation is described in Figure 9.Figure 9
Fiscal policy shock. (a) Solution fory(t). (b) Solutions for π(t) and πe(t).
(a) (b)Theπe˙=0 and y˙=0 loci are unaffected after the shock and the steady state lie at their intersection. Figure 10 shows the phase diagram, with the economy slowly returning to the steady state after its deviation at t0 due to the fiscal policy shock.Figure 10
Phase diagram portraying the dynamic adjustment after a fiscal policy shock.The second shock is an expansionary monetary policy shock. We set the money supply growth ratem˙=0.04 once the function asks to set new parameter values. Once again, previous to the shock, the economy is at equilibrium with y=yn=1 and πe=π=m˙=0.01. After the shock occurring at t0, the y˙=0 locus (11) shifts upwards. Hence, the economy is out of equilibrium and will oscillate towards the new steady state, where y=1 and πe=0.04. This situation is reported in Figure 11.Figure 11
Monetary policy shock. (a) Solution fory(t). (b) Solutions for π(t) and πe(t).
(a) (b)Initially, output will rise as will inflation. Aftery crosses the y˙=0 locus, it will start to decrease while inflation continues to rise. Only when the solution crosses the πe˙=0 locus will inflation start to fall. At this point, expected inflation will lie above its steady state value and output will be lower than yn. The oscillating process continues as output converges to its natural level yn=1 and expected and actual inflation converge to their new equilibrium value m˙=0.04. This process is illustrated in Figure 12.Figure 12
Phase diagram portraying the dynamic adjustment after a monetary policy shock.The third and final shock we consider is a supply side shock. It is given by a positive technological shock which, for exogenous reasons, affects the natural level of output, such thatyn=2. At the time of the shock, both πe˙=0 and y˙=0 loci shift rightwards, which is straightforward from (12) and (11). Hence, the economy will adjust towards the new steady state given by the intersection between the two new curves. Since the growth rate of money supply is unchanged, we can anticipate that the steady state levels of actual and expected inflation are the same and given by π=πe=0.01. However, real output at the new steady state is now given by y=yn=2. Again, convergence towards the new equilibrium is oscillatory, with a decrease in both actual and expected inflation and an increase in real output in the first periods. This case is depicted in Figures 13 and 14.Figure 13
Supply side shock. (a) Solution fory(t). (b) Solutions for π(t) and πe(t).
(a) (b)Figure 14
Phase diagram portraying the dynamic adjustment after a supply side shock.


## 5. Concluding Remarks

We studied the dynamic properties of a simple dynamic version of the well known AD-AS model and used code, embedded in a single Matlab function, to simulate the model in order to numerically analyse the dynamic adjustments in the economy under a wide array of different applications concerning policy shocks.By standard analytical inspection of the linearised system of the resulting two differential equations, we find that the inflation model may have either stable or unstable spirals (focuses), or nodes, but no saddle point equilibria. Unstable nodes are ruled out numerically. A degenerate Hopf bifurcation occurs when the value of the demand for money balance’s sensitivity to variations in the nominal interest rate is inversely proportional to the way expectations on inflation are formed, which explains the smooth transition between unstable and stable focuses. However, the model’s linearity naturally rules out any possibility for occurrence of limit cycles.Numerical simulations of the model with recurrence to the function developed in Matlab allow for the illustration of different cases of dynamic adjustments, with a complete description of the results. Furthermore, the function conveniently accounts for the possibility of implementing different shocks after the initial simulation. These shocks pertain to monetary and fiscal policy shocks and supply side shocks. The function also shows how the transition to new steady state levels may occur, with appropriate illustrations and output.One of our goals is to motivate researchers both within and outside the economics profession for the prospective complementarity in both analytical and numerical approaches. Shunning away computer simulations for the sake of closed form solution and elegant mathematics may preclude tackling more realistic settings, or otherwise intractable. This could thwart possible theoretical and empirical contributions that are potentially relevant for policy makers.Admittedly, the AD-AS model is oversimplifying in its assumptions and limited in accounting for complex business cycles and other economic phenomena. We do not see this as a contradiction in our goals, nor does it defeat our purposes. For instance, further extensions of this simple setup could build theoretical improvements based on microfoundations for Keynesian aggregate demand and aggregate supply such as in Farmer [24]. Other possible developments would include incorporating technological changes and determine their impact on economic growth rates, following works such as Dutt [25].It is in our view, however, that the simplicity and perceptiveness of the AS-AD model studied here allows us to better convey our message and thus contributes to further connect the bridge between economic models’ analytical results and computer based numerical simulations.



---

*Source: 3193068-2018-01-16.xml*