Time series imputation

Also known as: missing value imputation in time series

On this page 7

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.

MechanismMeaningExampleConsequence for imputation
Missing completely at random (MCAR)Gaps are unrelated to any valueRandom packet loss in telemetryMost methods remain unbiased
Missing at random (MAR)Gaps depend on observed variablesMeter offline during known maintenanceUse covariates to condition estimates
Missing not at random (MNAR)Gaps depend on the missing value itselfSensor saturates at extreme temperaturesSimple imputation introduces bias
Missingness mechanisms and their consequences

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.

MethodHow it fills gapsBest suited forMain weakness
Forward or backward fillRepeats the last or next observed valueStep-like states and slowly changing levelsFlattens dynamics on long gaps
Linear or spline interpolationDraws a line or smooth curve between neighborsShort gaps in smooth signalsIgnores seasonality
Seasonal decompositionInterpolates the remainder after removing STL componentsStrong daily or weekly cyclesNeeds enough history per season
Kalman smoothingEstimates hidden state in a state-space modelNoisy series with clear structureRequires a specified model
Multivariate regressionPredicts the gap from related seriesSensor networks and correlated assetsFails when all series fail together
Deep generative modelsLearns joint distribution with RNN, diffusion or attentionLarge multivariate datasetsCostly and harder to validate
Common imputation approaches for time series

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 stageAcceptable approachReason
Historical training dataBidirectional smoothing or interpolationFull context improves reconstruction
Backtesting foldsImpute within each fold using past data onlyPrevents leakage across the split
Live inferenceCausal filtering or forward fillFuture values do not yet exist
Evaluation targetsExclude imputed points from error metricsAvoids scoring the model on guesses
Imputation choices in a forecasting pipeline

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.

MistakeSymptomRemedy
Filling zeros as a defaultArtificial dips and biased averagesDistinguish true zeros from missing values
Interpolating across long outagesUnrealistically straight segmentsUse seasonal or multivariate models
Imputing before the train-test splitOptimistic backtest scoresImpute inside each fold
Discarding the missingness flagModel cannot learn gap effectsKeep a binary indicator feature
Frequent imputation errors and remedies

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.