尝试使用Portfolio Analytics进行优化时出错

时间:2017-07-19 21:39:34

标签: r optimization r-portfolioanalytics

我试图从网站上复制代码以测试R中的Portfolio Analytics库。但是我收到错误而且我不知道为什么。我得到的错误是:错误:"包:投资回报率" %search in(%||) requireNamespace(" ROI",quietly = TRUE)不为TRUE

library(PortfolioAnalytics)

data(edhec)
returns <- edhec[, 1:6]
funds <- colnames(returns)

init.portfolio <- portfolio.spec(assets = funds)

init.portfolio <- add.constraint(portfolio = init.portfolio, 
                                 type = "full_investment")

init.portfolio <- add.constraint(portfolio = init.portfolio, 
                                 type = "long_only")

minSD.portfolio <- add.objective(portfolio=init.portfolio, 
                                 type="risk", 
                                 name="StdDev")

minSD.opt <- optimize.portfolio(R = returns, portfolio = minSD.portfolio, 
                                optimize_method = "ROI", trace = TRUE)

0 个答案:

没有答案