檢視國際股票投資組合的風險因子
對同時持有英國、 美國與瑞士股票的英國投資人而言,會暴露在 5 個風險因子之下;這些資料收錄在多變量資料集 riskfactors 中。
在本練習中,你將回顧先前學到的一些檢定與技巧,用來顯示這些風險因子的尾部分佈比常態更肥厚、波動度高,且存在明顯的序列相依。
本練習屬於課程
R 的量化風險管理
練習說明
- 使用合適的函式繪製
riskfactors。 - 計算
riskfactors的對數報酬,對所有序列移除第一個NA值,指定為returns。接著使用合適的函式繪製returns。 - 使用帶有 3 個參數的
apply(),對所有序列進行 Jarque-Bera 常態性檢定。 - 用
qqnorm()只針對returns中第 5 個報酬序列製作與常態比較的 Q-Q 圖。然後用qqline()加上參考線。 - 使用
acf()先繪製報酬的樣本自相關函數,再繪製報酬絕對值的樣本自相關函數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the risk-factor data
# Calculate the log-returns, assign to returns, and plot
___ <- ___(___(___))[-1, ]
# Use apply() to carry out the Jarque-Bera test for all 5 series
# Make a Q-Q plot against normal for the 5th return series and add a reference line
___(returns[, ___])
___(returns[, ___])
# Make a picture of the sample acfs for returns and their absolute values