0

I'm trying to build portfolio with the function Return.portfolio (PerformanceAnalytics package). I have returns for 2 assets in a matrix r. when running: Return.portfolio(r,verbose = T,weights = c(0.5,0.5)) it seems to working. When trying to add rebalance "quarters" I'm getting this error:

"Error in `[<-`(`*tmp*`, k, , value = c(0.639312209726542, 0.639312209726542 : 
  subscript out of bounds".

and I don't understand what is wrong. In addition, when trying to build long-short portfolio: Return.portfolio(r,weights = c(1,-1),verbose = T), its running but the results seems not logical.. Is there a reason for this? thanks guys

kaksat
  • 709
  • 1
  • 7
  • 18
yudyud
  • 27
  • 1
  • 6
  • The error you are getting suggests that your code is trying to subset an object beyond what it contains (e.g. taking the 3rd element of an object with 2 elements). However, other than that it is difficult to answer your question without a working example of your code :) – SamPassmore Jan 08 '17 at 14:03
  • ok. the issue is that its working well untill i add the argument of rebalance.on, nothing else has change. (returns matrix is the same). – yudyud Jan 08 '17 at 20:38
  • You need to provide an example for anyone here to be of any help to you. – SamPassmore Jan 08 '17 at 21:24
  • ok, my returns matrix (r) looks like this: 2002-01-01 0.0000000000 0.007576714 2002-01-02 0.0103941949 0.007895726 2002-01-03 -0.0005822981 -0.005968665 returns till 12-08-2016. when trying to run this: Return.portfolio(r,verbose = T,weights = c(0.5,0.5),rebalance_on = "quarters") i gett this error: Error in `[<-`(`*tmp*`, k, , value = c(0.706865189567491, 0.706865189567491 : subscript out of bounds. hope its help to understand. – yudyud Jan 09 '17 at 06:39
  • Read this page to get a good idea of how to make a good example of the problem so someone can help you http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – SamPassmore Jan 09 '17 at 10:02

0 Answers0