Compute an indicator for n components and store the results in a vector
조회 수: 3 (최근 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 Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!