Choosing a Time Series Forecasting Method for Nonlinear Data
This guide walks you through selecting a forecasting method when your time series data is nonlinear—meaning patterns like trends, seasonality, or cycles change over time or don’t follow a straight line. You’ll learn how to assess your data, compare candidate methods, and pick the one that best balances accuracy and practicality. No prior experience with advanced statistics is needed, but familiarity with basic data plotting and train/test splits will help.
What You’ll Need
- Historical time series data (at least 2–3 full seasonal cycles if seasonality is present)
- Software: Python (with pandas, numpy, matplotlib, scikit-learn, statsmodels), R, or a spreadsheet tool for basic analysis
- Basic understanding of forecasting metrics (MAE, RMSE, MAPE)
- A way to plot your data (line charts, scatter plots)
Step-by-Step
- Visualize and characterize your data. Plot the series over time. Look for trends (up/down), seasonality (repeating patterns), cycles, sudden level shifts, or changing variance. Nonlinearity often appears as curvature, changing amplitude of seasonality, or non-constant variance (heteroscedasticity).
- Check for stationarity. Run an Augmented Dickey-Fuller (ADF) test or visually inspect rolling statistics. Nonlinear methods can handle non-stationary data, but knowing whether the series is stationary helps narrow choices. If the series has a clear trend, many models require differencing or detrending first.
- Identify the type of nonlinearity. Ask: Is the nonlinearity in the trend (e.g., exponential growth)? In the seasonality (e.g., amplitude grows with level)? Or in the noise (e.g., volatility clustering)? This determines which methods are appropriate.
- Set up a validation framework. Split your data chronologically: train on the first 70–80% and test on the last 20–30%. For small datasets, use time series cross-validation (rolling origin) to get more reliable performance estimates.
- Start with simple nonlinear baselines. Fit a polynomial trend (e.g., quadratic) or a log-linear model if growth looks exponential. These serve as cheap benchmarks. Also try a naive seasonal model (e.g., last season’s value) to see if any complex method beats it.
- Consider machine learning methods. For moderate to large datasets, tree-based methods (Random Forest, XGBoost, LightGBM) and support vector regression (SVR) can capture nonlinear relationships. Create lag features (e.g., value at t-1, t-2, …) and rolling statistics (mean, std) to feed the model. These methods don’t assume a fixed functional form.
- Try neural network approaches. For long sequences with complex patterns, consider LSTM (Long Short-Term Memory) networks or Temporal Convolutional Networks (TCN). These require more data (typically thousands of points) and careful hyperparameter tuning. If you have fewer than a few hundred points, they may overfit.
- Use statistical nonlinear models. If your data shows changing variance or volatility, consider GARCH-type models (for financial data). For regime changes, Markov switching models or threshold autoregressive (TAR) models are options. For smooth nonlinear trends, state space models with nonlinear observation equations (e.g., using the Kalman filter) work well.
- Compare models on the test set. Compute error metrics (MAE, RMSE, MAPE) for each candidate. Also check residual plots: if residuals show patterns, the model hasn’t captured all the structure. Prefer simpler models when performance is similar (Occam’s razor).
- Evaluate stability. Run a sensitivity check: change the train/test split slightly or use rolling-origin evaluation. A good method should have consistent performance across different windows. If a model’s performance varies wildly, it may be overfitting.
- Choose the best method and document. Select the model with the best validation performance that also meets practical constraints (computational cost, interpretability). Record the exact parameters and preprocessing steps for reproducibility.
Common Mistakes
- Ignoring seasonality: Using a nonlinear model without accounting for seasonality can lead to poor forecasts. Always include seasonal features or use methods that handle seasonality (e.g., seasonal-trend decomposition using LOESS – STL).
- Overfitting with complex models: LSTMs and XGBoost can easily memorize noise. Use regularization, early stopping, and cross-validation to avoid this.
- Not scaling data: Neural networks and SVMs require feature scaling (e.g., min-max normalization) to converge properly.
- Leaking future information: When creating lag features, ensure you don’t accidentally use future values (e.g., using the test set to compute rolling means). Always compute features using only past data.
- Using MAPE when values are near zero: MAPE becomes infinite or undefined if actual values are zero. Use MAE or RMSE instead.
Tips
- Start simple: Always benchmark against a naive method (e.g., last value) and a linear model. If a nonlinear method doesn’t beat them by a meaningful margin, it’s not worth the complexity.
- Use decomposition: Break the series into trend, seasonality, and remainder (e.g., with STL). Model each component separately if needed.
- Feature engineering matters: For tree-based models, add calendar features (day of week, month, holiday flags) and lagged values. This often boosts accuracy more than switching algorithms.
- Consider ensemble methods: Combining forecasts from different models (e.g., averaging) often reduces variance and improves accuracy.
- Keep a holdout set: After selecting a model, test it on a final holdout set (data not used in any training or validation) to get an unbiased estimate of performance.
Troubleshooting
- Model performs well on training but poorly on test: This is overfitting. Reduce model complexity, increase regularization, or use more training data (if possible).
- Residuals still show patterns: Your model missed some structure. Try adding more lags, differencing, or using a different method (e.g., from tree-based to neural).
- Forecasts are flat or constant: This often happens with linear models on nonlinear data. Switch to a nonlinear method or add interaction terms.
- Runtime is too long: Reduce the number of features, use a simpler model, or apply dimensionality reduction (e.g., PCA) to lags.
- Negative forecasts when data is positive: Add a transformation (e.g., log) or use models that naturally output positive values (e.g., Poisson regression for counts).
Frequently Asked Questions
What is the simplest nonlinear forecasting method?
Polynomial regression (e.g., quadratic trend) is the simplest. It adds curvature to the trend but doesn’t handle seasonality well on its own.
Can I use ARIMA for nonlinear data?
ARIMA is linear in its parameters. For nonlinear data, consider ARIMA with Box-Cox transformations or switch to nonlinear models like NARX or LSTM.
How much data do I need for an LSTM?
Generally, LSTMs need at least a few thousand observations to perform well. With less data, they tend to overfit. Use simpler models like random forests or SVR.
Should I detrend my data before using a nonlinear model?
Not necessarily. Some models (like tree-based) can handle trends directly. However, if you use a model that assumes stationarity (like SVR), detrending helps.
What does a negative RMSE mean?
RMSE is always non-negative. A negative value indicates a calculation error—likely you took the square root of a negative number, which shouldn’t happen since errors are squared.
How do I choose between accuracy and interpretability?
If you need to explain forecasts to stakeholders, choose simpler models (e.g., polynomial regression). For pure accuracy, complex models (LSTM, XGBoost) often win, but they are black boxes.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.