How to calculate Sums in a Panel Data framework using "For Loops"
Afficher commentaires plus anciens
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!!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!