Search code examples
rfinancequantitative-financeperformanceanalytics

R PerformanceAnalytics::Return.portfolio() generates NaN when geometric=TRUE


I am struggling with PerformanceAnalytics::Return.portfolio() where if I try to set the parameter geometric=TRUE I get NaN as the return series. If I set the geometric=FALSE then I get the returns calculated.

I have obviously made sure that there are no "na" or "nan" or "inf" values in the input return series and the weights series.

Any pointers?

The call is:

stratRets <- PerformanceAnalytics::Return.portfolio(R = rets, weights = weights, geometric = TRUE)

I can't copy the return and weights dataframes here as they contain thousands of rows. I will try to come up with a smaller example to reproduce the issue and post it here shortly.

Meanwhile any quick pointers on what to check will be greatly appreciated.


Solution

  • Answer is to remove any rows at the beginning with weights totaling to 0.