我正在尝试使用包 PerformanceAnalytics 计算给定投资组合的滚动年化 alpha。
到目前为止,我设法做了两件事:
使用我的每日回报获得滚动的每日阿尔法
chart.RollingRegression(r,r_idx,width = 250, attribute = "Alpha")
使用 获得滚动年化回报
chart.RollingPerformance(r,r_idx,width = 250, FUN="Return.annualized")
。我想将该年化功能转换为前一个函数调用
我尝试在 RollingRegression 中使用 FUN 参数,但它不起作用。还有另一种方法吗?
谢谢
这是您可以运行的代码,它从 2 个随机生成的返回时间序列中给出上述 2 个图表:
library(PerformanceAnalytics)
dates <- seq.Date(as.Date("2006-12-31"),by="day",length.out = 1000)
set.seed(3542)
ra <- xts(rnorm(1000,0,0.01),order.by = dates)
rb <- xts(rnorm(1000,0,0.01),order.by = dates)
chart.RollingRegression(ra,rb,width = 250, attribute = "Alpha")
chart.RollingPerformance(ra,width = 250, FUN="Return.annualized")