Abstract: Missing values often occur in financial data due to a variety of reasons (errors in the collection process or in the processing stage, lack of asset liquidity, lack of reporting of funds, etc.). However, most data analysis methods expect complete data and cannot be employed with missing values. One convenient way to deal with this issue without having to redesign the data analysis method is to impute the missing values. This package provides an efficient way to impute the missing values based on modeling the time series with a random walk or an autoregressive (AR) model, convenient to model log-prices and log-volumes in financial data. In the current version, the imputation is univariate-based (so no asset correlation is used). In addition, outliers can be detected and removed. The package is based on the paper: J. Liu, S. Kumar, and D. P. Palomar (2019). Parameter Estimation of Heavy-Tailed AR Model With Missing Data Via Stochastic EM. IEEE Trans. on Signal Processing, vol. 67, no. 8, pp. 2159-2172.
Introduction
In financial analysis, practitioners frequently encounter "holey" datasets. Gaps in time series can arise from asset illiquidity, technical failures in data pipelines, or reporting delays. Standard financial models, such as those used for portfolio optimization or risk parity, typically require complete data and fail when presented with NA values. Common workarounds like row deletion or simple linear interpolation are often inadequate; the former discards valuable information, while the latter fails to capture the stochastic nature of market movements.
The imputeFin R package addresses these challenges by providing a principled framework for imputing missing values. It leverages models that reflect the actual behavior of financial data—specifically random walks and autoregressive (AR) processes—ensuring that imputed values are statistically consistent with the observed series.
Methodology
The core of imputeFin lies in its robust estimation and imputation routines. The package supports two primary modeling approaches:
Gaussian AR(1) Models
For standard data, the package employs Gaussian AR(1) models. It uses the Expectation-Maximization (EM) algorithm to find maximum likelihood estimates of parameters even in the presence of missing data. Users can specify whether the series should be treated as a random walk or a zero-mean process.
Heavy-Tailed Student’s t Models
Financial markets are notorious for "heavy tails," where extreme price swings occur more frequently than a normal distribution predicts. imputeFin incorporates Student’s t AR(1) models to handle such data. Because the E-step of a standard EM algorithm is mathematically intractable for Student’s t distributions, the package implements a Stochastic EM (SEM) approach. This method utilizes Gibbs Sampling to simulate missing data, enabling parameter estimation for heavy-tailed processes.
Key Features and Implementation
Beyond basic imputation, the package offers several advanced features:
- Outlier Handling: Outliers can be detected and removed based on user-defined probability thresholds, preventing data glitches from biasing the imputation.
- Rolling Windows: The
impute_OHLCfunction allows for rolling window imputation, which is particularly useful for Open-High-Low-Close price data where relationships may evolve over time. - Univariate Focus: By focusing on univariate imputation, the package avoids the "curse of dimensionality" associated with large-scale multivariate models, while still allowing for the processing of multiple independent series.
Conclusion and Future Directions
imputeFin provides a robust toolkit for cleaning financial data. While currently focused on univariate models, it offers a significant improvement over simple interpolation by accounting for the stochastic and heavy-tailed nature of markets. Future developments may include incorporating asset correlations to further improve imputation accuracy in highly interconnected markets and extending support to higher-order AR models.
Summary updated