This may be too broad a question, but I'm currently starting on a time-series model and was testing my potential variables for stationarity and found that a set of the predictors are stationary from 2008-2020 but a huge spike in the last two years makes them fail an adf test.

My question though is, when it comes to the actual modeling, what can be done to have the model still generalize well despite having a few years of hopefully a once-in-a-lifetime effect so recently? Besides just having a binary variable for "pandemic month" vs "non-pandemic month".

  • $\begingroup$ If there is a regime change, then one can employ Markov Switching Model, as is explained in Hamilton's book in Chapter 22. $\endgroup$ Sep 7, 2022 at 15:18
  • $\begingroup$ @User1865345 What is the title of that book? $\endgroup$
    – Galen
    Sep 7, 2022 at 16:39
  • 1
    $\begingroup$ Time Series Analysis, James D. Hamilton, Princeton University Press, 1994 @Galen. Hamilton provides a nice application using US real GNP data. $\endgroup$ Sep 7, 2022 at 16:59

1 Answer 1


If your time series exhibits 'anomalous behavior' in more recent observations, you necessarily have to remove or at least 'adjust' the data. Otherwise, your model performance will suffer for future events that don't relate to the previous outlier interval.

In this thread Rob Hyndman gave following advice that appears to be straight forward - although there may be more/better alternatives:

For non-seasonal time series, outliers are replaced by linear interpolation. For seasonal time series, the seasonal component from the STL fit is removed and the seasonally adjusted series is linearly interpolated to replace the outliers, before re-seasonalizing the result.

STL refers to Seasonal and Trend Decomposition using LOESS.

Hope this helps towards solving your problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.