ARMA(p,q)

An ARMA model is an autoregressive moving average model. Written in operator form we have:

$$(1-\phi_1 B - ... - \phi_pB^p)X_t = (1 - \theta_1 B - ... - \theta_q B^q)$$

If we remember the plotts.true.wge plots we did in a previous section, you may have wondered what happens when the AR and MA chave common factors? Well, they cancel out conveniently! Lets look at an example:

plotts.true.wge(phi = c(1.1, -.9),theta = c(1.1,-.9))

Wow! It is zero everywhere on the spectral density! BUT, it is not actually zero, as this is a logarithmic scale. This means it is actually one everywhere, and this leads us to the conclusion, along with the ACF and common sense that if all the factors between the AR and MA components are the same, we are left with $X_t = a_t$, pure white noise! This allows us to conclude that factors can cancel out, at least with my pea brain.

Another example:

plotts.true.wge(250, phi = c(1.3, -.4), theta = 0.8)
plotts.true.wge(250, phi = 0.5)

Bam! They are the same!!! Wow!

Blending AR and MA components

An ARMA(p,q) model is invertible iff the roots of the AR side and the MA side are invertible. For a process to be considered arma it is stationary and invertible. Lets check it out with plotts.true again:

plotts.true.wge(250, phi = c(1.95, -1.9, .9025))
plotts.true.wge(250, theta = 0.95)
plotts.true.wge(250, phi = c(1.95, -1.9, .9025), theta = 0.95)

Lets also just take a moment that aic and aic5.wge exist and tell us things. There is no need to write them here because thats a lot of work

Psi weights with AR models:

$$\psi_0 = 1$$ $$\psi_1 = \phi_1$$ $$\psi_2 = \phi_1 \psi_1 +\phi_2$$ $$\psi_3 = \phi_1 \psi_2 + \phi_2 \psi_1 + \phi_3$$ $$\psi_\ell = \sum_{i =1} ^p \phi_i \psi_{\ell - i}$$

multfun <- function(phi,l,psi){
    sum(phi[1:l] * psi[1:l])
}
phitest <- function(phi,l){
    if (l>length(phi)){
         return( append(phi,rep(0,l-length(phi))))
    }
    else{
        return(phi)
    }
}
arpsiweights <- function(phi, theta = as.numeric(0), l){
    phi <- phitest(phi,l)
    psi <- as.numeric(1) 
    for (i in 2:l){
        psi[i] <-  multfun(phi,i-1,rev(psi)) 
    }
psi
}

Psi weights for ARMA

$$\psi_0 = 1$$ $$\psi_1 = \phi_1 - \theta_1$$ $$\psi_2 = \phi_1 \psi_1 +\phi_2 - \theta_2$$ $$\psi_3 = \phi_1 \psi_2 + \phi_2 \psi_1 + \phi_3 -theta_3$$ $$\psi_\ell = \sum_{i =1} ^p \phi_i \psi_{\ell - i} - \theta_i$$

psiweights <- function(phi, theta = as.numeric(0), l){
    phi <- phitest(phi,l)
    psi <- as.numeric(1) 
    theta <- c(0,theta)
    theta <- phitest(theta,l)
    for (i in 2:l){
        psi[i] <-  multfun(phi,i-1,rev(psi)) - theta[i]
    }
psi
}


josephsdavid/tstest documentation built on July 3, 2019, 4:48 p.m.