Compound Return

  • Follow


Greetings:

I am attempting to create a vector of compound returns with a fixed starting principal amount and variable returns per period. For example:

I had capital = $10,000 at time 0.

My return, r, at the following periods:

r1 = 1.2%
r2 = 2.3%
r3 = -1.2%
…

My $10,000 compounds at the rates above per period.

So:

x1 = capital * (1 + r1)
x2 = x1 * (1 + r2)
x3 = x2 * (1 + r3)
....

My main issue is probably simple for those with experience in MATLAB.  I'm having troube recursively calling the x in the above example. For example:

r is a vector of returns
capital is the initial capital ($10,000)

I modified compint (http://www.mathworks.com/matlabcentral/newsreader/view_thread/259630#676655) to return a 1-period return:

%%%

function a = compint(p, r)
%p=starting balance, r=return %

a = (p) * (1 + r);

%%%

I try to run the following code:

capital = compint(capital, r(:,1));

which simply multiplies the return at period t against the original starting capital. I would like it to of course recursively (or otherwise) multiply the next return against the previous capital + return.

I'm very new to MATLAB and hoping there is a built in function or someone has accomplished this task.
0
Reply J 6/28/2010 5:42:10 PM

Very easy:

series = [cumprod(r) * capital];



"J " <remove.this.strimp101@gmail.com> wrote in message <i0amth$77$1@fred.mathworks.com>...
> Greetings:
> 
> I am attempting to create a vector of compound returns with a fixed starting principal amount and variable returns per period. For example:
> 
> I had capital = $10,000 at time 0.
> 
> My return, r, at the following periods:
> 
> r1 = 1.2%
> r2 = 2.3%
> r3 = -1.2%
> &#8230;
> 
> My $10,000 compounds at the rates above per period.
> 
> So:
> 
> x1 = capital * (1 + r1)
> x2 = x1 * (1 + r2)
> x3 = x2 * (1 + r3)
> ...
> 
> My main issue is probably simple for those with experience in MATLAB.  I'm having troube recursively calling the x in the above example. For example:
> 
> r is a vector of returns
> capital is the initial capital ($10,000)
> 
> I modified compint (http://www.mathworks.com/matlabcentral/newsreader/view_thread/259630#676655) to return a 1-period return:
> 
> %%%
> 
> function a = compint(p, r)
> %p=starting balance, r=return %
> 
> a = (p) * (1 + r);
> 
> %%%
> 
> I try to run the following code:
> 
> capital = compint(capital, r(:,1));
> 
> which simply multiplies the return at period t against the original starting capital. I would like it to of course recursively (or otherwise) multiply the next return against the previous capital + return.
> 
> I'm very new to MATLAB and hoping there is a built in function or someone has accomplished this task.
0
Reply J 6/28/2010 9:44:04 PM


1 Replies
220 Views

(page loaded in 0.035 seconds)

Similiar Articles:













6/28/2012 10:12:40 AM


Reply: