RiskPortfolios icon indicating copy to clipboard operation
RiskPortfolios copied to clipboard

Risk Efficient Portfolios

Open rjvelasquezm opened this issue 5 years ago • 0 comments

When I try to run a risk efficient portfolio I get the following error:

Error in [<-(*tmp*, pos, i - 1, value = 1) : subscript out of bounds

Digging into the code a bit seems to be an issue regarding the dimensions it loops on.

Specifically this part of the code:

for (i in 2:11) {
                print(i)
                pos <- semiDev > pct[i - 1] & semiDev <= pct[i]
                J[pos, i - 1] <- 1
                epsilon[i - 1] <- median(semiDev[pos])
        }

It has fixed i range of 2:11 which seems to represent the quantiles. But, it uses the same range for J which is a matrix of the dimensions of the assets passed in. Seems like it should be using the dimensions of the assets because if you have fewer assets than 11 then you'll get the above error as it tries to write to a row/column beyond what exists in the matrix J.

rjvelasquezm avatar Oct 12 '19 15:10 rjvelasquezm