selection_matrix: Selection matrix for imposing linear restrictions

Description Usage Arguments Value Note Examples

View source: R/SVAR-3-identification.R

Description

Selection matrix selecting those elements in X with restrictions in place. This function will create the matrix C in C %*% vec(X) = c.

Usage

1
selection_matrix(X, value = 0:1, flatten = vec)

Arguments

X

A square matrix, the target of imposing restrictions. The restricted elements must coincide with the values specified for value below. The non-restricted elements may have NAs or any other value except those in value.

value

A numeric vector, the values imposed on elements of X. May be numeric or contain NA. Every element of X with any of these values will be assumed to be restricted to that value.

flatten

A function, flattening the dimension of X. The default is to vec(), but in some situations may want to select unique elements of a symmetric matrix and then vech() is helpful.

Value

A matrix containing 0s and 1s of dimension

if flatten = vec or

if flatten = vech. The scalar R is the number of restrictions and K the number of variables, i.e. K is the number of both the rows and the columns of X.

Note

This function is only able to create selection matrices for restrictions on individual elements. Restrictions on linear combinations of elements are not (yet) implemented.

Examples

1
2
3
4
5
set.seed(8191)
K <- 4
A <- matrix(rnorm(K^2), K, K)
A[sample(1:K^2, K * (K-1) / 2)] <- 0
selection_matrix(A)

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