rBACov {highfrequency} | R Documentation |
rBACov
Description
The Beta Adjusted Covariance (BAC) equals the pre-estimator plus a minimal adjustment matrix such that the covariance-implied stock-ETF beta equals a target beta.
The BAC estimator works by applying a minimum correction factor to a pre-estimated covariance matrix such that a target beta derived from the ETF is reached.
Let
denote the implied beta derived from the pre-estimator, and
denote the target beta, then the correction factor is calculated as:
where
where is the number of assets in the ETF, and
is the number of trades in the
th asset, and
where is the weight of the
th asset in the ETF.
and
is defined by the following two cases:
has dimensions
and
has dimensions
.
The Beta-Adjusted Covariance is then
where is the pre-estimated covariance matrix.
Usage
rBACov(
pData,
shares,
outstanding,
nonEquity,
ETFNAME = "ETF",
unrestricted = TRUE,
targetBeta = c("HY", "VAB", "expert"),
expertBeta = NULL,
preEstimator = "rCov",
noiseRobustEstimator = rTSCov,
noiseCorrection = FALSE,
returnL = FALSE,
...
)
Arguments
pData |
a named list. Each list-item contains an |
shares |
a |
outstanding |
number of shares outstanding of the ETF |
nonEquity |
aggregated value of the additional components (like cash, money-market funds, bonds, etc.) of the ETF which are not included in the components in |
ETFNAME |
a |
unrestricted |
a |
targetBeta |
a |
expertBeta |
a |
preEstimator |
a |
noiseRobustEstimator |
a |
noiseCorrection |
a |
returnL |
a |
... |
extra arguments passed to |
Author(s)
Emil Sjoerup, (Kris Boudt and Kirill Dragun for the Python version)
References
Boudt, K., Dragun, K., Omauri, S., and Vanduffel, S. (2021) Beta-Adjusted Covariance Estimation (working paper).
See Also
ICov
for a list of implemented estimators of the integrated covariance.
Examples
## Not run:
# Since we don't have any data in this package that is of the required format we must simulate it.
library(xts)
library(highfrequency)
# The mvtnorm package is needed for this example
# Please install this package before running this example
library("mvtnorm")
# Set the seed for replication
set.seed(123)
iT <- 23400 # Number of observations
# Simulate returns
rets <- rmvnorm(iT * 3 + 1, mean = rep(0,4),
sigma = matrix(c(0.1, -0.03 , 0.02, 0.04,
-0.03, 0.05, -0.03, 0.02,
0.02, -0.03, 0.05, -0.03,
0.04, 0.02, -0.03, 0.08), ncol = 4))
# We assume that the assets don't trade in a synchronous manner
w1 <- rets[sort(sample(1:nrow(rets), size = nrow(rets) * 0.5)), 1]
w2 <- rets[sort(sample(1:nrow(rets), size = nrow(rets) * 0.75)), 2]
w3 <- rets[sort(sample(1:nrow(rets), size = nrow(rets) * 0.65)), 3]
w4 <- rets[sort(sample(1:nrow(rets), size = nrow(rets) * 0.8)), 4]
w5 <- rnorm(nrow(rets) * 0.9, mean = 0, sd = 0.005)
timestamps1 <- seq(34200, 57600, length.out = length(w1))
timestamps2 <- seq(34200, 57600, length.out = length(w2))
timestamps3 <- seq(34200, 57600, length.out = length(w3))
timestamps4 <- seq(34200, 57600, length.out = length(w4))
timestamps4 <- seq(34200, 57600, length.out = length(w4))
timestamps5 <- seq(34200, 57600, length.out = length(w5))
w1 <- xts(w1 * c(0,sqrt(diff(timestamps1) / (max(timestamps1) - min(timestamps1)))),
as.POSIXct(timestamps1, origin = "1970-01-01"), tzone = "UTC")
w2 <- xts(w2 * c(0,sqrt(diff(timestamps2) / (max(timestamps2) - min(timestamps2)))),
as.POSIXct(timestamps2, origin = "1970-01-01"), tzone = "UTC")
w3 <- xts(w3 * c(0,sqrt(diff(timestamps3) / (max(timestamps3) - min(timestamps3)))),
as.POSIXct(timestamps3, origin = "1970-01-01"), tzone = "UTC")
w4 <- xts(w4 * c(0,sqrt(diff(timestamps4) / (max(timestamps4) - min(timestamps4)))),
as.POSIXct(timestamps4, origin = "1970-01-01"), tzone = "UTC")
w5 <- xts(w5 * c(0,sqrt(diff(timestamps5) / (max(timestamps5) - min(timestamps5)))),
as.POSIXct(timestamps5, origin = "1970-01-01"), tzone = "UTC")
p1 <- exp(cumsum(w1))
p2 <- exp(cumsum(w2))
p3 <- exp(cumsum(w3))
p4 <- exp(cumsum(w4))
weights <- runif(4) * 1:4
weights <- weights / sum(weights)
p5 <- xts(rowSums(cbind(w1 * weights[1], w2 * weights[2], w3 * weights[3], w4 * weights[4]),
na.rm = TRUE),
index(cbind(p1, p2, p3, p4)))
p5 <- xts(cumsum(rowSums(cbind(p5, w5), na.rm = TRUE)), index(cbind(p5, w5)))
p5 <- exp(p5[sort(sample(1:length(p5), size = nrow(rets) * 0.9))])
BAC <- rBACov(pData = list(
"ETF" = p5, "STOCK 1" = p1, "STOCK 2" = p2, "STOCK 3" = p3, "STOCK 4" = p4
), shares = 1:4, outstanding = 1, nonEquity = 0, ETFNAME = "ETF",
unrestricted = FALSE, preEstimator = "rCov", noiseCorrection = FALSE,
returnL = FALSE, K = 2, J = 1)
# Noise robust version of the estimator
noiseRobustBAC <- rBACov(pData = list(
"ETF" = p5, "STOCK 1" = p1, "STOCK 2" = p2, "STOCK 3" = p3, "STOCK 4" = p4
), shares = 1:4, outstanding = 1, nonEquity = 0, ETFNAME = "ETF",
unrestricted = FALSE, preEstimator = "rCov", noiseCorrection = TRUE,
noiseRobustEstimator = rHYCov, returnL = FALSE, K = 2, J = 1)
# Use the Variance Adjusted Beta method
# Also use a different pre-estimator.
VABBAC <- rBACov(pData = list(
"ETF" = p5, "STOCK 1" = p1, "STOCK 2" = p2, "STOCK 3" = p3, "STOCK 4" = p4
), shares = 1:4, outstanding = 1, nonEquity = 0, ETFNAME = "ETF",
unrestricted = FALSE, targetBeta = "VAB", preEstimator = "rHYov",
noiseCorrection = FALSE, returnL = FALSE, Lin = FALSE, L = 0, K = 2, J = 1)
## End(Not run)