MRCIGVAR provides data-generation, estimation, model-selection,
testing, and impulse-response tools for a family of global and
regime-switching multivariate time-series models. The package covers
both standard and cointegrated specifications, with particular emphasis
on multi-regime cointegrated global VAR systems.
The current refactor standardises the public API around lower snake_case function names while keeping backward-compatible legacy aliases where needed.
This repository builds on the original MRCIGVAR package created by Dr
Pu Chen (https://orcid.org/0000-0002-9659-8697). We gratefully
acknowledge Dr Chen as the founder and original owner of the package.
The original repository is available at
https://github.com/puchen8229/MRCIGVAR/.
The package currently includes workflows for:
VARCIVARMRVARMRCIVARGVARCIGVARMRGVARMRCIGVAR
Across those families, the package supports:
- synthetic data generation
- parameter estimation
- lag and threshold model selection
- impulse response functions and confidence bands
- regime-migration GIRFs
- constraint and diagnostic routines
Install the development version from GitHub with:
# install.packages("pak")
pak::pak("CurtinIDS/MRCIGVAR")For local development, clone the repository and either load or install the package locally:
devtools::load_all()
# or
devtools::install()The refactored codebase uses a consistent naming scheme:
*_data()for data generators and constructors*_estimate()for estimation routines*_select_*()for model-selection helpersirf_*()andgirf_*()for response analysis
Examples:
cigvar_data(),cigvar_estimate()mrcigvar_data(),mrcigvar_estimate()irf_cigvar_cb(),irf_mrcigvar_cb()
Legacy aliases are still available for backward compatibility, but new code should use the refactored lowercase function names.
Below is a minimal CIGVAR workflow using the refactored API.
library(MRCIGVAR)
n <- 4
p <- matrix(0, nrow = n, ncol = 3)
p[, 1] <- 2
p[, 2] <- 2
res_d <- cigvar_data(
m = 2,
n = n,
p = p,
T = 200,
type = "const",
DFYflag = 0
)
res_e <- cigvar_estimate(res_d)
res_e$Summary
sel <- cigvar_select_(res = res_e, L_V = c(3, 3))
sel[which.min(sel[, ncol(sel)]), ]
irf_cb <- irf_cigvar_cb(
res = res_e,
nstep = 12,
comb = NA,
irf = "gen1",
runs = 50,
conf = c(0.05, 0.95)
)
plot_irf(irf_cb, response = c(1, 2), impulse = c(1, 2), ncol = 2)For multi-regime workflows, the package provides parallel families such
as mrcigvar_data(), mrcigvar_estimate(), mrcigvar_select_(), and
irf_mrcigvar_cb().
For longer-form documentation, see the vignette set:
vignettes/mrcigvar-introduction.Rmdvignettes/core-model-workflows.Rmdvignettes/mrcigvar-workflow.Rmdvignettes/irf-and-girf.Rmdvignettes/refactor-migration-guide.Rmd
This repository is under active refactoring. The main goals of the refactor are:
- consistent public naming
- clearer roxygen documentation
- improved module boundaries in
R/ - compatibility wrappers for legacy function names
- Edit
README.Rmd, notREADME.md. NAMESPACEis generated by roxygen2.- Most files in
R/are split-module outputs and should be edited carefully. - The MkDocs site combines native pages in
docs/with generated pages rendered fromREADME.Rmdand selected files invignettes/. - Regenerate the docs pages with
Rscript scripts/render-docs.R. - Create the docs environment with
conda env create -f environment-docs.yml. - Activate it with
conda activate mrcigvar-docs. - Preview the docs locally with
mkdocs serve.
Contributor expectations and project conventions are documented in
CONTRIBUTING.md.
Bug reports and feature requests are best submitted through the GitHub issue tracker: