I am trying to estimate a rolling extreme shortfall matrix by looping. In the following code ESdynamic is crated for each column on the simulated matrix.
mu = [0 0 0 0 0 0];
A = rand(6);
Sigma= A * A';
Data = mvnrnd(mu,Sigma,1000);
Now, instead of representing r as just one column of data matrix, I want to out the entire code in a loop so that, at first Esdynamic is populated with column one, than on column 2... at the end we have a matrix of ESdynamic.
VarMdl = garch(1,1);
Mdl = arima('ARLags',1,'Variance',VarMdl);
EstMdl = estimate(Mdl,r);
[res,v,logL] = infer(EstMdl,r);
for P_Index = 1: +1: length(p)
P_Value = p(P_Index);
for J= 1:T
VaR = Var_Normal;
ES = ES_Normal;
ESdynamic = [ESdynamic,ES];
I also want a Vardynamic matrix. how to ket the loop update it?
VaRdynamic = 
ES_Matrix(:,P_Index) = ESdynamic';
Now is it possible to put another loop so that the ESdynamic and VaRdynamic matrices, are generated for p = [0.5, 0.1, 0.05, 0.025, 0.01, 0.001] in a loop?
The plot compares all 6 columns of ESdynamic, for each ...please help
ESdynamic = ;
function [VaR,ES] = hNormalVaRES(Sigma,p)
VaR = -norminv(p);
ES = -Sigma*quad(@(q)q.*normpdf(q),-6,-VaR)/p;
Your kind suggestions are requested.