r/MachineLearning • • 3d ago

Project Time Series Lag Problems [P]

Hi everyone, I'm having an issue with lags on time series models predicting U.S. housing prices (FHFA HPI as the target) and I can't figure out where they're coming from (I'm no expert by any means). I've hand-built simpler models, but I'm using Claude Code for this project because it's larger. I've collected over 600 features: global, national (40 countries), and metro (393 U.S. metros). The attached table shows the different models we've tried - starting simple'ish and moving to building our own hierarchical transformer. The problem (the attached charts show an example) is that all the forecasts significantly lag the actual observations - ON ALL THE DIFFERENT MODELS by roughly the same amount. A 1-year forecast lags actuals by about 4-5 quarters. A 2-year forecast lags actuals by about 8-9 quarters. Same with 3- and 5-year (charts attached). On all runs. So the lag is pretty much the exact forecast horizon. I've experienced late calls on turns before, but nothing so consistent across all model types. So I'm pretty sure I'm doing something wrong, but don't know what. Any ideas or help would be appreciated.

4 Upvotes

4 comments sorted by

2

u/martinetmayank 1d ago
  1. What's your insample accuracy?
  2. have you done any feature engineering? or just passing all features at once?
  3. are those features really having any impact or is it just causation?
  4. any sort of time feature?
  5. what was the criteria for selection of lags?
  6. have you tried what the univariate looks like (to establish a baseline)
  7. why go to a complex model directly (I'm just curious). We, start with univariate and then LR (and it's variation) then Trees and finally DL (this is for FMCG/CGP industry)

1

u/moucha10 1d ago
  1. It varies by type of model (in sample/out of sample): linear (6.3/9.5), trees (2.4/9.4), LSTM (2.8/13.9), flat transformer (4.3/10.9), hierarchical transformer (5.5/9.8). We tried other simpler models and then complex. The simpler models had closer in/out sample results. The more complex had wide results. The hierarchical transformer performed better than all other complex models. I think this makes sense because real estate is a hierarchical industry.
  2. Yes, we tried single feature, small subset of likely features, grouped by category (credit, affordability, economic, etc.), and all features (93 total global and national features). We also tested on changes, direction, momentum, and some hand-built features based on relationships (current vs. avg, ratios over time). Even some regime detection with Markov-switching and change-point detection.
  3. They didn't have an impact. All approaches still have a lag. Some reduced the lag, but not sufficiently. And all lags are right around the forecast horizon (4-5 quarters for a 1-year forecast, 8/9 quarters for a 2 year forecast, same for 3- and 5-years).
  4. Not sure what you mean on this one. We used cycle-timing, quarters since last turn, peak to trough, inflection points. Let me know if you mean something different.
  5. I've tried everything between 1 and 20 quarters. Part of this is to see where each model performs well and where they don't. For training, we chose look-back windows of 4 quarters, 3 years, 5 years, 15 years. For the transformers we went back a little further.
  6. Yes, the univariates are close the best. This kind of makes sense because real estate stays linear for long periods. But that's the easy part. It (or others) doesn't capture the peaks and troughs. I'm less concerned about getting the magnitude of growth right as I am about predicting peaks and troughs.
  7. We did start simple. Not sure why the attached table sorted them the way it did, but we started very simple, tuned, tested, tried different things, and then went to the next category. Transformers were last. My thesis was that a hierarchical transformer would work better because of longer time horizons and transfer learning across hundreds of metro areas. But doesn't seem to be the case.

Real estate is smooth and slow, so we should be finding better signal. At least at shorter horizons. If forecasts weren't great at 3-5 years I would be less worried. But there are visible signs of a slowdown in housing, commercial, etc. 1-2 years prior that should at least be improving those shorter-term forecasts. None of these models are catching that.

1

u/martinetmayank 1d ago
  1. what does 2.3 (or other number) here means? is it MAPE or Bias or something else?
  2. it seems like there are lots of features. May I know the number of rows the data have? is it one city? Were you running a global model or a local model?
  3. Looking at the plot gives an idea that something happened in that time period, kind of an "event" which triggered that sudden peak. The 1st peak is right around the time of the 2008 financial crisis while the 2nd one is during Covid. This is my initial hypothesis, just have a look at some global factor or event which might have affected this. But this should have a negative impact, price should decrease, not increase. Just have a look at it.
  4. Time as in, sin/cos of calendar month or Month Target encoded values as a feature so as to capture Seasonality
  5. i personally would not go beyond lag 8 (in terms of quarter) as 2 years would be more than enough unless those lags show a very high correlation
  6. Again, look at some global events
  7. Okay

Well, looking at the graph my intuition would be that 2 macro events which I told you. Before the 08 crisis, loans were very cheap (so a peak in 06-07) in US and then 08, Leehman Brothers collapsed which took industry with it. Interest rates rose, so a dip (in 09-10)

In Covid, i think the Fed has reduced interest rates again, so as to increase consumption, which shows an in increase just after Covid.

Again, I'm not from US, but these are my hypothesis. Please do research on this angle as well. If true, No model could have predicted this.

1

u/patcpsc 20h ago edited 5h ago

A few things leap out:

- 4-5 quarters is roughly a year. 8-9 quarters is roughly 2 years. A simple model f(x) = x (i.e. the best estimate of the value 1 or 2 years out is the current value) would probably outperform many of these models. I could be misreading your charts - but I suspect your models are finding equivalents of f(x) = x.

- the time series is non stationary, very autocorrelated. Typical approach in this instance is to first difference the result and forecast the growth rate and not the level. So take your dependent [n.b. edit] variable i.e. the price index, and transform it y_t -> (y_t - y_{t-1})/y_{t-1}, either at monthly or quarterly levels.

- have a look at ARMA models. Econometrics people would start there, and my guess is you'd get better results from a simple ARMA model. Maybe then a simple linear regression of the current index growth from previous period growth and a couple of key macro factors, e.g. gdp growth, interest rates. Once you've got some traction there I'd start playing with the more complex models.