MarkowitzR (version 0.9900.0)

theta_vcov: Compute variance covariance of 'Unified' Second Moment

Description

Computes the variance covariance matrix of sample mean and second moment.

Usage

theta_vcov(X,vcov.func=vcov,fit.intercept=TRUE)

Arguments

X

an \(n \times p\) matrix of observed returns.

vcov.func

a function which takes an object of class lm, and computes a variance-covariance matrix. If equal to the string "normal", we assume multivariate normal returns.

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.

Value

a list containing the following components:

mu

a \(q = (p+1)(p+2)/2\) vector of 1, then the mean, then the vech'd second moment of the sample data.

Ohat

the \(q \times q\) estimated variance covariance matrix. When fit.intercept is true, the left column and top row are all zeros.

n

the number of rows in X.

pp

the number of assets plus as.numeric(fit.intercept).

Details

Given \(p\)-vector \(x\), the 'unified' sample is the \((p+1)(p+2)/2\) vector of 1, \(x\), and \(\mbox{vech}(x x^{\top})\) stacked on top of each other. Given \(n\) contemporaneous observations of \(p\)-vectors, stacked as rows in the \(n \times p\) matrix \(X\), this function computes the mean and the variance-covariance matrix of the 'unified' sample.

One may use the default method for computing covariance, via the vcov function, or via a 'fancy' estimator, like sandwich:vcovHAC, sandwich:vcovHC, etc.

References

Pav, S. E. "Asymptotic Distribution of the Markowitz Portfolio." 2013 http://arxiv.org/abs/1312.0557

Pav, S. E. "Portfolio Inference with this One Weird Trick." R in Finance, 2014 http://www.rinfinance.com/agenda/2014/talk/StevenPav.pdf

See Also

itheta_vcov.

Examples

Run this code
# NOT RUN {
X <- matrix(rnorm(1000*3),ncol=3)
Sigmas <- theta_vcov(X)
Sigmas.n <- theta_vcov(X,vcov.func="normal")
Sigmas.n <- theta_vcov(X,fit.intercept=FALSE)

# make it fat tailed:
X <- matrix(rt(1000*3,df=5),ncol=3)
Sigmas <- theta_vcov(X)
# }
# NOT RUN {
if (require(sandwich)) {
 Sigmas <- theta_vcov(X,vcov.func=vcovHC)
}
# }
# NOT RUN {
# add some autocorrelation to X
Xf <- filter(X,c(0.2),"recursive")
colnames(Xf) <- colnames(X)
Sigmas <- theta_vcov(Xf)
# }
# NOT RUN {
if (require(sandwich)) {
Sigmas <- theta_vcov(Xf,vcov.func=vcovHAC)
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace