Learn R Programming

gmvarkit (version 1.4.1)

smart_covmat: Create random VAR-model \((dxd)\) error term covariance matrix \(\Omega\) fairly close to a given positive definite covariance matrix using (scaled) Wishart distribution

Description

random_covmat generates random VAR model \((dxd)\) error term covariance matrix \(\Omega\) from (scaled) Wishart distribution that is fairly close to the given matrix.

Usage

smart_covmat(d, M, Omega, W_and_lambdas, accuracy, structural_pars = NULL)

Arguments

d

the number of time series in the system.

M

a positive integer specifying the number of mixture components.

Omega

a symmetric positive definite \((dxd)\) covariance matrix specifying expected value of the matrix to be generated.

W_and_lambdas

the mean of the normal distribution the new parameters are generated from.

If lambdas are not constrained:

a size \((d^2 - n_zeros + d*(M - 1))\) vector \((Wvec(W),\lambda_{2},...,\lambda{M})\), where \(n_zeros\) is the number of zero constraints in \(W\) and \(\lambda_m=(\lambda_{m1},...,\lambda_{md})\).

If lambdas are constrained:

a size \((d^2 - n_zeros + r)\) vector \((Wvec(W),\gamma)\), where \(C_{\lambda}\gamma =(\lambda_2,....,\lambda_M)\), \(\gamma\) is of the size \((r x 1)\), and \(C_{\lambda}\) of the size \((d*(M - 1) x r\)).

accuracy

a positive real number adjusting how close to the given covariance matrix the returned individual should be.

For reduced form models standard deviation of each diagonal element is for reduced form models

  • \(\omega_{i,i}/\)accuracy when accuracy > d/2

  • and sqrt(2/d)*\(\omega_{i,i}\) when accuracy <= d/2.

Wishart distribution is used for reduced form models, but for more details read the source code.

For structural models, the parameters are generated from normal distribution with mean given by the argument W_and_lambdas and the standard deviation is sqrt(abs(W_and_lambdas)/(d + accuracy)).

structural_pars

If NULL a reduced form model is considered. For structural model, should be a list containing the following elements:

  • W - a \((dxd)\) matrix with its entries imposing constraints on \(W\): NA indicating that the element is unconstrained, a positive value indicating strict positive sign constraint, a negative value indicating strict negative sign constraint, and zero indicating that the element is constrained to zero.

  • C_lambda - a \((d(M-1) x r)\) constraint matrix that satisfies (\(\lambda\)\(_{2}\)\(,...,\) \(\lambda\)\(_{M}) =\) \(C_{\lambda} \gamma\) where \(\gamma\) is the new \((r x 1)\) parameter subject to which the model is estimated (similarly to AR parameter constraints). The entries of C_lambda must be either positive or zero. Ignore (or set to NULL) if the eigenvalues \(\lambda_{mi}\) should not be constrained.

See Virolainen (2020) for the conditions required to identify the shocks and for the B-matrix as well (it is \(W\) times a time-varying diagonal matrix with positive diagonal entries).

Value

For reduced form models:

Returns a \((d(d+1)/2x1)\) vector containing vech-vectorized covariance matrix \(\Omega\).

For structural models:

Returns a length \(d^2 - n_zeros - d*(M - 1)\) vector of the form \((Wvec(W),\lambda_2,...,\lambda_M)\) where \(\lambda_m=(\lambda_{m1},...,\lambda_{md})\) contains the eigenvalue parameters of the \(m\)th regime \((m>1)\) and \(n_zeros\) is the number of zero constraints in \(W\). If lambdas are constrained, replacce \(d*(M - 1)\) in the length with \(r\) and \(\lambda_2,...,\lambda_M)\) with \(\gamma\). The operator \(Wvec()\) vectorizes a matrix and removes zeros.