Learn R Programming

bvartools (version 0.3.0)

covar_prepare_data: Covariance: Data Preparation

Description

Convenience function, which generates the input data for posterior simulation of covariance parameters.

Usage

covar_prepare_data(y, omega_i, k, tt, tvp)

Value

A list with three elements:

y

The prepared vector of endogenous variables.

z

The prepared matrix of regressors.

omega_i

The prepared diagonal matrix of measurement error variances.

All matrices are returned as sparse matrices.

Arguments

y

a \(KT \times 1\) vector of input data.

omega_i

a \(K \times K\) or \(KT \times KT\) matrix of error variances. The matrix must be sparse.

k

an integer of the number of endogenous variables.

tt

an integer of the number of observations.

tvp

logical indicating if the SUR matrix with the values of regressors should be prepared for the estimation of constant or time varying parameters.

Details

For the model $$y_t = Z_{t} a_t + u_t$$ with \(u_t \sim N(0, \Psi \Omega_{t} \Psi^{\prime})\) and \(\Omega_{t}\) as a diagonal matrix of error variances, the function produces the input data for the posterior simulation of the lower triangular covariance coefficients of \(\Psi\) as presented in Primiceri (2005).

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 <- 3
tt <- 4
u <- matrix(1:(k * tt))
omega_i <- Matrix(diag(1:3, k))

# Generate input data (constant parameters)
covar_prepare_data(u, omega_i, k, tt, FALSE)

# Generate input data (time varying parameters)
covar_prepare_data(u, omega_i, k, tt, TRUE)

Run the code above in your browser using DataLab