rmOutliersTrades | R Documentation |
Delete entries for which the price is outlying with respect to surrounding entries. In comparison to tradesCleanupUsingQuotes, this function doesn't need quote data.
rmOutliersTrades(pData, maxi = 10, window = 50, type = "advanced", tz = NULL)
pData |
a |
maxi |
an integer, indicating the maximum number of median absolute deviations allowed. |
window |
an integer, indicating the time window for which the "outlyingness" is considered. |
type |
should be |
tz |
fallback time zone used in case we we are unable to identify the timezone of the data, by default: |
If type = "standard"
: Function deletes entries for which the price deviated by more than "maxi"
median absolute deviations from a rolling centered median (excluding
the observation under consideration) of window observations.
If type = "advanced"
: Function deletes entries for which the price deviates by more than "maxi"
median absolute deviations from the value closest to the price of
these three options:
Rolling centered median (excluding the observation under consideration)
Rolling median of the following window of observations
Rolling median of the previous window of observations
The advantage of this procedure compared to the "standard" proposed by Barndorff-Nielsen et al. (2010, footnote 8) is that it will not incorrectly remove large price jumps. Therefore this procedure has been set as the default for removing outliers.
Note that the median absolute deviation is taken over the entire day. In case it is zero (which can happen if prices don't change much), the median absolute deviation is taken over a subsample without constant prices.
xts
object or data.table
depending on type of input.
Jonathan Cornelissen, Kris Boudt, and Onno Kleen.
Barndorff-Nielsen, O. E., P. R. Hansen, A. Lunde, and N. Shephard (2009). Realized kernels in practice: Trades and quotes. Econometrics Journal, 12, C1-C32.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.