首页 > 解决方案 > 回报时间序列的预期回报和协方差

问题描述

我正在尝试模拟ewstats此处定义的 Matlab 函数:

https://it.mathworks.com/help/finance/ewstats.html

Matlab给出的结果如下:

> ExpReturn = 1×2
0.1995    0.1002

> ExpCovariance = 2×2
0.0032   -0.0017
-0.0017    0.0010

我正在尝试使用 RiskPortfolios R 包复制该示例:

https://cran.r-project.org/web/packages/RiskPortfolios/RiskPortfolios.pdf

我正在使用的 R 代码是这个:

library(RiskPortfolios)

rets <- as.matrix(cbind(c(0.24, 0.15, 0.27, 0.14), c(0.08, 0.13, 0.06, 0.13)))
w <- 0.98

rets
w
meanEstimation(rets, control = list(type = 'ewma', lambda = w))
covEstimation(rets, control = list(type = 'ewma', lambda = w))

均值估计与示例中的相同,但协方差矩阵不同:

> rets
     [,1] [,2]
[1,] 0.24 0.08
[2,] 0.15 0.13
[3,] 0.27 0.06
[4,] 0.14 0.13
> w
[1] 0.98
> 
> meanEstimation(rets, control = list(type = 'ewma', lambda = w))
[1] 0.1995434 0.1002031
> 
> covEstimation(rets, control = list(type = 'ewma', lambda = w))
             [,1]         [,2]
[1,]  0.007045044 -0.003857217
[2,] -0.003857217  0.002123827

我错过了什么吗?谢谢

标签: rmatlabportfolio

解决方案


如果使用,他们给出相同的答案type = "lw"

round(covEstimation(rets, control = list(type = 'lw')), 4)

##   0.0032 -0.0017
##  -0.0017  0.0010

推荐阅读