Skip to contents

Estimates a VARX(p) model where both endogenous and exogenous variables are lagged using ordinary least squares (OLS). Optimised for maximum speed and memory efficiency.

Usage

fVARX(y, ex, p, c)

Arguments

y

A numeric matrix of endogenous time series data with T rows (time periods) and N columns (variables).

ex

A numeric matrix of exogenous time series data with T rows (time periods) and M columns (variables).

p

An integer specifying the number of lags for both endogenous and exogenous variables.

c

An integer indicator for including a constant term (1 = include intercept, 0 = no intercept).

Value

A list with two elements: beta — coefficient matrix of dimensions (Np + M + Mp + c) x N; residuals — (T-p) x N residual matrix.

Details

The VARX(p) model is: $$Y_t = c + A_1 Y_{t-1} + \cdots + A_p Y_{t-p} + B_0 X_t + B_1 X_{t-1} + \cdots + B_p X_{t-p} + e_t$$ Both endogenous and exogenous variables are lagged p periods. Exogenous variables also enter contemporaneously at time t.

Examples

if (FALSE) { # \dontrun{
y  <- matrix(rnorm(200), ncol = 2)
ex <- matrix(rnorm(100), ncol = 1)
result    <- fVARX(y, ex, p = 2, c = 1)
beta      <- result$beta
residuals <- result$residuals
} # }