How to compute excess returns for several companies and dates?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I have the set of data below (For about 6000 companies and not only 3, and daily data until 2004).
What I need to do is, for each company at a time, set a new column - say column D - with Returns (col.C) minus the risk free rate (col.G) for the correspondent dates.
So for example, for company B it would be B8-G2, B9-G3 and so on. For company C it would be B14-G2 and etc.
Is there a simple way to do this? For example search, while the company code is the same, matching dates between column B and F and set a new array with the subtracted values?
Thank you so much in advance (I'm new to matlab)!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161719/image.bmp)
0 件のコメント
回答 (1 件)
Andrei Bobrov
2014 年 4 月 25 日
ABC = {'A','B','C'}';
DATES = num2cell((19630101:100:19630601)');
ii = fullfact([3 6]);
Df = [ABC(ii(:,1)),DATES(ii(:,2))];
p = [1 2 1 0 1 1 ]'*.01;
[~,i0] = ismember(cell2mat(Df(:,2)), cell2mat(DATES));
pc = num2cell(p);
out = [Df,pc(i0)];
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!