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:
using lags of financial variables

Subject: using lags of financial variables

From: sarah dijols

Date: 28 Apr, 2013 08:36:10

Message: 1 of 3

I am running the following code (which is not mine, it is the correction of a finance exercice) :
%% Question 2: compute log excess returns for the risky assets
%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;

and get the following error message:
" Undefined function or method 'lag' for input arguments of type 'double'."
Isn't there a 'lag' function?
How could I procede?
Thanks for your attention.
Sarah

Subject: using lags of financial variables

From: Nasser M. Abbasi

Date: 28 Apr, 2013 08:48:46

Message: 2 of 3

On 4/28/2013 3:36 AM, sarah dijols wrote:
> I am running the following code (which is not mine, it is the correction of a finance exercice) :
> %% Question 2: compute log excess returns for the risky assets
> %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;
>
> and get the following error message:
> " Undefined function or method 'lag' for input arguments of type 'double'."
> Isn't there a 'lag' function?
> How could I procede?
> Thanks for your attention.
> Sarah
>

it is better to follow up on same thread than ask the same question again:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/328636

Subject: using lags of financial variables

From: Bruno Luong

Date: 28 Apr, 2013 08:51:09

Message: 3 of 3

"sarah dijols" <sarah.dijols@hotmail.fr> wrote in message <klin1q$c6n$1@newscl01ah.mathworks.com>...

> Isn't there a 'lag' function?

I don't think anyone but author of this code can answer.

Bruno

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