進階動差估計
PortfolioAnalytics 提供「sample」方法,以及另外三種更進階的投資組合動差估計方法。
"sample":前四階動差的基本樣本估計。"boudt":根據 Boudt 等人,2014 的研究,藉由擬合統計因子模型來估計前四階動差。"black_litterman":使用 Black-Litterman 架構 估計前兩階動差。"Meucci":使用 Fully Flexible Views 架構 估計前兩階動差。
在這個練習中,你將使用「boudt」方法來估計第二動差。已經建立了一個名為 port_spec、且包含「StdDev」目標的投資組合規格物件。
本練習屬於課程
R 中級投資組合分析
練習說明
- 列印投資組合規格物件。
- 對資產報酬擬合具有 3 個因子的統計因子模型。指定給名為
fit的變數。 - 使用具有 3 個因子的「boudt」方法來估計投資組合的動差。指定給名為
moments_boudt的變數。 - 使用
extractCovariance()從fit取得估計的變異數-共變異數矩陣,並檢查它是否等於moments_boudt中的估計值。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the portfolio specification object
# Fit a statistical factor model to the asset returns
fit <- statistical.factor.model(R = ___, k = ___)
# Estimate the portfolio moments using the "boudt" method with 3 factors
moments_boudt <- set.portfolio.moments(R = ___, portfolio = ___, method = ___, k = ___)
# Check if the covariance matrix extracted from the model fit is equal to the estimate in `moments_boudt`
moments_boudt$___ == extractCovariance(___)