Continue running for loop for values that do not given an error
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Voss
le 9 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur GARCH Model dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!