Description Usage Arguments Details Value Note Examples
Convert matrices containig observations, coefficients, residuals and covariances to their VAR(1) companion format.
1 2 3 4 5 6 7 8 9 10 11 |
Y |
A |
nu |
A |
A |
A |
U |
A |
p |
An integer scalar. The lag length of the VAR(p) system. |
SIGMA |
A |
Convert objects such as
A - a matrix of slope parameters
nu - a column vector of intercepts
Y - a matrix of observations
U - a matrix of residuals
SIGMA - a covariance matrix
such that they correspond to objects taken from a VAR(1) representation.
companion_format
A list with five elements. Four elements
Y, nu, A and U correspond to the output of big_Y, big_nu,
big_A, and big_U. The fifth element is the (Kp x N) regressor matrix
Z populated with lags of Y.
big_A
A (Kp x Kp) matrix with the slope parameters on the
first K rows. The remaining rows carry block-diagonal unit matrices and the
remainder are zeros.
big_Y
A (Kp x N) matrix. The p-1 lags of Y are
pasted as rows below Y. The p pre-sample observations are deleted.
big_nu
A (Kp x 1) colum matrix. The first K elements
correspond to nu. The remaining elements are zero.
big_U
A (Kp x N) matrix. The first K rows contain the
residuals, the last K(p-1) rows consist of zeros.
big_SIGMA
A (Kp x Kp) matrix. The upper left (K x K)
block will contain the original covariance matrix. The remaining elements
will be zero.
The difference between big_Y() and Y2Z() is that
observations in matrix Z are shifted back by one time period in
comparison to Y.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.