Now I realized, after I established the generosity, that the questions have already been answered here . I will summarize how much I can understand this.
When you call optimize.portfolio , there is an optional momentFUN parameter that defines the moments of your portfolio. One of his arguments is momentargs , which you can go through optimize.portfolio .
First you need to select a set of expected results. I will read the last entry in your views time series:
my.expected.returns = views["2009-08-31"]
You will also need your own covariance matrix. I calculated it from your returns :
my.covariance.matrix = cov(returns)
Finally, you need to define momentargs , which is a list consisting of mu (expected results), sigma (your covariance matrix) and the third and fourth moments (which we set to zero):
num_assets = ncol(current.view) momentargs = list() momentargs$mu = my.expected.returns momentargs$sigma = my.covariance.matrix momentargs$m3 = matrix(0, nrow = num_assets, ncol = num_assets ^ 2) momentargs$m4 = matrix(0, nrow = num_assets, ncol = num_assets ^ 3)
Now you are ready to optimize your portfolio:
o = optimize.portfolio(R = returns, portfolio = pf, momentargs = momentargs)
lebelinoz
source share