3

I'm trying to copy the code from a website to test Portfolio Analytics library in R. But I getting an error and I don't have a clue why. The error I am getting is: Error: "package:ROI" %in% search() || requireNamespace("ROI", quietly = TRUE) is not 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) 
2
  • 4
    check if you have ROI, ROI.plugin.quadprog, and ROI.plugin.glpk libraries installed. Commented Jul 20, 2017 at 3:20
  • 1
    Hey thanks, that worked for me. Commented Jan 18, 2018 at 18:51

1 Answer 1

2

You need to install ROI plugin then you should be able to do the optimization with ROI method. you can use the following commands to install ROI plugin,

install.packages("ROI") install.packages("ROI.plugin.glpk") install.packages("ROI.plugin.quadprog") 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.