Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/ensure_causality_invertibility.R
Test to ensure AR parameters are causal and MA parameters are invertible. If the AR parameters are used, the function converts them to casual If the MA parameters are used, the function converts them to invertible parameters If ar parameters, (phi_1, phi_2, ..., phi_p) If ma parameter, (theta_1, theta_2, ..., theta_q)
1 | ensure_causality_invertibility(parameters)
|
parameters |
vector of AR or MA parameters, in the order of |
Test to ensure AR parameters are causal and MA parameters are invertible It converts them to casual/incertible parameters if not
parameter values that are causal or invertible, ensureing unique solutions.
Hannah Lennon <drhannahlennon@gmail.com>
Jingsong Yuan, Time Series Lecture Notes, https://www.ma.man.ac.uk/~jy/tsaf/
Brockwell and Davis (1987)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(polynom)
ensure_causality_invertibility(c(0.5, 1.3))
p <- 3
q <- 3
para <- c(0.2, 1, 0.2, 1, -0.5, 0.3)
para[1:p] <- ensure_causality_invertibility(para[1:p])
para[(p + 1):(p + q)] <- -ensure_causality_invertibility(-para[(p + 1):(p + q)])
## The function is currently defined as
function (parameters)
{
L <- length(parameters)
ps <- polynomial(c(-parameters[L:1], 1))
ps <- solve(ps)
if (all(abs(ps) < 1))
return(parameters)
else {
j <- numeric(L)
k <- 0
vec <- numeric(L)
ps[abs(ps) >= 1] <- 1/ps[abs(ps) >= 1]
while (k < L) {
j <- add_1(j)
k <- sum(j)
vec[k] <- vec[k] + (-1)^(k + 1) * prod(ps^j)
}
return(as.numeric(vec))
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.