Calculating annual return from monthly return, why does it generate Nan?
<p>I have some irregular data below, that gives me the monthly return correctly. Now I wish to transform it into annual geometric return, but for some reason it returns NaN for many values. </p>

<p>I suspect it is because of how the index values in the xts objet is ordered, but I do not know how to turn them into descending (couldn't find an answer to it either online). </p>

<p>What is wrong? And how can it be resolved?</p>

<p>Code below</p>

<pre><code>Browse[2]&gt; Data.xts[,1]
           monthly.returns
2012-09-27     -0.02469261
2012-10-30     -0.05129329
2012-11-29      0.05129329
2012-12-30      0.11778304
2013-01-30     -0.14310084
2013-02-27     -0.08004271
2013-03-28     -0.02817088
2013-04-29     -0.02898754
2013-05-30      0.16251893
2013-06-27      0.00000000
2013-07-30      0.52324814
2013-08-29      0.86927677
2013-09-29     -0.01250016
2013-10-30      0.02484600
2013-11-28     -0.06986968
2013-12-30     -0.06453852
2014-01-30      0.17055672
2014-02-27      0.22195942
2014-03-30      0.02342027
2014-04-29     -0.11258822
2014-05-29      0.03061464
2014-06-29     -0.08381867
2014-07-30     -0.06782260
2014-08-28     -0.08541775
2014-09-29     -0.10394609
2014-10-30     -0.29833937
2014-11-27      0.05556985
2014-12-30     -0.22652765

Browse[2]&gt; annualReturn(Data.xts[, 'monthly.returns'] , type = 'log')
           yearly.returns
2012-12-30            NaN
2013-12-30            NaN
2014-12-30       1.255605
</code></pre>