| itheta_vcov {MarkowitzR} | R Documentation |
Compute variance covariance of Inverse 'Unified' Second Moment
Description
Computes the variance covariance matrix of the inverse unified second moment matrix.
Usage
itheta_vcov(X,vcov.func=vcov,fit.intercept=TRUE)
Arguments
X |
an |
vcov.func |
a function which takes an object of class |
fit.intercept |
a boolean controlling whether we add a column of ones to the data, or fit the raw uncentered second moment. For now, must be true when assuming normal returns. |
Details
Given p-vector x with mean \mu and
covariance, \Sigma, let y be x
with a one prepended. Then let
\Theta = E\left(y y^{\top}\right),
the uncentered second moment matrix. The inverse of
\Theta contains the (negative) Markowitz portfolio
and the precision matrix.
Given n contemporaneous observations of p-vectors,
stacked as rows in the n \times p matrix X,
this function estimates the mean and the asymptotic
variance-covariance matrix of \Theta^{-1}.
One may use the default method for computing covariance,
via the vcov function, or via a 'fancy' estimator,
like sandwich:vcovHAC, sandwich:vcovHC, etc.
Value
a list containing the following components:
mu |
a |
Ohat |
the |
n |
the number of rows in |
pp |
the number of assets plus |
Note
By flipping the sign of X, the inverse of
\Theta contains the positive Markowitz
portfolio and the precision matrix on X. Performing
this transform before passing the data to this function
should be considered idiomatic.
A more general form of this function exists as mp_vcov.
Replaces similar functionality from SharpeR package, but with modified API.
Author(s)
Steven E. Pav shabbychef@gmail.com
References
Pav, S. E. "Asymptotic Distribution of the Markowitz Portfolio." 2013 https://arxiv.org/abs/1312.0557
Pav, S. E. "Portfolio Inference with this One Weird Trick." R in Finance, 2014 http://past.rinfinance.com/agenda/2014/talk/StevenPav.pdf
See Also
Examples
X <- matrix(rnorm(1000*3),ncol=3)
# putting in -X is idiomatic:
ism <- itheta_vcov(-X)
iSigmas.n <- itheta_vcov(-X,vcov.func="normal")
iSigmas.n <- itheta_vcov(-X,fit.intercept=FALSE)
# compute the marginal Wald test statistics:
qidx <- 2:ism$pp
wald.stats <- ism$mu[qidx] / sqrt(diag(ism$Ohat[qidx,qidx]))
# make it fat tailed:
X <- matrix(rt(1000*3,df=5),ncol=3)
ism <- itheta_vcov(X)
qidx <- 2:ism$pp
wald.stats <- ism$mu[qidx] / sqrt(diag(ism$Ohat[qidx,qidx]))
if (require(sandwich)) {
ism <- itheta_vcov(X,vcov.func=vcovHC)
qidx <- 2:ism$pp
wald.stats <- ism$mu[qidx] / sqrt(diag(ism$Ohat[qidx,qidx]))
}
# add some autocorrelation to X
Xf <- filter(X,c(0.2),"recursive")
colnames(Xf) <- colnames(X)
ism <- itheta_vcov(Xf)
qidx <- 2:ism$pp
wald.stats <- ism$mu[qidx] / sqrt(diag(ism$Ohat[qidx,qidx]))
if (require(sandwich)) {
ism <- itheta_vcov(Xf,vcov.func=vcovHAC)
qidx <- 2:ism$pp
wald.stats <- ism$mu[qidx] / sqrt(diag(ism$Ohat[qidx,qidx]))
}