Troubleshooting PortfolioAnalytics Efficient Frontier Errors
Summary
The document collects two reported causes of an error in PortfolioAnalytics’ efficient frontier function. One answer links the problem to using a newer version of the ROI optimization infrastructure and reports that the function worked with older ROI components. Another suggests checking for duplicate values in the input data, which may also trigger the failure.
These are troubleshooting observations rather than a verified diagnosis or general fix. The reports concern different setups and provide no controlled comparison, package details, or reproducible test establishing either cause. Users should treat them as leads to investigate, checking both their optimization dependencies and input data when reproducing the error.
Key ideas
- An ROI infrastructure update was reported as a possible source of the function error.
- A contributor said the function worked with older ROI components in their setup.
- Duplicate values in the input data were suggested as another possible trigger.
- The reports do not establish a definitive or universally applicable cause.
Tags
Full text
# PortfolioAnalytics R package - Error with the function "create.EfficientFrontier"
# PortfolioAnalytics R package - Error with the function "create.EfficientFrontier"
Issue
The function `create.EfficientFrontier` from the `PortfolioAnalytics` package is outputting an error message that reads:
```
Error in `colnames<-`(`*tmp*`, value = c("mean", "StdDev", "out", "w.Asset1", :
attempt to set 'colnames' on an object with less than two dimensions
```
Troubleshooting performed so far without success
- Searched for identical cases - found a few cases with the same error message but output from different functions
- Checked if the covariance matrix was not positive definite
- Had recently updated the zoo package so I reinstalled the older version
- Besides my own code, I tried to run the example codes I found in two different blogs however, I got the exact same error once I tried to execute the function "create.EfficientFrontier".
You can check the link below for the code and specific data set in order to try to reproduce my error:
Efficient Frontier Demo from Ross Bennett (PortfolioAnalytics developer)
Three different data sets and the same error, so I suppose I might have some basic misconfiguration issue on my RStudio.
Any ideas on what the culprit could be?
Thanks in advance!
## Answer by FrankC (score 1, accepted)
https://quant.stackexchange.com/a/32481
I ran into the same issue. I do not know what causes it, but I noticed that you have this error if you use the latest ROI infrastructure (released in June 2016), while the function works correctly if you use the old (2013) ROI infrastructure (and old plug-ins) still available on CRAN (see archives).
## Answer by Pavel (score 1)
https://quant.stackexchange.com/a/65671
Check your data for duplicate values. It seems the function has an issue if there are any duplicates in your data. Best way to find duplicates is to sort alphabetically first!Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.