Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simple lag function

Subject: Simple lag function

From: Gang-Gyoo

Date: 29 Apr, 2013 19:54:09

Message: 1 of 2

function test

%Test data(not your data)
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

Subject: Simple lag function

From: someone

Date: 29 Apr, 2013 20:03:09

Message: 2 of 2

"Gang-Gyoo " <ggjin@hhu.ac.kr> wrote in message <klmj51$i7v$1@newscl01ah.mathworks.com>...
> function test
>
> %Test data(not your data)
> 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?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us