covar_vector_to_matrix: Covariance: Vector to Matrix

View source: R/RcppExports.R

covar_vector_to_matrixR Documentation

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)

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.

Value

A sparse, block diagonal matrix.

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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.1467-937X.2005.00353.x")}

Examples


# 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)


franzmohr/bvartools documentation built on Jan. 28, 2024, 4:06 a.m.