Learn R Programming

⚠️There's a newer version (2.2.1) of this package.Take me there.

gmvarkit

The goal of gmvarkit is to provide tools to work with Gaussian Mixture Vector Autoregressive (GMVAR) model. Most importantly gmvarkit provides function fitGMVAR for two phase maximum likelihood estimation, but it also constains functions for quantile residual tests, graphical diagostics, forecasting and simulations. Also applying general linear constraints to the autoregressive parameters is supported.

Simple example

This is a basic example how to estimate a GMVAR model to an example data. The estimation process is computationally heavy and uses parallel computing.

# These examples use the data 'eurusd' which comes with the package, but in a scaled form.
data <- cbind(10*eurusd[,1], 100*eurusd[,2])
colnames(data) <- colnames(eurusd)

# GMVAR(2,2) model
fit22 <- fitGMVAR(data, p=2, M=2)
fit22

# GMVAR(2,2) model with autoregressive parameters restricted to be the same for all regimes
C_mat <- rbind(diag(2*2^2), diag(2*2^2))
fit22c <- fitGMVAR(data, p=2, M=2, constraints=C_mat)
fit22c

References

  • Kalliovirta L., Meitz M. and Saikkonen P. (2016) Gaussian mixture vector autoregression. Journal of Econometrics, 192, 485-498.
  • Kalliovirta L. and Saikkonen P. (2010) Reliable Residuals for Multivariate Nonlinear Time Series Models. Unpublished Revision of HECER Discussion Paper No. 247.

Copy Link

Version

Install

install.packages('gmvarkit')

Monthly Downloads

538

Version

1.0.3

License

GPL-3

Maintainer

Savi Virolainen

Last Published

September 22nd, 2018

Functions in gmvarkit (1.0.3)

form_boldA

Form the \(((dp)x(dp))\) "bold A" matrices related to the VAR processes
check_pMd

Check that p, M and d are correctly set
get_regime_means_int

Calculate and return regime means \(\mu_{m}\)
get_regime_means

Calculate and return regime means \(\mu_{m}\)
sort_components

Sort components in parameter vector by mixing weights into a decreasing order
smart_ind

Create somewhat random parameter vector of GMVAR model fairly close to a given parameter vector
eurusd

Euro area and U.S. long-term government bond yields and Euro-U.S. dollar exchange rate.
pick_phi0

Pick \(\phi_{m,0}\) or \(\mu_{m}\), m=1,..,M vectors from the given parameter vector
pick_regime

Pick regime parameters \(\upsilon_{m}\)\( = (\phi_{m,0},\)\(\phi_{m}\)\(,\sigma_{m})\) from the given parameter vector.
fitGMVAR

Two-phase maximum likelihood estimation of GMVAR model
format_valuef

Function factory for value formatting
in_paramspace_int

Determine whether the parameter vector lies in the parameter space or not
diagnostic_plot

Quantile residual diagnostic plot for GMVAR model
get_test_Omega

Compute covariance matrix Omega used in quantile residual tests
dlogmultinorm

Calculate logarithms of multiple multivariate normal densities with varying mean and constant covariance matrix
iterate_more

Maximum likelihood estimation of GMVAR model with preliminary estimates
is_stationary

Check the stationary condition of given GMVAR model
unvec

Reverse vectorization operator.
loglikelihood

Compute log-likelihood of GMVAR model using parameter vector
check_parameters

Check that the given parameter vector satisfies model assumptions
pick_Omegas

Pick covariance matrices
pick_allA

Pick coefficient all matrices
unvech

Reverse operator of the parsimonious vectorization operator vech().
random_coefmats2

Create somewhat random stationary VAR model \((dxd)\) coefficient matrices \(A\).
random_coefmats

Create random VAR-model \((dxd)\) coefficient matrices \(A\).
pick_Am

Pick coefficient matrices
pick_Ami

Pick coefficient matrix
standard_errors

Calculate standard errors for estimates of GMVAR model
get_IC

Calculate AIC, HQIC and BIC
add_data

Add data to object of class 'gmvar' defining a GMVAR model
get_boldA_eigens

Calculate absolute values of the eigenvalues of the "bold A" matrices containing the AR coefficients
swap_parametrization

Swap the parametrization of object of class 'gmvar' defining a GMVAR model
loglikelihood_int

Compute the log-likelihood of Gaussian Mixture Vector Autoregressive model
n_params

Calculate the number of parameters in GMVAR model parameter vector
print.gmvarpred

print method for class 'gmvarpred' objects
print_std_errors

Print standard errors of GMVAR model in the same form as the model estimates are printed
check_gmvar

Checks whether the given object has class attribute "gmvar"
print.gmvarsum

Summary print method from objects of class 'gmvarsum'
in_paramspace

Determine whether the parameter vector lies in the parameter space or not
simulateGMVAR

Simulate from GMVAR process
check_null_data

Checks whether the given object contains data or not
pick_all_phi0_A

Pick all \(\phi_{m,0}\) or \(\mu_{m}\) and \(A_{m}\) parameter values from the given parameter vector.
plot.gmvarpred

plot method for class 'gmvarpred' objects
predict.gmvar

Predict method for class 'gmvar' objects
pick_alphas

Pick mixing weight parameters \(\alpha_{m}, m=1,...,M\) from the given parameter vector.
plot.qrtest

Quantile residual tests
random_ind2

Create somewhat random parameter vector of GMVAR model that is always stationary
reform_data

Reform data
regime_distance

Calculate "distance" between two (scaled) regimes \(\upsilon_{m}\)\( = (\phi_{m,0},\)\(\phi_{m}\)\(,\sigma_{m})\)
quantile_residuals

Calculate multivariate quantile residuals of GMVAR model
smart_covmat

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

Calculate multivariate quantile residuals of GMVAR model
reform_constrained_pars

Reform constrained parameter vector into the "standard" form
vec

Vectorization operator.
random_covmat

Create somewhat random VAR model error term covariance matrix
vech

Parsimonious vectorization operator for symmetric matrices.
random_ind

Create somewhat random mean-parametrized parameter vector of GMVAR model, that may not be stationary!
GAfit

Genetic algorithm for preliminary estimation of GMVAR model
change_parametrization

Change parametrization of the parameter vector
GMVAR

Create object of class 'gmvar' defining a GMVAR model
check_constraints

Check the constraint matrix has the correct form
change_regime

Change regime parameters \(\upsilon_{m}\)\( = (\phi_{m,0},\)\(\phi_{m}\)\(,\sigma_{m})\) of the given parameter vector.
check_data

Check the data is in the correct form
aa_gmvarkit

gmvarkit: Estimate Gaussian Mixture Vector Autoregressive (GMVAR) model
all_pos_ints

Check whether all arguments are positive scalar whole numbers
calc_gradient

Calculate gradient or Hessian matrix