MATLAB: I am getting error for performing AIC test for model orders varying in 0:3 range

aic for order 0aic test

For ARIMA(p,d,q) if AIC test is applied for p,q = 0:3 keeping d = 0 and 1, it shows error. I want to confirm for possibilities when p and/or q = 0 also. What can be done to achieve so? This is my code.
LOGL = zeros(4,4);
PQ = zeros(4,4);
for p = 0:3
for q = 0:3
mod = arima(p,1,q);
[fit,~,logL] = estimate(mod,z,'print',false);
LOGL(p,q) = logL;
PQ(p,q) = p+q;
end
end
LOGL = reshape(LOGL,16,1);
PQ = reshape(PQ,16,1);
[aic,bic] = aicbic(LOGL,PQ+1,100);
mAIC=reshape(aic,4,4)
mBIC=reshape(bic,4,4)
the error is due to log function. Is there any way to achieve what I want?

Best Answer

MATLAB indexing starts at 1, so when wither p or q is equal to 0 your indexing,
LOGL(p,q) = logL;
PQ(p,q) = p+q;
will fail. Change this to:
LOGL(p+1,q+1) = logL;
PQ(p+1,q+1) = p+q;