companion_format: Convert a VAR(p) model to VAR(1) companion format

Description Usage Arguments Details Value Note Examples

View source: R/aux_funs.R

Description

Convert matrices containig observations, coefficients, residuals and covariances to their VAR(1) companion format.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
companion_format(Y, nu, A, U)

big_A(A)

big_Y(Y, p)

big_nu(nu, p)

big_U(U, p)

big_SIGMA(SIGMA, p)

Arguments

Y

A (K x N+p) matrix carrying the data for estimation. There are N observations for each of the K variables with p pre-sample values.

nu

A (K x 1) matrix of intercepts.

A

A (K x Kp) matrix, providing the coeffcients for lag 1 to p with the first row containing the coefficents of the first equation. Parameter p is the maximum lag length and K the number of variables.

U

A (K x N) matrix of residuals.

p

An integer scalar. The lag length of the VAR(p) system.

SIGMA

A (K x K) matrix of covariances. The covariance matrix of the residuals U.

Details

Convert objects such as

such that they correspond to objects taken from a VAR(1) representation.

Value

Note

The difference between big_Y() and Y2Z() is that observations in matrix Z are shifted back by one time period in comparison to Y.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
set.seed(8191)

K <- 3
N <- 5
p <- 2

nu <- matrix(1:K, ncol = 1)
A  <- matrix(0.1, K, K * p); diag(A) <- 1:K / 10
U  <- matrix(rnorm(K * N), K, N)
Y0 <- matrix(0, K, p)
Y  <- create_varp_data(A, Y0, U)

cf <- companion_format(Y, nu, A, U)

cf$U
cf$Y - cf$A %*% cf$Z

## Not run: 
# input has to be in matrix form
 companion_format(Y[1, ], nu[1, ], A[1, ], U[1,])

## End(Not run)

big_A(A)

Y <- matrix(seq_len(K * N), K, N)
big_Y(Y, p)

big_nu(nu, p)

## Not run: 

big_nu(c(nu), p)

## End(Not run)

U <- matrix(seq_len(K * N), K, N)
big_U(U, p)

SIGMA <- matrix(0.5, K, K)
big_SIGMA(SIGMA, p = p)

nielsaka/zeitreihe documentation built on March 17, 2020, 8:38 p.m.