rvar: Generate pseudo-random data from a Vector Autoregression

Description Usage Arguments Details Value Author(s) Examples

Description

This function generates data from a user-specified Vector Autoregression (VAR)

Usage

1
2
rvar(nobs, coefficients, intercept, vcv, nburn = 1000,
     y0 = matrix(0, nlag, neq))

Arguments

nobs

Integer; the number of observations to generate.

coefficients

A list of numeric vectors; each vector specifies the coefficients of one of the VAR equations.

intercept

A numeric vector containing the intercepts.

vcv

A numeric matrix representing the variance-covariance matrix of the innovations.

nburn

An integer, the number of draws to discard before generating draws from the VAR.

y0

A matrix containing the inital values of the series.

Details

Let β_1 represent the first element of the coefficients list and suppose that there are k equations with l lags. The first equation of the DGP is

y[t,1] = intercept[1] + c(y[t-(1:l),1],…,y[t-(1:l),k]) %*% coefficients[[1]] + epsilon[t,1]

.

Value

A data frame with nobs rows containing the generated series and all of their lags. This is redundant information, but makes it easier to use these results directly in a regression model.

Author(s)

Gray Calhoun gcalhoun@iastate.edu

Examples

1
2
3
4
5
6
d <- rvar(10000, list(a = c(0.5, 0, 0.2, 0.1),
                      b = c(0.1, 0.2, 0.5, 0)),
          c(4, 6), diag(2))

lm(a ~ aL1 + aL2 + bL1 + bL2, data = d)
lm(b ~ aL1 + aL2 + bL1 + bL2, data = d)

grayclhn/oosanalysis-R-library documentation built on May 17, 2019, 8:33 a.m.