Fit Vector Autoregressive (VAR) Model Parameters using Ordinary Least Squares (OLS)
Source:R/RcppExports.R
FitVAROLS.RdThis 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.
Arguments
- Y
Numeric matrix. Matrix of dependent variables (Y).
- X
Numeric matrix. Matrix of predictors (X).
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
Xusing theqr_econfunction from the Armadillo library.Extract the
QandRmatrices from the QR decomposition.Solve the linear system
R * coef = Q.t() * Yto estimate the VAR model coefficientscoef.The function returns a matrix containing the estimated autoregressive and cross-regression coefficients of the VAR model.
See also
Other Fitting Autoregressive Model Functions:
FitMLVARDynr(),
FitMLVARMplus(),
FitVARDynr(),
FitVARLassoSearch(),
FitVARLasso(),
FitVARMplus(),
LambdaSeq(),
ModelVARP1Dynr(),
ModelVARP2Dynr(),
OrigScale(),
PBootVARExoLasso(),
PBootVARExoOLS(),
PBootVARLasso(),
PBootVAROLS(),
RBootVARExoLasso(),
RBootVARExoOLS(),
RBootVARLasso(),
RBootVAROLS(),
SearchVARLasso(),
StdMat()
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