Learn R Programming

bvartools (version 0.3.0)

covar_vector_to_matrix: Covariance: Vector to Matrix

Description

Convenience function, which takes the vector of draws of lower triangular covariance coefficients and transforms it into a matrix with ones on the main diagonal. In case of time varying parameters the resulting matrix will be block diagonal.

Usage

covar_vector_to_matrix(psi, k, tt)

Value

A sparse, block diagonal matrix.

Arguments

psi

a \(K (K - 1) / 2 \times 1\) or \(T K (K - 1) / 2 \times 1\) vector of input data.

k

the number \(K\) of endogenous variables.

tt

the number \(T\) of observations.

References

Chan, J., Koop, G., Poirier, D. J., & Tobias J. L. (2019). Bayesian econometric methods (2nd ed.). Cambridge: Cambridge University Press.

Primiceri, G. E. (2005). Time varying structural vector autoregressions and monetary policy. The Review of Economic Studies 72(3), 821--852. tools:::Rd_expr_doi("10.1111/j.1467-937X.2005.00353.x")

Examples

Run this code

# Create artificial data
k <- 5
tt <- 4
n_covar <- (k - 1) * k / 2

# Constant parameters
psi <- matrix(1:(n_covar))
covar_vector_to_matrix(psi, k, tt)

# Time varying parameters
psi <- matrix(1:(n_covar * tt))
covar_vector_to_matrix(psi, k, tt)

Run the code above in your browser using DataLab