Skip to contents

A call to arima() can be used in the formula argument of model construction functions in the epinowcast package such as enw_formula(). It declares an ARIMA(p, d, q) latent series indexed by time (and optionally a grouping variable by) whose value at each observation is added to the linear predictor. As with rw(), arguments are not evaluated; they are passed by name for use in model construction. Setting p = d = q = 0 is not allowed; use rw() (equivalent to arima(time, d = 1)) for a random walk.

Usage

arima(time, by, p = 1, d = 0, q = 0)

Arguments

time

Defines the time index of the ARIMA process.

by

Optional grouping variable. If supplied, an independent ARIMA series is fitted for each level of by. Currently limited to a single variable.

p

Non-negative integer. Order of the autoregressive part. Defaults to 1.

d

Non-negative integer. Order of differencing (d = 1 gives an integrated series, equivalent to rw() when p = q = 0). Defaults to 0.

q

Non-negative integer. Order of the moving-average part. Defaults to 0.

Value

A list of class enw_arima_term describing the ARIMA term, interpretable by construct_arima(). Each group draws an independent shock series; phi, theta, and sigma are shared across groups (per-group parameters are a planned extension).

Examples

arima(time)
#> $time
#> [1] "time"
#> 
#> $by
#> NULL
#> 
#> $p
#> [1] 1
#> 
#> $d
#> [1] 0
#> 
#> $q
#> [1] 0
#> 
#> attr(,"class")
#> [1] "enw_arima_term"
arima(time, location)
#> $time
#> [1] "time"
#> 
#> $by
#> [1] "location"
#> 
#> $p
#> [1] 1
#> 
#> $d
#> [1] 0
#> 
#> $q
#> [1] 0
#> 
#> attr(,"class")
#> [1] "enw_arima_term"
arima(time, location, p = 2, d = 1, q = 1)
#> $time
#> [1] "time"
#> 
#> $by
#> [1] "location"
#> 
#> $p
#> [1] 2
#> 
#> $d
#> [1] 1
#> 
#> $q
#> [1] 1
#> 
#> attr(,"class")
#> [1] "enw_arima_term"