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

1 visualización (últimos 30 días)
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.

Respuestas (0)

Categorías

Más información sobre Financial Data Analytics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by