Thursday, February 13, 2025

Predicting Gold Prices with SARIMAX

Not investment advice.
I collected 54 years of gold price data from the St. Louis Fed starting 9/30/71 (end of the US federal government fiscal year after gold was allowed to float). I also collected the 10-year treasury rate, US public debt, and inflation rate for the same dates. I used python to run some statistical models on the data and predict the gold prices for the next three years.
I cleaned up the data and scaled the debt down to be in line with the other data. Initial correlation of the variables showed a positive relationship with US debt, and negative correlations with the 10-year treasury rate and inflation. However, in the final analysis, the relationships were not what I expected.

Initial correlation of features with price
Price: 1.000000
debt (billions): 0.951928
treasury_rate -0.634155
inflation -0.288526


Here is a scatter plot of the price data:

I initially built two machine learning models that worked quite well within the known universe of prices, but did poorly at extrapolation. Time series models were a better choice to analyze financial data. I made one attempt using Meta’s prophet time series model, but could not find enough good documentation to use it. Then, I tried SARIMAX (Seasonal Autoregressive Integrated Moving Average + exogenous variables). It's a state space model, a type of mathematical model used to describe time series data, where the observed data is linked to an underlying, unobservable (latent) state that evolves over time. These models are particularly useful for situations where the system being modeled is influenced by both systematic dynamics and random noise. For future predictions, I created a set of estimated data with the following hypothesis:

- US debt continues to grow at the mean rate from 2017-2024
- inflation drops to 2.7% and stays there
- the 10-year treasury rate drops to 4.2% in 2025, then 3.8% the following two years

The model found that only US debt was statistically significant in determining gold prices. Neither the treasury rate nor inflation had significant impacts on the price. I found that surprising. As you can see from the chart, there was a pretty wide confidence interval in the predictions.

Predicted Gold Prices through 2027
9/30/2025 $2,838.27
9/30/2026 $2,985.15
9/30/2027 $3,130.70


No comments:

Post a Comment