Skip to contents

Compute the initial state covariance of ARMA model

Usage

arma_Q0gnb(phi, theta, tol = 2.220446e-16)

Arguments

phi

autoregression parameters.

theta

moving average parameters.

tol

tollerance. (TODO: explain)

Details

Experimental computation of the initial state covariance matrix of ARMA models.

The numerical results are comparable to SSinit = "Rossignol2011" method in arima and related functions. The method seems about twice faster than "Rossignol2011" on the models I tried but I haven't done systematic tests.

See section ‘examples’ below and, for more tests based on the tests from stats, the tests in test/testthat/test-arma-q0.R.

Value

a matrix

References

Gardner G, Harvey AC, Phillips GDA (1980). “Algorithm AS154. An algorithm for exact maximum likelihood estimation of autoregressive-moving average models by means of Kalman filtering.” Applied Statistics, 311--322.

R bug report PR#14682 (2011-2013) <URL: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14682>.

Author

Georgi N. Boshnakov

See also

Examples

Q0a <- arma_Q0gnb(c(0.2, 0.5), c(0.3)) 
Q0b <- makeARIMA(c(0.2, 0.5), c(0.3), Delta = numeric(0))$Pn
all.equal(Q0a, Q0b) ## TRUE
#> [1] TRUE

## see test/testthat/test-arma-q0.R for more;
## these functions cannot be defined in the package due to their use of
## \code{:::} on exported base R functions.
##
## "Gardner1980"
arma_Q0Gardner <- function(phi, theta, tol = .Machine$double.eps){
    ## tol is not used here
    .Call(stats:::C_getQ0, phi, theta)
}
## "Rossignol2011"
arma_Q0bis <- function(phi, theta, tol = .Machine$double.eps){
    .Call(stats:::C_getQ0bis, phi, theta, tol)
}

arma_Q0Gardner(c(0.2, 0.5), c(0.3))
#>          [,1]      [,2]
#> [1,] 2.111111 1.0222222
#> [2,] 1.022222 0.6177778
arma_Q0bis(c(0.2, 0.5), c(0.3)) 
#>          [,1]      [,2]
#> [1,] 2.111111 1.0222222
#> [2,] 1.022222 0.6177778
Q0a
#>          [,1]      [,2]
#> [1,] 2.111111 1.0222222
#> [2,] 1.022222 0.6177778
Q0b
#>          [,1]      [,2]
#> [1,] 2.111111 1.0222222
#> [2,] 1.022222 0.6177778