So far on this blog, I have mainly focused on machine learning, and models of events that are driven by econometrics. But the truth is that I am an economist (with a doctorate). As such, I get asked all of the time about where I think that the economy is going (especially recently). That seems to be what is interesting to people. I try to explain that there are different kinds of economists and that they focus on different aspects and industries of the economy. For example, in my dissertation I focused on the economics of natural gas. I actually, knew very little about macroeconomics. Maybe a lot more than the average person, but probably a lot less than a lot of PhDs in economics (especially traditional macroeconomists). Most of my focus was on applied econometrics (give me a really compelling identification strategy please).

Yet, I can’t seem to ditch this perception that all economists sit around and try to divine what Jerome Powell is going to do at the next FOMC meeting. So rather than try to fight that. I decided to steer into the skid, as it were. I jumped into the literature and started looking at the main workhorse of modern macroeconomic thought, the DSGE model.

I want to explain this model to you.

DSGE Model

DSGE is an acronym. It stands for Dynamic Stochastic General Equilibrium model. For a non-economist all of those words are probably pretty scary. I get it. But in some sense they tell you exactly what the model does and it isn’t so bad. So let’s break this class of model down.

First of all, these models are dynamic. That means that the model accounts for time. They deal with time series and as such they need to be able to forecast, they need to respond to changes in input, and they depend on the past. The models, are in some sense moving. That is why they are called dynamic.

Second, they are stochastic. If you have never seen that word before, it means that random stuff happens to these models. There is an element of randomness to the model. Remember, how we were all blindsided by the pandemic? These models account for random shocks that can occur in any sector. Granted the Covid-19 pandemic was a major shock, and one that was something of a black swan event. At least in terms of its magnitude, it was extreme. That requires some finesse in how the model handles something that big, but smaller shocks constantly happen, for example, changes in consumer sentiment. So random stuff is accounted for by these models.

The third and final component is the general equilibrium piece of the puzzle. What in the world does that mean? It simply means that prices are determined within the model, along with the quantity of the things that those prices measure. Usually, in macroeconomics that means that inflation and interest rates as prices and the levels of capital and consumption goods as the quantity that is being modeled. This is opposed to a partial equilibrium model where prices are handed down to us from the gods and everyone just accepts them. In a partial equilibrium model, we take the prices as given and compute quantities only.

Okay so if you have those three components, it is a DSGE model.

Now notice, that doesn’t mean that DSGE is a model in and of itself. There is no universal DSGE model. Instead it is an entire class of models. I can build a DSGE model, and so can you and they can be radically different from each other. They just have to be Dynamic, have Stochastic shocks within them, and be General Equilibrium models that spit out quantities and prices. In fact, a DSGE model can be implemented for a micro-economic phenomenon instead of a macro-economic phenomenon. That being said, they are the workhorses of modern macro-economic models because they provide a really good framework for thinking about the economy as a whole.

Forecasting the Economy

Alright, so this is kind of disingenuous. The code, I am about to drop on you is terrible, and it won’t give you a sense of what a DSGE model is and how it works. This model is hiding a lot of its equations by having a solved system. But the idea is this is how the forecasting works. Once you have a model with estimated parameters, you can just run it forward a bunch of times. This will give you an estimate of what the economy is going to do. So without further ado, here is some python code:

import numpy as np
import matplotlib.pyplot as plt

# Parameters
alpha = 0.5
beta = 0.9
delta = 0.1
sigma = 0.2
T = 100  # Number of time periods

# Initialize variables
k = np.zeros(T)
c = np.zeros(T)

# Initial conditions
k[0] = 0.5

# Simulate the model
for t in range(1, T):
    c[t] = (1 - delta) * k[t-1] ** alpha
    k[t] = c[t] + (1 - delta) * k[t-1] + np.random.normal(0,5)

# Plot the results
time_periods = np.arange(T)
plt.plot(time_periods, c, label='Consumption')
plt.plot(time_periods, k, label='Capital')
plt.title('DSGE Model: Consumption and Capital')

Here is the output from this toy model:

Again, I am just running things forward from an initial point in a known model. However, things aren’t quite as easy as they sound. You need to estimate the parameters of your DSGE. You probably, want a model of the world that is more complicated than this that accounts for a lot more than the code above. Yet, this model shows the dynamic and stochastic nature of the model really nicely.

Now then, the question becomes, how do I estimate a DSGE model. That can get quite complicated. Fortunately, you don’t have to. You can of course build your own, or you can just read my report where I run a DSGE (the same one that the NY fed uses), and I interpret the results for you check it out.

Leave a Reply

Your email address will not be published. Required fields are marked *