If you changed the loop to start at 0, you are trying to index LOGL and PQ at the index 0 which does not exist. MATLAB starts indexing at 1.
First pre-allocate the additional space:
LOGL = zeros(5,5);
PQ = zeros(5,5);
Error:
for p = 0:4
for q = 0:4
mod = arima(p,0,q);
[fit,~,logL] = estimate(mod,eur,'print',false);
LOGL(p,q) = logL;
PQ(p,q) = p+q;
end
end
So increase the indices by 1.
No Error:
for p = 0:4
for q = 0:4
mod = arima(p,0,q);
[fit,~,logL] = estimate(mod,eur,'print',false);
LOGL(p+1,q+1) = logL;
PQ(p+1,q+1) = p+q;
end
end
Bear in mind that now the log-likelihood of the ARIMA(2,0,3) model is in LOGL(3,4)
Best Answer