How to decide the optimal AR-model order? I'm trying to create AR-model on wheather data and I wondered is there a method or algorithm which can find the optimal order for an AR-model?
I'm using Matlab for my data-analysis, is there a function which can do this?
Thank you
 A: You could use the Levinson-Durbin method. It iteratively fits an AR model to the autocorrelation sequence of interest and calculates the model error. The optimal AR model order is the order that minimizes the model error. From that order on, AR model error would be almost the same. Here is a small code to plot model error for different model orders:

r = ; % Autocorrelation sequence of the process
maxOrd = 50;
El = zeros(1, maxOrd);
for i = 1:maxOrd
    [a, e, k] = levinson(r,i);
    El(i) = e;
end
plot(1:maxOrd, El);

You will get something like this:

And the optimum AR order is the smallest order that reaches a model error close enough to the minimum.
A: Modern procedures would include the explicit identification and incorporation of determinsitic structure (pulses,level shifts,seasonal pulses and local time trends) into an equation that would also include ARIMA structure. Care would be taken to test for transience of parameters and the error variance to meet the requirements of a Gaussian Error Process.
