I need help for handling with an error in matlab caused with the function
estimate(garch(1,1),x')
from the Economic Toolbox. My exercise is to predict values for value-at-risks by using garch(1,1)-models for discrete returns $R$ of share prices $data$
for i=1:length(data-1)
R(i-1)=data(i)/data(i-1)-1;
end
of various public companys from 2004 till 2016. Therefore I am using for example 250 discrete returns from the past to predict a value for the actual value-at-risk:
for j=1:length(R)-n
daten=R(j:(n+j-1));
x=daten-mean(daten)*ones(1,n);
fit = estimate(garch(1,1),x');
estParams = ['Constant',cell2mat(fit.GARCH), cell2mat(fit.ARCH)];
alpha0(j)=estParams(1);
alpha1(j)=estParams(2);
beta1(j)=estParams(3);
end
n equals to 250 here. The problem is, that I am always getting this error after certain runs of my if-loop, because the data doesnt fit to a garch(1,1)-model:
Error using VaR_garch (line 21)
Estimated GARCH model is invalid.
Caused by:
Error using garch/validateModel (line 791)
Non-zero degree P requires a non-zero degree Q.
and the corresponding lines of garch.m are
if (Mdl.P > 0) && (Mdl.Q == 0)
error(message('econ:garch:validateModel:InvalidModelDegrees'))
end
So I need to use
estimate(garch(1,0),x')
in my if-loop, when I get my error. How can I deal with this error, so matlab is going on with estimation the parameters in my if-loop?
I'm sure you probably know this but ask on MATLab on https://uk.mathworks.com/matlabcentral/answers/index?s_tid=mlc_an_ask I think you'll most likely get a quicker response!