|
|
Compound Return
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%
> …
>
> 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: Compound Return - comp.soft-sys.matlabGreetings: I am attempting to create a vector of compound returns with a fixed starting principal amount and variable returns per period. For examp... Compounding Interest and plotting - comp.soft-sys.matlab ...Compound Return - comp.soft-sys.matlab Compound interest - comp.soft-sys.matlab Compound Return - comp.soft-sys.matlab Compound Return - comp.soft-sys.matlab Compounding ... how to display the number entered in descending orderb - comp.lang ...Compound Return - comp.soft-sys.matlab how to display the number entered in descending orderb - comp.lang ... Compound Return - comp.soft-sys.matlab how to display the ... signed/unsigned as fundamental types - comp.lang.c++.moderated ...I was asking myself why they aren't defined as compound types. defining the... ... Compound Return - comp.soft-sys.matlab signed/unsigned as fundamental types - comp.lang ... Does PAUSE have any Side Effect ?? - comp.lang.fortranCompound Return - comp.soft-sys.matlab Does PAUSE have any Side Effect ?? - comp.lang.fortran Remove or comment out the PAUSE statement, and the program returns NaN. Initial Capitals - comp.lang.rexxCompound Return - comp.soft-sys.matlab For example: r is a vector of returns capital is the initial capital ($10,000) I modified compint (http://www.mathworks.com ... calculating returns - comp.soft-sys.matlabCalculating Total Return and Compound Annual Growth Rate CAGR In order to evaluate investment performance, you must learn to calculate total return and compound annual ... Matlab acker(A,B,p) method - comp.soft-sys.matlabHi, will acker method return the G matrix of Luenberger observer? I have used ... Matlab acker(A,B,p) method - comp.soft-sys.matlab Compounding Interest and plotting ... z scores without the stats toolbox - comp.soft-sys.matlab ...What does size(nt_z) return? Looks to me like it ought to be same as size(nt ... probably very easy questions, but Im very new to matlab You can write a compound ... Character Repeat - comp.lang.javascriptIt can be optimised though: the += compound operator is notoriously slow in some ... function BigCat(L) { if (!L) return "" if (L&1) return BigCat(L-1) + "x" var T ... Compound Return Definition | InvestopediaCompound Return - Definition of Compound Return on Investopedia - The rate of return, usually expressed as a percentage, that represents the cumulative effect that a ... Computing Compound ReturnCompound return is one of the most frequently used terms in the investment world. But what does it mean? And how does one calculate it? This article will help you ... 6/28/2012 10:12:40 AM
|
|
|
|
|
|
|
|
|