Skip to contents

This function estimates the parameters of a VAR model using the Ordinary Least Squares (OLS) method. The OLS method is used to estimate the autoregressive and cross-regression coefficients.

Usage

FitVAROLS(Y, X)

Arguments

Y

Numeric matrix. Matrix of dependent variables (Y).

X

Numeric matrix. Matrix of predictors (X).

Value

Matrix of estimated autoregressive and cross-regression coefficients.

Details

The FitVAROLS() function estimates the parameters of a Vector Autoregressive (VAR) model using the Ordinary Least Squares (OLS) method. Given the input matrices Y and X, where Y is the matrix of dependent variables, and X is the matrix of predictors, the function computes the autoregressive and cross-regression coefficients of the VAR model. Note that if the first column of X is a vector of ones, the constant vector is also estimated.

The steps involved in estimating the VAR model parameters using OLS are as follows:

  • Compute the QR decomposition of the lagged predictor matrix X using the qr_econ function from the Armadillo library.

  • Extract the Q and R matrices from the QR decomposition.

  • Solve the linear system R * coef = Q.t() * Y to estimate the VAR model coefficients coef.

  • The function returns a matrix containing the estimated autoregressive and cross-regression coefficients of the VAR model.

Author

Ivan Jacob Agaloos Pesigan

Examples

Y <- dat_p2_yx$Y
X <- dat_p2_yx$X
FitVAROLS(Y = Y, X = X)
#>           [,1]        [,2]        [,3]        [,4]        [,5]         [,6]
#> [1,] 0.7899726  0.36836768 0.008539283  0.02231498  0.11338780  0.024505442
#> [2,] 1.0001995  0.01334496 0.481949237 -0.01730029 -0.03223315  0.234373552
#> [3,] 1.0666814 -0.03022951 0.014945306  0.60741736 -0.01610408 -0.006149189
#>             [,7]
#> [1,] -0.01143384
#> [2,]  0.01815779
#> [3,]  0.29620975