Learn R Programming

highfrequency (version 0.8.0)

ReMeDI: ReMeDI

Description

This function estimates the auto-covariance of market-microstructure noise

Let the observed price \(Y_{t}\) be given as \(Y_{t} = X_{t} + \varepsilon_{t}\), where \(X_{t}\) is the efficient price and \(\varepsilon_t\) is the market microstructure noise

The estimator of the \(l\)'th lag of the market microstructure is defined as: $$ \hat{R}^{n}_{t,l} = \frac{1}{n_{t}} \sum_{i=2k_{n}}^{n_{t}-k_{n}-l} \left(Y_{i+l}^n - Y_{i+l+k_{n}}^{n} \right) \left(Y_{i}^n - Y_{i- 2k_{n}}^{n} \right), $$ where \(k_{n}\) is a tuning parameter. In the function knChooseReMeDI, we provide a function to estimate the optimal \(k_{n}\) parameter.

Usage

ReMeDI(pData, kn = 1, lags = 1, knEqual = FALSE, makeCorrelation = FALSE)

Arguments

pData

xts or data.table containing the log-prices of the asset

kn

numeric of length 1 determining the tuning parameter kn this controls the lengths of the non-overlapping interval in the ReMeDI estimation

lags

numeric containing integer values indicating the lags for which to estimate the (co)variance

knEqual

Use an altered version of the ReMeDI estimator, where we instead use equal kn, instead of kn and 2*kn for the windows. See Figure 1 of paper in reference section.

makeCorrelation

logical indicating whether to transform the autocovariances into autocorrelations. The estimate of variance is imprecise and thus, constructing the correlation like this may show correlations that fall outside \((-1,1)\).

References

Li, M. and Linton, O. (2019). A ReMeDI for microstructure noise. Cambridge Working Papers in Economics 1908.

Examples

Run this code
# NOT RUN {
remed <- ReMeDI(sampleTData[as.Date(DT) == "2018-01-02", ], kn = 2, lags = 1:8)
# We can also use the algorithm for choosing the kn tuning parameter
optimalKn <- knChooseReMeDI(sampleTData[as.Date(DT) == "2018-01-02",],
                            knMax = 10, tol = 0.05, size = 3,
                            lower = 2, upper = 5, plot = TRUE)
optimalKn
remed <- ReMeDI(sampleTData[as.Date(DT) == "2018-01-02", ], kn = optimalKn, lags = 1:8)
# }

Run the code above in your browser using DataLab