Continue running for loop for values that do not given an error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Wietze Zijpp
el 9 de Abr. de 2022
Comentada: Voss
el 9 de Abr. de 2022
Suppose I have the following line of code
Mdl_vol(1) = egarch('GARCHLags',1,'ARCHLags',1);
Mdl_vol(2) = egarch('GARCHLags',1:2,'ARCHLags',1);
Mdl_vol(3) = egarch('GARCHLags',1:3,'ARCHLags',1);
Mdl_vol(4) = egarch('GARCHLags',1,'ARCHLags',1:2);
Mdl_vol(5) = egarch('GARCHLags',1:2,'ARCHLags',1:2);
Mdl_vol(6) = egarch('GARCHLags',1:3,'ARCHLags',1:2);
Mdl_vol(7) = egarch('GARCHLags',1,'ARCHLags',1:3);
Mdl_vol(8) = egarch('GARCHLags',1:2,'ARCHLags',1:3);
Mdl_vol(9) = egarch('GARCHLags',1:3,'ARCHLags',1:3);
% AIC i stocks j models
for i = 1:20
for j = 1:9
EstMdl = estimate(Mdl_vol(j),monthlyerrorsi(:,i),'Display','off');
results = summarize(EstMdl);
AIC(j,i) = results.AIC;
end
end
Now I get the following error
Estimated EGARCH model is invalid.
Caused by:
Error using egarch/validateModel (line 789)
GARCH polynomial is not stationary.
So for some i = 1:20 any of the 9 models is invalid. However, I am wondering if there is a way to have the once that give an error display a 0 or NaN value. And for the models that do not given an error to obtain the right values.
0 comentarios
Respuesta aceptada
Voss
el 9 de Abr. de 2022
monthlyerrorsi = randn(100,20); % random monthlyerrorsi
Mdl_vol(1) = egarch('GARCHLags',1,'ARCHLags',1);
Mdl_vol(2) = egarch('GARCHLags',1:2,'ARCHLags',1);
Mdl_vol(3) = egarch('GARCHLags',1:3,'ARCHLags',1);
Mdl_vol(4) = egarch('GARCHLags',1,'ARCHLags',1:2);
Mdl_vol(5) = egarch('GARCHLags',1:2,'ARCHLags',1:2);
Mdl_vol(6) = egarch('GARCHLags',1:3,'ARCHLags',1:2);
Mdl_vol(7) = egarch('GARCHLags',1,'ARCHLags',1:3);
Mdl_vol(8) = egarch('GARCHLags',1:2,'ARCHLags',1:3);
Mdl_vol(9) = egarch('GARCHLags',1:3,'ARCHLags',1:3);
% AIC i stocks j models
for i = 1:20
for j = 1:9
try
EstMdl = estimate(Mdl_vol(j),monthlyerrorsi(:,i),'Display','off');
results = summarize(EstMdl);
AIC(j,i) = results.AIC;
catch ME
disp(sprintf('%s -- Occurred at (j,i) = (%d,%d)',ME.message,j,i));
AIC(j,i) = NaN;
end
end
end
AIC
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre GARCH Model en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!