Estimate the error variance of Autoregressive model

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 5K views
emmasaunders12
Messages
43
Reaction score
0
Hi everyone, hopefully someone can help

For an vector AR(1) model of the form

y(t)=Ay(t-1) + et

How does one estimate the variance of the white noise input. I was under the impression that one can simply use the residual of the model fit and estimate the variance from this, when I do a simple simulation in MATLAB however I get very different results

%A small MATLAB
%simulated data

y=[1 2 4 8 16 32 64 128];

%remove mean for yule walker

y=y-repmat(mean(y),1,8);
[ar_coeffs err] = aryule(y,1);

%gives an estimate of the error variance as 1.3985e+003
inity=y(1);
estY(:,1)=inity;
for i=2:8
estY(:,i)=-ar_coeffs(2:end)*estY(i-1);
end
resid=y-estY;
var=sqrt((sum(resid.^2))/8-1);

Now variance in error = 38.3082 very different from before

Can anyone enlighten me, am I calculating the variance in the error correctly?

Thanks

Emma
 
Physics news on Phys.org
emmasaunders12 said:
var=sqrt((sum(resid.^2))/8-1);

This looks like an estimate of the standard deviation, not the variance.

Also you method sets the first prediction equal to the first datum, so that residual is forced to be zero. You only have 7 samples that are useful for estimating the variance of the noise. If you used the unbiased estimator of the variance, you'd divide by 7-1 instead of 8-1.

I don't see where your code defines the array estY.
 
Hi stephen thanks for the help,

Emitting the first estimated term and using:

var=((sum(resid(2:end).^2)/7-1));

gives me 1.6773e+003, not 1.3985e+003 reported by matlab, have you any idea where I am going wrong?

Thanks

Emma
 
I wouldn't expect the aryule function to give the same result as your method. The aryule function estimates both the value of A and the variance of e_t from the data. Your method assumes the value A is known and estimates the variance of e_t from the data.

I haven't studied the details of how aryule works. I think we could figure them out from something like this PDF http://www.google.com/url?sa=t&rct=...LkMzAAr2z1c67pA&bvm=bv.60983673,d.aWM&cad=rja

I think aryule finds the numbers that make the predictions of the model give the best "least squares" fit to the data Those numbers might not be the ones that make the model exactly match the data at t = 1.
 
I am suspicious of the way you subtract the mean of the y's. Doesn't that make all the early y's negative and the later y's positive? A model Y(t) = A*Y(t-1) would be hard to fit to data that changes sign that way. Seems like your original data should have given a perfect fit of Y(t) = 2 * Y(t-1) with no errors.