How to calculate Sums in a Panel Data framework using "For Loops"
이전 댓글 표시
The following table consists of Price Returns returns at different Dates:

Idea: For any given Date and Stock Ticker, if returns data of previous 12 time steps is available (cell is not NaN), sum those returns and stock them in a new table. Code:
% Take row by row
% Considering columns 2 to 279 look at each date point if returns data for previous 12 time steps (weeks) is available
for i=length(Tnew.Date)
for j=TNew.x1COVGY:end
if (TNew.x1COVGY:end = ~(‘NaN’))
% Sum those 12 entries and list the result in a new table. For example, A2AIM's value for 30-Oct will be the sum of values between 30-Oct and 14-Aug.
end
end
Thanks for your help!!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!