4
$\begingroup$

When using the PerformanceAnalytics package of R, I am getting an error from the Return.portfolio function whenever I ask it to rebalance_on any frequency. If the rebalance parameter is removed, the function works fine.

Return.portfolio(portfolio.returns.daily, weights=risk.weights, rebalance_on="months")

Error in [<-(*tmp*, k, , value = c(0.734291071622665, 0.629392347105141, : subscript out of bounds

$\endgroup$
1
  • $\begingroup$ please provide reproducible data to help you. We just need the portion that will result in the error, You can dput() in r & paste it here $\endgroup$
    – Rime
    Aug 14, 2015 at 21:54

1 Answer 1

1
$\begingroup$

Just ran into and solved this problem.

Convert the timeSeries object into an xts object then change the indexClass to "Date"

# returns is a timeSeries object
r <- as.xts(returns)
indexClass(r) <- "Date"
a <- Return.portfolio(r, rebalance_on="quarters", verbose=TRUE)

I'm not an R expert or anything so I don't know if changing the indexClass has any other ramifications, but this allows me Return.portfolio to work.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.