Outputs of an ARMA systems
outputs_ARMA_cpp.Rd
This internal helper function computes the outputs of an ARMA system $$a_0 y_t + a_1 y_{t-1} + \cdots + a_p y_{t-p} = b_0 u_t + \cdots + b_q u_{t-q}$$
Arguments
- A1
\((m, mp)\) matrix \(-a_0^{-1}(a_p,...,a_1)\).
- B
\((m, n(q+1))\) matrix \(a_0^{-1}(b_0,...,b_q\).
- t0
integer, start iteration at t = t0.
- u
\((n, N)\) matrix with the inputs \((u_1,...,u_N\).
- y
\((m, N)\) matrix with the outputs \((y_1,...,y_N\).
Value
This RcppArmadillo routine returns NULL
but overwrites
the input argument y
with the computed outputs!
Details
Values \(y_t\), \(u_t\) for \(t\leq 0\) are implicitly set to be zero. However, by starting the iteration with some \(t_0>1\) we can enforce non-zero initial values.
Note
Use this procedure with care!
The procedure does not check the input arguments. We require \(m > 0\), \(p \geq 0\), \(n(q+1) \geq 0\) and \(1 \leq t_0 \leq N\).
The procedure overwrites the input argument
y
.The data matrices are organized columnwise (to avoid memory shuffling)!
Note also the non standard representation of the coefficient matrices.
See also
outputs_ARMA_cpp
, residuals_ARMA_cpp
, cll_theta_ARMA_cpp
,
outputs_STSP_cpp
, residuals_STSP_cpp
, cll_theta_STSP_cpp
and
solve_de
, solve_inverse_de
and ll
.
Examples
# generate a random ARMA(2,1) model (3 outputs, 2 inputs)
p = 2
q = 1
m = 3
n = 2
model = test_armamod(dim = c(m, n), degrees = c(p,q), digits = 2)
A = unclass(model$sys$a)
a0 = A[,,1]
A1 = -A[,,(p+1):2]
dim(A1) = c(m, m*p)
A1 = solve(a0, A1)
B = unclass(model$sys$b)
dim(B) = c(m, n*(q+1))
B = solve(a0, B)
# generate random noise sequence (sample size N = 10)
n.obs = 10
u = matrix(rnorm(n.obs*n), nrow = n, ncol = n.obs)
print(u)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -0.9234875 0.06413824 -0.9346702 1.5322629 1.6740514 -2.593322
#> [2,] -1.3827419 -0.84400232 1.5097295 0.3183137 -0.8690263 -2.874328
#> [,7] [,8] [,9] [,10]
#> [1,] -0.009260612 -1.0108320 -0.6941441 -1.05623972
#> [2,] -0.272488684 -0.6879902 -0.5103549 -0.02120797
# generate matrix for the outputs
y = matrix(0, nrow = m, ncol = n.obs)
# call outputs_ARMA_cpp()
outputs_ARMA_cpp(A1, B, t0 = 2, u, y) # start with t>=2
print(u)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -0.9234875 0.06413824 -0.9346702 1.5322629 1.6740514 -2.593322
#> [2,] -1.3827419 -0.84400232 1.5097295 0.3183137 -0.8690263 -2.874328
#> [,7] [,8] [,9] [,10]
#> [1,] -0.009260612 -1.0108320 -0.6941441 -1.05623972
#> [2,] -0.272488684 -0.6879902 -0.5103549 -0.02120797
print(y) # y is overwritten with the computed outputs
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 0 1.4816666 -6.68354563 -3.163022 19.727964 1.146488 -18.37155
#> [2,] 0 -3.0774978 -2.68220557 8.123394 2.456978 -6.716153 18.16196
#> [3,] 0 -0.6506853 -0.04853879 8.301383 -4.003540 -24.220695 10.10210
#> [,8] [,9] [,10]
#> [1,] 37.54089 -49.93209 -243.06434
#> [2,] -27.10059 -113.44119 83.12755
#> [3,] 17.60264 -27.35485 121.22911