calculate YoY growth rate
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Piyush Kumar
2024 年 9 月 26 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Econometrics Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!