我必须计算时间范围2006 2010中2种资产(SPY和TLT)之间的协方差矩阵[方差协方差协方差方差]的逆 我做到了
ret1=diff(SPY1) %2006-31/12/2009 of log of SPY
ret2=diff(TLT1)
dim(ret1)
dim(ret2)
dim(m1)
dim(r1)
m1 = t(m1)
r1 = t(r1)
inv_C = matrix(0,nrow = NCOL(ret1),ncol = 1)
for(i in 1:NCOL(ret1)) {
cov1 = cov(ret1[,i],ret2[,i])
inv_C[i,] = 1/cov1
}
但是这只给我一个值,因为我需要所有矩阵 我怎样才能做到这一点?谢谢