Compute an indicator for n components and store the results in a vector
1 次查看(过去 30 天)
显示 更早的评论
Hi, Matlab users, I have the following code to compute Marginal Expected Shortfall for one company:
% We need to have the same days for market_returns and firm_returns
if length(firm_returns)~=length(market_returns)
error('Unequal number of days for firm and market');
end
% Find the 5% quantile the market return
low_threshold = prctile(market_returns,5);
% Find the 5% worst days for the market return
worst_days = market_returns < low_threshold;
% Take the average of the firm's returns during the worst days of the
% market
mes = mean(firm_returns(worst_days));
Now, I have 2+ companies from the same country, and the same market portfolio (index). How can I change the above code to compute mes for all companies and store the results in a vector? I'm a newbie here and I'm thinking for a 'for loop' but don't know how to apply. Many thanks.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Data Analytics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!