Time series imputation is the process of estimating missing values in a sequence of time-ordered observations by exploiting the temporal structure of the data, such as trend, seasonality, autocorrelation and relationships with other series. In Time series & forecasting, it is a core preprocessing step, because most forecasting models, lag features and rolling statistics assume a regular, gap-free time index.
Unlike imputation in tabular data, where rows are usually treated as exchangeable, missing value imputation in time series must respect temporal order and dependence. A good method reconstructs plausible values without leaking future information into training data and without erasing the variability that downstream models need to learn.
Why gaps appear in temporal data
Gaps in time series arise from sensor outages, transmission failures, irregular reporting and data cleaning that removes implausible readings. The cause matters, because the right imputation method depends on whether values are missing at random or for a systematic reason.
Statisticians describe three missingness mechanisms. The table below summarizes each mechanism and its practical consequence for imputation in temporal data.
| Mechanism | Meaning | Example | Consequence for imputation |
|---|---|---|---|
| Missing completely at random (MCAR) | Gaps are unrelated to any value | Random packet loss in telemetry | Most methods remain unbiased |
| Missing at random (MAR) | Gaps depend on observed variables | Meter offline during known maintenance | Use covariates to condition estimates |
| Missing not at random (MNAR) | Gaps depend on the missing value itself | Sensor saturates at extreme temperatures | Simple imputation introduces bias |
Gap length is equally important. Isolated single points are easy to reconstruct from neighbors, whereas long contiguous blocks spanning one or more seasonal cycles remove the local context that simple interpolation depends on.
Main families of imputation methods
Imputation methods range from simple deterministic rules to probabilistic deep-learning models. Each family makes different assumptions about smoothness, seasonality and cross-series correlation, so the choice should follow the structure of the data rather than habit.
| Method | How it fills gaps | Best suited for | Main weakness |
|---|---|---|---|
| Forward or backward fill | Repeats the last or next observed value | Step-like states and slowly changing levels | Flattens dynamics on long gaps |
| Linear or spline interpolation | Draws a line or smooth curve between neighbors | Short gaps in smooth signals | Ignores seasonality |
| Seasonal decomposition | Interpolates the remainder after removing STL components | Strong daily or weekly cycles | Needs enough history per season |
| Kalman smoothing | Estimates hidden state in a state-space model | Noisy series with clear structure | Requires a specified model |
| Multivariate regression | Predicts the gap from related series | Sensor networks and correlated assets | Fails when all series fail together |
| Deep generative models | Learns joint distribution with RNN, diffusion or attention | Large multivariate datasets | Costly and harder to validate |
Kalman smoothing deserves special attention because it uses observations both before and after the gap, propagates uncertainty and handles irregular spacing naturally. Deep approaches such as recurrent imputation networks and score-based diffusion imputers can capture nonlinear cross-series patterns but demand careful validation.
How imputation interacts with forecasting
Imputation directly shapes forecast quality because filled values become inputs, targets and lag features for the model. A poor method can distort autocorrelation, inflate apparent stationarity or smooth away the peaks that the forecaster is supposed to predict.
The most serious risk is look-ahead leakage. Bidirectional methods, including centered interpolation and Kalman smoothing, use future observations. That is acceptable for historical analysis, but in a live pipeline the imputer at forecast time can only use past data available at that moment, so backtests must replicate the same restriction.
| Pipeline stage | Acceptable approach | Reason |
|---|---|---|
| Historical training data | Bidirectional smoothing or interpolation | Full context improves reconstruction |
| Backtesting folds | Impute within each fold using past data only | Prevents leakage across the split |
| Live inference | Causal filtering or forward fill | Future values do not yet exist |
| Evaluation targets | Exclude imputed points from error metrics | Avoids scoring the model on guesses |
Some modern forecasters, including DeepAR and several time series foundation models, accept observation masks and learn to handle gaps internally. In those cases, explicit imputation may be unnecessary or even harmful, and passing a missingness indicator is often the better design.
Choosing and validating a method
The reliable way to choose an imputer is masked evaluation: hide a sample of known values in patterns that resemble real gaps, impute them and measure the reconstruction error. Random point masking alone is misleading when real outages arrive as contiguous blocks.
- Match the simulated gap length distribution to the observed one.
- Report error metrics such as MAE or RMSE separately for short and long gaps.
- Compare the autocorrelation and variance of imputed and original segments.
- Measure the final effect on downstream forecast accuracy, not only reconstruction error.
As a rule of thumb, interpolation works for gaps shorter than a few steps, seasonal methods work for gaps up to about one cycle, and multivariate or state-space models are needed beyond that. When a gap exceeds several seasonal cycles, flagging the period and excluding it from training is frequently more honest than imputing it.
Limitations and common mistakes
Every imputed value is an assumption, not an observation. Deterministic methods return a single estimate and hide uncertainty, which makes downstream prediction intervals too narrow. Multiple imputation or probabilistic imputers address this by producing several plausible completions.
| Mistake | Symptom | Remedy |
|---|---|---|
| Filling zeros as a default | Artificial dips and biased averages | Distinguish true zeros from missing values |
| Interpolating across long outages | Unrealistically straight segments | Use seasonal or multivariate models |
| Imputing before the train-test split | Optimistic backtest scores | Impute inside each fold |
| Discarding the missingness flag | Model cannot learn gap effects | Keep a binary indicator feature |
Another common error is confusing missing values with true zeros. In intermittent demand data, a zero is a meaningful observation of no sales, while a missing value means the system did not record anything. Treating them identically corrupts methods such as Croston’s method.
A plain-language summary
Imagine a thermometer that records the temperature every hour. Sometimes it stops working for a while. Time series imputation fills those empty hours with sensible guesses.
The guesses are not random. They use what happened just before and after the gap. They also use daily patterns, such as nights being cooler than afternoons. The best guess respects the rhythm of the data. It is still a guess, so careful teams mark which values were filled in.
An example from practice
A regional electricity distributor forecasts hourly load for about 400 substations. Smart meter collectors fail occasionally, leaving gaps from one hour to several days. Early models used linear interpolation, and forecast errors spiked after long outages because straight lines erased the daily peak.
The analytics team switched to a two-tier approach. Gaps of up to three hours are interpolated, while longer gaps are filled by a state-space model using neighboring substations and temperature as covariates. Every filled value carries a missingness flag, and imputed hours are excluded from error metrics.
Masked evaluation on historical data showed that reconstruction error on multi-day gaps fell by roughly half. The day-ahead forecast also became more stable after outages, which reduced unnecessary reserve purchases during peak periods.