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?
2 views (last 30 days)
Show older comments
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
Answers (2)
Jeremy Hughes
on 1 Oct 2018
Should one of these be Time?
log(RFRmonthly. Index./ lagmatrix(RFRmonthly. Index,1));
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
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!