In probability theory and statistics, the covariance matrix is a square matrix setting out the covariance between each pair of elements . In the matrix diagonal there are variances. The variance covariance matrix is staple of statistical analysis and implementing practical aspects of data science like multiple regression. Below I will outline the rudiments of estimating Variance-Variance using an example from Finance.
This second video maps out how to use the Variance Covariance Matrix to estimate the Standard Deviation of an Asset Portfolio. Estimating the Variance of the portfolio is important for understanding the benefits of diversification and for also also estimating Value at Risk type metrics. See below R code at bottom of page and video clip that demonstrates how to automate
The R code produces the same variance-covariance matrix as set out by Simon Benninga. The data file Datavc can be obtained here.
read.csv("Datavc.csv")
prices <- read.csv("Datavc.csv")
prices
prices$GE
ger <- diff(log(prices$GE),1)
ger
ger <- diff(log(prices$GE),1)
msr <- diff(log(prices$MSFT),1)
jnjr <- diff(log(prices$JNJ),1)
kr <- diff(log(prices$K),1)
bar <- diff(log(prices$BA),1)
ibmr <- diff(log(prices$IBM),1)
portfolio.r <- data.frame(ger,msr,jnjr,kr,bar,ibmr)
portfolio.r
cov(portfolio.r)