
ARIMA(p, d, q) by Hannan-Rissanen (Geron Ch 13, morie.fn hmarim)
Source:R/geron_ml_native.R
morie_geron_arima.RdPure AR models (q = 0) are plain OLS on lags; otherwise a long
autoregression of order k supplies the innovations and the ARMA
coefficients come from OLS on lags plus fitted innovations. forecast
is a closure taking a horizon h.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_arima(V)
#> $ar
#> [1] 1
#>
#> $ma
#> numeric(0)
#>
#> $intercept
#> [1] 1
#>
#> $residuals
#> [1] -1.776357e-15 -1.776357e-15 -2.664535e-15 -2.664535e-15 -3.552714e-15
#> [6] -3.552714e-15 -3.552714e-15
#>
#> $sigma2
#> [1] 1.167514e-29
#>
#> $aic
#> [1] -460.3406
#>
#> $fitted
#> [1] 2 3 4 5 6 7 8
#>
#> $differenced
#> [1] 1 2 3 4 5 6 7 8
#>
#> $forecast
#> function (h = 1)
#> {
#> H <- as.integer(h)
#> .morie_gr_need(H >= 1L, "forecast: h must be >= 1")
#> hist <- z
#> errs <- resid
#> out <- numeric(0)
#> for (i in seq_len(H)) {
#> val <- intercept
#> if (length(ar))
#> for (a in seq_along(ar)) val <- val + ar[a] * hist[length(hist) -
#> a + 1L]
#> if (length(ma)) {
#> for (b in seq_along(ma)) {
#> val <- val + ma[b] * (if (length(errs) > b -
#> 1L)
#> errs[length(errs) - b + 1L]
#> else 0)
#> }
#> }
#> hist <- c(hist, val)
#> errs <- c(errs, 0)
#> out <- c(out, val)
#> }
#> f <- out
#> if (length(anchors))
#> for (a in rev(anchors)) f <- a + cumsum(f)
#> f
#> }
#> <bytecode: 0x562173c2b370>
#> <environment: 0x56215faaf668>
#>
#> $order
#> [1] 1 0 0
#>
#> $estimate
#> [1] 1.167514e-29
#>
#> $n
#> [1] 7
#>
#> $method
#> [1] "ARIMA(1,0,0) by OLS"
#>