var_lm {bvhar}R Documentation

Fitting Vector Autoregressive Model of Order p Model

Description

This function fits VAR(p) using OLS method.

Usage

var_lm(y, p = 1, include_mean = TRUE, method = c("nor", "chol", "qr"))

## S3 method for class 'varlse'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'varlse'
knit_print(x, ...)

Arguments

y

Time series data of which columns indicate the variables

p

Lag of VAR (Default: 1)

include_mean

Add constant term (Default: TRUE) or not (FALSE)

method

Method to solve linear equation system. ("nor": normal equation (default), "chol": Cholesky, and "qr": HouseholderQR)

x

varlse object

digits

digit option to print

...

not used

Details

This package specifies VAR(p) model as

Y_{t} = A_1 Y_{t - 1} + \cdots + A_p Y_{t - p} + c + \epsilon_t

If include_type = TRUE, there is c term. Otherwise (include_type = FALSE), there is no c term. The function estimates every coefficient matrix A_1, \ldots, A_p, c.

Then perform least squares to the following multivariate regression model

Y_0 = X_0 A + error

which gives

\hat{A} = (X_0^T X_0)^{-1} X_0^T Y_0

Value

var_lm() returns an object named varlse class. It is a list with the following components:

coefficients

Coefficient Matrix

fitted.values

Fitted response values

residuals

Residuals

covmat

LS estimate for covariance matrix

df

Numer of Coefficients: mp + 1 or mp

p

Lag of VAR

m

Dimension of the data

obs

Sample size used when training = totobs - p

totobs

Total number of the observation

call

Matched call

process

Process: VAR

type

include constant term ("const") or not ("none")

y0

Y_0

design

X_0

y

Raw input

It is also a bvharmod class.

References

Lütkepohl, H. (2007). New Introduction to Multiple Time Series Analysis. Springer Publishing.

See Also

Examples

# Perform the function using etf_vix dataset
fit <- var_lm(y = etf_vix, p = 2)
class(fit)
str(fit)

# Extract coef, fitted values, and residuals
coef(fit)
head(residuals(fit))
head(fitted(fit))

[Package bvhar version 2.0.1 Index]