Compute the theoretical autocorrelation function for an ARMA process.
Arguments
- ar
A
vectorof length p containing AR coefficients- ma
A
vectorof length q containing MA coefficients- lag_max
A
unsigned integerindicating the maximum lag necessary
Details
This is an implementaiton of the ARMAacf function in R. It is approximately 40x times faster. The benchmark was done on iMac Late 2013 using vecLib as the BLAS.
Examples
# ARMA(2,1)
ARMAacf_cpp(c(1.0, -0.25), 1.0, lag_max = 10)
#> [,1]
#> [1,] 1.000000000
#> [2,] 0.875000000
#> [3,] 0.625000000
#> [4,] 0.406250000
#> [5,] 0.250000000
#> [6,] 0.148437500
#> [7,] 0.085937500
#> [8,] 0.048828125
#> [9,] 0.027343750
#> [10,] 0.015136719
#> [11,] 0.008300781
# ARMA(0,1)
ARMAacf_cpp(numeric(0), .35, lag_max = 10)
#> [,1]
#> [1,] 1.000000
#> [2,] 0.311804
#> [3,] 0.000000
#> [4,] 0.000000
#> [5,] 0.000000
#> [6,] 0.000000
#> [7,] 0.000000
#> [8,] 0.000000
#> [9,] 0.000000
#> [10,] 0.000000
#> [11,] 0.000000