calculate YoY growth rate
조회 수: 5 (최근 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!