Takes an ARMA function and converts it to an infinite MA process.
Arguments
- ar
A
column vector
of length p- ma
A
column vector
of length q- lag_max
A
int
of the largest MA(Inf) coefficient required.
Details
This function is a port of the base stats package's ARMAtoMA. There is no significant speed difference between the two.
Examples
# ARMA(2,1)
ARMAtoMA_cpp(c(1.0, -0.25), 1.0, 10)
#> [,1]
#> [1,] 2.00000000
#> [2,] 1.75000000
#> [3,] 1.25000000
#> [4,] 0.81250000
#> [5,] 0.50000000
#> [6,] 0.29687500
#> [7,] 0.17187500
#> [8,] 0.09765625
#> [9,] 0.05468750
#> [10,] 0.03027344
# ARMA(0,1)
ARMAtoMA_cpp(numeric(0), 1.0, 10)
#> [,1]
#> [1,] 1
#> [2,] 0
#> [3,] 0
#> [4,] 0
#> [5,] 0
#> [6,] 0
#> [7,] 0
#> [8,] 0
#> [9,] 0
#> [10,] 0