0
我正在嘗試查找風險值。我也做了以下內容: -如何在r中找到風險值
x<- matrix (1:40, ncol = 4)
xapp <- apply(x, 2, quantile, probs = c(0.1,0.2,0.5))
它給了我下面的輸出: -
[,1] [,2] [,3] [,4]
10% 1.9 11.9 21.9 31.9
20% 2.8 12.8 22.8 32.8
50% 5.5 15.5 25.5 35.5
這顯然是錯誤的。
要找到VaR,我需要爲每列排序數據。即
X1 X2 < X3 < ... < X10 <
然後風險值@ 10%= X(0.1×10)=行1,風險值@ 20%= X(0.2×10)= 2行,風險值@ 50%= X(0.5×10)= 5行
它應該給我下面的輸出: -
[,1] [,2] [,3] [,4]
10% 1 11 21 31
20% 2 12 22 32
50% 5 15 25 35
我應該如何糾正呢?