Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Simple lag function
Replies: 1   Last Post: Apr 29, 2013 4:03 PM

 Messages: [ Previous | Next ]
 Curious Posts: 2,359 Registered: 12/6/04
Re: Simple lag function
Posted: Apr 29, 2013 4:03 PM

"Gang-Gyoo " <ggjin@hhu.ac.kr> wrote in message <klmj51\$i7v\$1@newscl01ah.mathworks.com>...
> function test
>
> data= rand(12,2);
>
> %Log monthly risk free rate
> lrf_m = log(1+(lag(data(:,2))/(100*12)));
> lrf_m(1,1)=NaN;
>
> %Log monthly exc return German Long term bond
> ly_10_m = (log(1+(data(:,1))/(100*12)));
> dur = 12*((1-(1+(data(:,1)/(100))).^(-10)))./(1-(1+(data(:,1)/(100))).^(-1));
> lret_b_10_m =(lag(dur).*lag(ly_10_m)-(lag(dur)-1).*ly_10_m);
> exlret_b_10 = lret_b_10_m-lrf_m
> end
>
> function y= lag(x)
> y= [NaN x(1:end-1)']';
> end

% Is there a question?

Date Subject Author
4/29/13 Gang-Gyoo
4/29/13 Curious