rSemiCov {highfrequency} | R Documentation |
Realized semicovariance
Description
Calculate the Realized Semicovariances (rSemiCov).
Let be an intraday
return matrix and
the number of intraday returns. Then, let
and
.
Then, the realized semicovariance is given by the following three matrices:
The mixed covariance matrix will have 0 on the diagonal.
From these three matrices, the realized covariance can be constructed as .
The concordant semicovariance matrix is
.
The off-diagonals of the concordant matrix is always positive, while for the mixed matrix, it is always negative.
Usage
rSemiCov(
rData,
cor = FALSE,
alignBy = NULL,
alignPeriod = NULL,
makeReturns = FALSE
)
Arguments
rData |
an |
cor |
boolean, in case it is |
alignBy |
character, indicating the time scale in which |
alignPeriod |
positive numeric, indicating the number of periods to aggregate over. For example, to aggregate
based on a 5-minute frequency, set |
makeReturns |
boolean, should be |
Details
In the case that cor is TRUE
, the mixed matrix will be an matrix filled with NA as mapping the mixed covariance matrix into correlation space is impossible due to the 0-diagonal.
Value
In case the data consists of one day a list of five matrices are returned. These matrices are named
mixed
, positive
, negative
, concordant
, and rCov
.
The latter matrix corresponds to the realized covariance estimator and is thus named like the function rCov
.
In case the data spans more than one day, the list for each day will be put into another list named according to the date of the estimates.
Author(s)
Emil Sjoerup.
References
Bollerslev, T., Li, J., Patton, A. J., and Quaedvlieg, R. (2020). Realized semicovariances. Econometrica, 88, 1515-1551.
See Also
ICov
for a list of implemented estimators of the integrated covariance.
Examples
# Realized semi-variance/semi-covariance for prices aligned
# at 5 minutes.
# Univariate:
rSVar = rSemiCov(rData = sampleTData[, list(DT, PRICE)], alignBy = "minutes",
alignPeriod = 5, makeReturns = TRUE)
rSVar
## Not run:
library("xts")
# Multivariate multi day:
rSC <- rSemiCov(sampleOneMinuteData, makeReturns = TRUE) # rSC is a list of lists
# We extract the covariance between stock 1 and stock 2 for all three covariances.
mixed <- sapply(rSC, function(x) x[["mixed"]][1,2])
neg <- sapply(rSC, function(x) x[["negative"]][1,2])
pos <- sapply(rSC, function(x) x[["positive"]][1,2])
covariances <- xts(cbind(mixed, neg, pos), as.Date(names(rSC)))
colnames(covariances) <- c("mixed", "neg", "pos")
# We make a quick plot of the different covariances
plot(covariances)
addLegend(lty = 1) # Add legend so we can distinguish the series.
## End(Not run)