Compute an indicator for n components and store the results in a vector

1 回表示 (過去 30 日間)
Nicu Sprincean
Nicu Sprincean 2016 年 10 月 28 日
編集済み: Nicu Sprincean 2016 年 10 月 28 日
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 件)

カテゴリ

Help Center および File ExchangeFinancial Data Analytics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by