開始使用免費開始

計算基準報酬

在這個練習中,你將建立一個基準,用來評估之後練習中的最佳化模型表現。等權重基準是一種簡單的權重配置方式,用來建構基準投資組合。等權重的直覺是:對任何資產都不設偏好。我們要用這個設定來回答一個問題:「最佳化是否能優於用簡單權重來建構投資組合?」

本練習屬於課程

R 中級投資組合分析

檢視課程

練習說明

  • 載入 PortfolioAnalytics 套件。
  • 載入 edhec 資料集。
  • 將 edhec 資料集指定給名為 asset_returns 的變數。
  • 建立等權重向量,指定給名為 equal_weights 的變數。
  • 計算 asset_returns 的等權重基準(每季再平衡)。
  • 繪製基準報酬。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。


# Load the package


# Load the data


# Assign the data to a variable


# Create a vector of equal weights
equal_weights <- rep(1 / ncol(___), ncol(___))

# Compute the benchmark returns
r_benchmark <- Return.portfolio(R = ___, weights = ___, rebalance_on = ___)
colnames(r_benchmark) <- "benchmark"

# Plot the benchmark returns
編輯並執行程式碼