MATLAB Answers

0

Hello! i have been given a task to find monthly log return time series and then aggregate each to an annual log return series. but every code i use, follows with an error. how do i convert the data to annual the easiest possible way?

Asked by Khuzaima Ahmad on 29 Sep 2018
Latest activity Answered by Peter Perkins
on 1 Oct 2018
This is the code i used to find monthly log returns:
RFRmonthly = readtable('22RFR-monthly.xlsx');
RFRmonthly.Properties.VariableNames{1} = 'Time';
RFRmonthly.Properties.VariableNames{2} = 'Index';
RFR_Monthly = 2 * log(RFRmonthly.Index./ lagmatrix(RFRmonthly.Index,1));

  0 Comments

Sign in to comment.

2 Answers

Answer by Jeremy Hughes on 1 Oct 2018

Should one of these be Time?
log(RFRmonthly. Index./ lagmatrix(RFRmonthly. Index,1));

  1 Comment

No, its the log of index devided by lagmatrix of index

Sign in to comment.


Answer by Peter Perkins
on 1 Oct 2018

If the question is, "how do i convert the data to annual the easiest possible way?", the answer is to import using readtable (Check!) then convert using table2timetable and call retime with 'yearly' as the new time basis. I guess you want to get the last value in each year, or interpolate; I don't thnk you want to aggregate in the sense of sum. So something like
ttAnnual = retime(ttMonthly,'yearly','lastvalue')
but I'm just guessing. The I guess you'd lag that, divide the original price by the lagged price, and log.
I believe that the Financial Toolbox has a function called tick2ret, if you have access to that.

  0 Comments

Sign in to comment.