views:

373

answers:

2

I have a series of numbers. I calculated the "auto-regression" between them using Yule-Walker method.

But now how do I extend the series?

Whole working is as follows:

a) the series I use:

143.85 141.95 141.45 142.30 140.60 140.00 138.40 137.10 138.90 139.85 138.75 139.85 141.30 139.45 140.15 140.80 142.50 143.00 142.35 143.00 142.55 140.50 141.25 140.55 141.45 142.05

b) this data is loaded in to data using:

data = load('c:\\input.txt', '-ascii');

c) the calculation of the coefficients:

ar_coeffs = aryule(data,9);

this gives:

ar_coeffs =
 1.0000 -0.9687 -0.0033 -0.0103 0.0137 -0.0129 0.0086 0.0029 -0.0149 0.0310

d) Now using this, how do I calculate the next number in the series?

[any other method of doing this (except using aryule()) is also fine... this is what I did, if you have a better idea, please let me know!]

+1  A: 

Your data has a non-zero mean. Doesn't the Yule-Walker model assume the data is the output of a linear filter excited by a zero-mean white noise process?

If you remove the mean, this example using ARYULE and LPC might be what you're looking for. The procedure boils down to:

a = lpc(data,9); % uses Yule-Walker modeling
pred = filter(-a(2:end),1,data);
disp(pred(end)); % the predicted value at time N+1
mtrw
+2  A: 

For a real valued sequence x of length N, and a positive order p:

coeff = aryule(x, p)

returns the AR coefficients of order p of the data x (Note that coeff(1) is a normalizing factor). In other words it models values as a linear combination of the past p values. So to predict the next value, we use the last p values as:

x(N+1) = sum_[k=0:p] ( coeff(k)*x(N-k) )

or in actual MATLAB code:

p = 9;
data = [...];      % the seq you gave
coeffs = aryule(data, p);
nextValue = -coeffs(2:end) * data(end:-1:end-p+1)';


EDIT: If you have access to System Identification Toolbox, then you can use any of a number of functions to estimate AR/ARMAX models (ar/arx/armax) (or even find the order of AR model using selstruc):

m = ar(data, p, 'yw');    % yw for Yule-Walker method
pred = predict(m, data, 1);

coeffs = m.a;
nextValue = pred(end);

subplot(121), plot(data)
subplot(122), plot( cell2mat(pred) )
Amro

related questions