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 vues (au cours des 30 derniers jours)
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));

Réponses (2)

Jeremy Hughes
Jeremy Hughes le 1 Oct 2018
Should one of these be Time?
log(RFRmonthly. Index./ lagmatrix(RFRmonthly. Index,1));

Peter Perkins
Peter Perkins le 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.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by