Creates a precision matrix as a sparse matrix object considering the specification stated in Details.
Details
Let the second order auto-regression model be defined as
$$a_0 x_t + a_1 x_{t-1} + a_2 x_{t-2} = w_t, w_t ~ N(0, 1).$$
The n times n symmetric precision matrix Q for x_1, x_2, ..., x_n has the following non-zero elements:
\(Q_{1,1} = Q_{n,n} = a_0^2\)
\(Q_{2,2} = Q_{n-1,n-1} = a_0^2 + a_1^2\)
\(Q_{1,2} = Q_{2,1} = Q_{n-1,n} = Q_{n,n-1} = a_0 a_1\)
\(Q_{t,t} = q_0 = a_0^2 + a_1^2 + a_2^2, t = 3, 4, ..., n-2\)
\(Q_{t,t-1} = Q_{t-1,t} = q_1 = a_1(a_0 + a_2), t = 3, 4, ..., n-1\)
\(Q_{t,t-2} = Q_{t-2,t} = q_2 = a_2 a_0, t = 3, 4, ..., n\)
Examples
ar2precision(7, c(1, -1.5, 0.9))
#> 7 x 7 sparse Matrix of class "dsTMatrix"
#>
#> [1,] 1.0 -1.50 0.90 . . . .
#> [2,] -1.5 3.25 -2.85 0.90 . . .
#> [3,] 0.9 -2.85 4.06 -2.85 0.90 . .
#> [4,] . 0.90 -2.85 4.06 -2.85 0.90 .
#> [5,] . . 0.90 -2.85 4.06 -2.85 0.9
#> [6,] . . . 0.90 -2.85 3.25 -1.5
#> [7,] . . . . 0.90 -1.50 1.0