Estimate an VAR model

VAR(formula, ...)

Arguments

formula

Model specification (see "Specials" section).

...

Further arguments for arima

Specials

pdq

The AR special is used to specify the lag order for the auto-regression.
AR(p = 0)
p
The order of the auto-regressive (AR) terms.

xreg

Exogenous regressors can be included in an ARIMA model without explicitly using the xreg() special. Common exogenous regressor specials as specified in common_xregs can also be used. These regressors are handled using stats::model.frame(), and so interactions and other functionality behaves similarly to stats::lm(). The inclusion of a constant in the model follows the same rules as stats::lm(), where including 1 will add a constant and 0 or -1 will remove the constant (by default, a constant is included).
xreg(...)
...
Bare expressions for the exogenous regressors (such as
log(x))

Examples

lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) fit <- lung_deaths %>% model(VAR(vars(log(mdeaths), fdeaths) ~ AR(3))) fit
#> # A mable: 1 x 1 #> `VAR(vars(log(mdeaths), fdeaths) ~ AR(3))` #> <model> #> 1 <VAR(3)>
fit %>% forecast()
#> # A fable: 24 x 5 [1M] #> # Key: .model [1] #> .model index mdeaths fdeaths .distribution #> <chr> <mth> <dbl> <dbl> <dist> #> 1 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Jan 1490. 602. t(MVN[2]) #> 2 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Feb 1496. 582. t(MVN[2]) #> 3 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Mar 1500. 575. t(MVN[2]) #> 4 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Apr 1475. 555. t(MVN[2]) #> 5 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 May 1452. 543. t(MVN[2]) #> 6 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Jun 1443. 538. t(MVN[2]) #> 7 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Jul 1448. 539. t(MVN[2]) #> 8 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Aug 1462. 545. t(MVN[2]) #> 9 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Sep 1477. 552. t(MVN[2]) #> 10 VAR(vars(log(mdeaths), fdeaths) ~ AR(… 1980 Oct 1490. 557. t(MVN[2]) #> # … with 14 more rows