Covariance matrix
I want to make a covariance matrix with the following variables: AGG, VAW, IWN, SPY, EWG and EWW.
I found the covariance of the variables in r with this code:
cov(wr[ ,c("AGG","VAW","IWN","SPY","EWG","EWW")])
Here's the result:
AGG VAW IWN SPY |
AGG 3.571068e-05 -4.260068e-05 -2.587826e-05 -3.239567e-05 |
VAW -4.260068e-05 1.301973e-03 9.838237e-04 7.927169e-04 |
IWN -2.587826e-05 9.838237e-04 1.024990e-03 7.221941e-04 |
SPY -3.239567e-05 7.927169e-04 7.221941e-04 6.143463e-04 |
EWG -5.084499e-05 1.109888e-03 9.502014e-04 8.046398e-04 |
EWW -3.710732e-05 1.184849e-03 1.010141e-03 8.152602e-04 |
EWG EWW |
AGG -5.084499e-05 -3.710732e-05 |
VAW 1.109888e-03 1.184849e-03 |
IWN 9.502014e-04 1.010141e-03 |
SPY 8.046398e-04 8.152602e-04 |
EWG 1.444157e-03 1.179610e-03 |
EWW 1.179610e-03 1.659257e-03 |
How do I make a covariance matrix of the result?
Thanks in advance.
No need to worry the computed matrix is itself a covariance matrix but the output is slightly confusing as the variables are not in need order. I have typed the output in a simple manner so you can understand. The highlighted part are the variables corresponding to that are the values of the variance and covariance. Hope this helps.
AGG VAW IWN SPY EWG EWW
AGG 3.571068e-05 -4.260068e-05 -2.587826e-05
-3.239567e-05 -5.084499e-05 -3.710732e-05
VAW -4.260068e-05 1.301973e-03 9.838237e-04
7.927169e-04 1.109888e-03 1.184849e-03
IWN -2.587826e-05 9.838237e-04 1.024990e-03
7.221941e-04 9.502014e-04 1.010141e-03
SPY -3.239567e-05 7.927169e-04 7.221941e-04
6.143463e-04 8.046398e-04 8.152602e-04
EWG -5.084499e-05 1.109888e-03 9.502014e-04
8.046398e-04 1.444157e-03 1.179610e-03
EWW -3.710732e-05 1.184849e-03 1.010141e-03
8.152602e-04 1.179610e-03 1.659257e-03
Get Answers For Free
Most questions answered within 1 hours.