Question

suppose we following model

https://dsp.stackexchange.com/questions/15326/can-someone-show-the-details-of-how-to-apply-aic-for-sinusoidal-models-to-specif

where epsilon is white noise,i have tried following code

function [aic_matrix,bic_matrix]=ARMA_model(y,n);
%n possible order of each model
LOGL = zeros(n,n); %Initialize
PQ = zeros(n,n);
for p = 1:n
    for q = 1:n
        mod = arima(p,0,p);
        [fit,~,logL] = estimate(mod,y,'print',false);
        LOGL(p,q) = logL;
        PQ(p,q) = p+q;
     end
end
LOGL = reshape(LOGL,n*n,1);
PQ = reshape(PQ,n*n,1);
[aic1,bic1] = aicbic(LOGL,PQ+1,length(y));
aic_matrix=reshape(aic1,n,n);
bic_matrix=reshape(bic1,n,n);
end

but when i ran following command

[aic_matric,bic_matrix]=ARMA_model(B,100);

i got result

Error using arima/validateModel (line 1314)
The non-seasonal moving average polynomial is non-invertible.

Error in arima/setLagOp (line 391)
   Mdl = validateModel(Mdl);

Error in arima/estimate (line 1183)
  Mdl = setLagOp(Mdl, 'MA' , LagOp([1  coefficients(iMA)' ], 'Lags', [0 LagsMA ]));

Error in ARMA_model (line 9)
        [fit,~,logL] = estimate(mod,y,'print',false);

does it means that this signal is non stationary?what is a problem related to my code?please help me

Was it helpful?

Solution

I think this line is incorrect:

mod = arima(p,0,p); 

I think it should be

mod = arima(p,0,q);

Also, you really don't want the MA part of the system to have a higher order than the AR part (which is what your loop would do if the error was fixed). The loop

for q = 1:n 

should read

for q = 1:p.

Your code seems OK, apart from those issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top