calculate YoY growth rate
11 views (last 30 days)
Show older comments
Hi,friend,
price2ret function is able to calculate the growth rate of two adjacent values, if it's monthly data, it can be viewed as month over month change, can I use this function to calculate year over year change on the same monthly data series? thanks
0 Comments
Answers (1)
Piyush Kumar
on 26 Sep 2024
Hi,
You can calculate year over year change on the same monthly data series.
For example, I have created dummy data for 24 months. To calculate YoY growth rated, we will pass data with gap of 12 months, like Jan 2023 and Jan 2024.
% Generate dummy data for 24 months (2 years)
months = 1:24;
data = 100 + cumsum(randn(1, 24)); % Starting at 100 and adding random changes
% Initialize arrays to store MoM and YoY growth rates
mom_growth_rate = zeros(1, 23); % 23 because MoM is between adjacent months
yoy_growth_rate = zeros(1, 12); % 12 because YoY is between same months in consecutive years
% Calculate MoM growth rates
for i = 2:24
mom_growth_rate(i-1) = price2ret([data(i-1), data(i)]);
end
% Calculate YoY growth rates
for i = 13:24
yoy_growth_rate(i-12) = price2ret([data(i-12), data(i)]);
end
% Display results
disp('Monthly Data:');
disp(data);
disp('MoM Growth Rates:');
disp(mom_growth_rate);
disp('YoY Growth Rates:');
disp(yoy_growth_rate);
0 Comments
See Also
Categories
Find more on Econometrics Toolbox 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!