[R] Problem with calculating the residuals in an AR(p)-model

Spiderschwein martin_moeller at gmx.de
Tue Feb 17 13:00:45 CET 2009


I'm trying to calculate the residuals in a one-sided AR(p) model:
sum (phi_j (X_t-j - EX)) = epsilon

My X is an ARMA(1,1)-model, which can be represented as an AR(infty) model.
I calculate the order of the model with AIC and the parameters with the
Yule-Walker method.

For the residuals, I tried:

for (k in (p+1):n){ 
     for (j in 1:p){
          eps[k] <- sum(phi[j] * (X[k-j] - mean(X)))
     ceps[k] <- eps[k] - sum(eps)/(n-p+1) #centering the residuals

The residuals in my ARMA(1,1)-models are t-distributed with 6 degrees of
Unfortunately my code results in residuals, which are all around zero. So
ecdf(eps) or ecdf(ceps) are very different from a t(6)-distribution.

Where's the bug in my code?

View this message in context: http://www.nabble.com/Problem-with-calculating-the-residuals-in-an-AR%28p%29-model-tp22055764p22055764.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list