[R] Arima bug?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Feb 20 01:06:25 CET 2009


rkevinburton at charter.net wrote:
> I was looking at the 'R' code associated with arima. I see the following:
> 
>     upARIMA <- function(mod, phi, theta) {
>         p <- length(phi)
>         q <- length(theta)
>         mod$phi <- phi
>         mod$theta <- theta
>         r <- max(p, q + 1)
>         if (p > 0) 
>             mod$T[1:p, 1] <- phi
>         if (r > 1) 
>             mod$Pn[1:r, 1:r] <- .Call(R_getQ0, phi, theta)
>         else if (p > 0) 
>             mod$Pn[1, 1] <- 1/(1 - phi^2)
>         else mod$Pn[1, 1] <- 1
>         mod$a[] <- 0
>         mod
>     }
>  
> 
> In particular the statement:
> 
>        else if (p > 0) 
>             mod$Pn[1, 1] <- 1/(1 - phi^2)
....

> 
> So I was wondering if there is something that I am missing that will
"guarantee" that the length of the phi vector in this case is always 1.

There is. You are only getting there if r > 1 is FALSE, and by the 
definition of r, that can only happen if q==0 and (p==0 or p==1).

-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list