decompose_volume {intradayModel}R Documentation

Decompose Intraday Volume into Several Components

Description

This function decomposes the intraday volume into daily, seasonal, and intraday dynamic components according to (Chen et al., 2016). If purpose = “analysis” (aka Kalman smoothing), the optimal components are conditioned on both the past and future observations. Its mathematical expression is \hat{x}_{\tau} = E[x_{\tau}|\{y_{j}\}_{j=1}^{M}], where M is the total number of bins in the dataset.

If purpose = “forecast” (aka Kalman forecasting), the optimal components are conditioned on only the past observations. Its mathematical expression is \hat{x}_{\tau+1} = E[x_{\tau+1}|\{y_{j}\}_{j=1}^{\tau}].

Three measures are used to evaluate the model performance:

Usage

decompose_volume(purpose, model, data, burn_in_days = 0)

Arguments

purpose

String "analysis"/"forecast". Indicates the purpose of using the provided model.

model

A model object of class "volume_model" from fit_volume().

data

An n_bin * n_day matrix or an xts object storing intraday volume.

burn_in_days

Number of initial days in the burn-in period for forecast. Samples from the first burn_in_days are used to warm up the model and then are discarded.

Value

A list containing the following elements:

Author(s)

Shengjie Xiu, Yifan Yu and Daniel P. Palomar

References

Chen, R., Feng, Y., and Palomar, D. (2016). Forecasting intraday trading volume: A Kalman filter approach. Available at SSRN 3101695.

Examples

library(intradayModel)
data(volume_aapl)
volume_aapl_training <- volume_aapl[, 1:20]
volume_aapl_testing <- volume_aapl[, 21:50]
model_fit <- fit_volume(volume_aapl_training, fixed_pars = list(a_mu = 0.5, var_mu = 0.05),
                        init_pars = list(a_eta = 0.5))

# analyze training volume
analysis_result <- decompose_volume(purpose = "analysis", model_fit, volume_aapl_training)

# forecast testing volume
forecast_result <- decompose_volume(purpose = "forecast", model_fit, volume_aapl_testing)

# forecast testing volume with burn-in
forecast_result <- decompose_volume(purpose = "forecast", model_fit, volume_aapl[, 1:50],
                             burn_in_days = 20)


[Package intradayModel version 0.0.1 Index]