ChatGPT, Python, FRED and some NGDP gaps

I have spent quite a bit of time recently playing around with ChatGPT and other AI tools like Midjourney.

One thing that I, like a lot of other people, am curious about is how I can use AI to improve what I am doing in economics and finance.

My answer to that question is “quite a bit.” I am not particularly impressed with ChatGPT when I ask it about economics and finance, but that really isn’t a disappointment.

Rather, I see ChatGPT as an excellent tool to do things more effectively, and what I have particularly found is that AI is helping me generate new ideas, to ask new questions in the area in which I am already doing research and advisory work – in general economics, monetary policy, finances, and the economics of sports.

Today, for the first time, I tried to use ChatGPT to help me code. I must say that my coding skills have been declining over the years as a result of using primarily Excel and having research assistants.

But over the last couple of years, I have been playing a little bit around with coding in Python, but I have found it hard to get started again and to use it frequently. So I have frankly been giving up on Python.

Something I do use a lot, however, is the St. Louis Fed’s FRED database with economic and financial data. That is a great resource – and it is free.

So today I got the idea – why not try to combine ChatGPT, Python, and FRED to answer some questions about the global economy?

And of course, as a market monetarist, I wanted to have a look at nominal GDP in different countries – more specifically on what I will here term the “NGDP gap.”

So I simply asked ChatGPT to write me a code for Python that, based on data, creates time series for the NGDP gap for the US, the euro area, Sweden, and Denmark based on data from the FRED database.

I asked ChatGPT to write a code that calculates the trend in NGDP with an HP-filter (it figured out itself that Lambda should be 1600 on quarterly data) and asked it to write the code to calculate the NGDP gap as the percentage difference between the actual level of NGDP and the trend-NGDP level and create graphs for this. I didn’t ask it to make any specific design recommendations regarding the graphs.

The graphs below are the result of this.

I am quite happy with the results, and I did not expect that I – along with ChatGPT, Python, and FRED – would be able to achieve this with just a couple of hours of work.

What really took time was ensuring that there was proper “communication” between the programs. But it all worked out in the end, and for the next project, I’m sure it will be a lot less time-consuming.

But why am I doing this? Not because I’m an AI enthusiast – I’m not – but because it makes it easier (and less time-consuming) to ask questions and find answers.

Returning to economics, what interesting results does this produce? Well, take a look at the graphs. The Great Recession of 2008-9 is certainly visible in all of the graphs above, as are the “lockdown shocks” of 2020 and the very strong and swift recovery in 2020-21. Most importantly, we see that in all four currency areas, there has been a massive overshooting, and the NGDP gap has turned strongly positive over the past 1-2 years.

This is particularly noticeable in my home country of Denmark, where the NGDP gap has now reached +6 percent, indicating extremely loose monetary conditions. This also suggests that it could take some time before inflation returns to 2 percent in Denmark.

It’s also worth noting that the NGDP gap in the Eurozone is somewhat smaller than in Denmark, indicating that the need for monetary tightening is greater in Denmark than in the Eurozone. However, given Denmark’s peg to the Euro, it is impossible to tighten monetary policy relative to the Eurozone – unless, of course, the krone is revalued against the Euro. That is not currently on the table and is not something being advocated by the Danish government or the Danish central bank. However, as inflation has spiked over the past year, the discussion of whether the peg should be maintained in its present form has begun to emerge.

In my opinion, the main reason that the NGDP gap has become higher in Denmark than in the Eurozone is primarily due to relative terms-of-trade shocks. While most Eurozone countries, like Germany, have been hit by negative terms-of-trade shocks due to the rise in energy prices in Europe, Denmark, on the other hand, has seen its export prices, such as shipping and pharma prices, skyrocket. If Denmark had had a floating krone, it would likely have appreciated against the Euro. Instead, we are now seeing a real appreciation of the krone via higher Danish inflation.

Anyway, I thought my readers might find it interesting that AI can help us – or at least help a soon-to-be 52-year-old economist – become a bit more productive, or at least answer familiar questions with new tools (or toys…).

Contact my speaker agent? Then see my page at Youandx here.

%d bloggers like this: