RiskPortfolios
RiskPortfolios copied to clipboard
Risk Efficient Portfolios
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.