| Title: | Residual-Based Fully Modified Vector Autoregression |
|---|---|
| Description: | Implements the Residual-Based Fully Modified Vector Autoregression (RBFM-VAR) estimator of Chang (2000) <doi:10.1017/S0266466600166071>. The RBFM-VAR procedure extends Phillips (1995) FM-VAR to handle any unknown mixture of I(0), I(1), and I(2) components without prior knowledge of the number or location of unit roots. Provides automatic lag selection via information criteria (AIC, BIC, HQ), long-run variance estimation using Bartlett, Parzen, or Quadratic Spectral kernels with Andrews (1991) <doi:10.2307/2938229> automatic bandwidth selection, Granger non-causality testing with asymptotically chi-squared Wald statistics, impulse response functions (IRF) with bootstrap confidence intervals, forecast error variance decomposition (FEVD), and out-of-sample forecasting. |
| Authors: | Muhammad Alkhalaf [aut, cre, cph] (ORCID: <https://orcid.org/0009-0002-2677-9246>), Yoosoon Chang [ctb] (Original RBFM-VAR methodology) |
| Maintainer: | Muhammad Alkhalaf <[email protected]> |
| License: | GPL-3 |
| Version: | 2.0.2 |
| Built: | 2026-05-28 07:20:27 UTC |
| Source: | https://github.com/muhammedalkhalaf/rbfmvar |
Implements the Residual-Based Fully Modified Vector Autoregression (RBFM-VAR) estimator following Chang (2000). The RBFM-VAR procedure extends Phillips (1995) FM-VAR to handle any unknown mixture of I(0), I(1), and I(2) components without prior knowledge of the number or location of unit roots.
rbfmvarEstimate an RBFM-VAR model.
granger_testTest for Granger non-causality.
irfCompute impulse response functions.
fevdCompute forecast error variance decomposition.
forecast.rbfmvarGenerate out-of-sample forecasts.
Handles unknown mixtures of I(0), I(1), and I(2) variables
Automatic lag selection via AIC, BIC, or HQ
Multiple kernels for LRV estimation (Bartlett, Parzen, QS)
Andrews (1991) automatic bandwidth selection
Granger non-causality testing with asymptotic chi-squared inference
Impulse response functions with bootstrap confidence intervals
Forecast error variance decomposition
Out-of-sample forecasting
The RBFM-VAR model is based on Chang (2000), which develops a fully modified VAR estimation procedure that is robust to unknown integration orders. The key innovation is using second differences to eliminate I(2) trends while applying FM corrections to handle endogeneity from I(1) regressors.
The estimator achieves:
Zero mean mixed normal limiting distribution
Chi-square Wald statistics for hypothesis testing
Consistent estimation regardless of integration orders
Maintainer: Muhammad Alkhalaf [email protected] (ORCID) [copyright holder]
Other contributors:
Yoosoon Chang (Original RBFM-VAR methodology) [contributor]
Chang, Y. (2000). Vector Autoregressions with Unknown Mixtures of I(0), I(1), and I(2) Components. Econometric Theory, 16(6), 905-926. doi:10.1017/S0266466600166071
Phillips, P. C. B. (1995). Fully Modified Least Squares and Vector Autoregression. Econometrica, 63(5), 1023-1078. doi:10.2307/2171721
Andrews, D. W. K. (1991). Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59(3), 817-858. doi:10.2307/2938229
Useful links:
Report bugs at https://github.com/muhammedalkhalaf/rbfmvar/issues
Extract Coefficients from rbfmvar Object
## S3 method for class 'rbfmvar' coef(object, type = "plus", ...)## S3 method for class 'rbfmvar' coef(object, type = "plus", ...)
object |
An |
type |
Character. Type of coefficients to extract: |
... |
Additional arguments (currently ignored). |
Coefficient matrix.
Computes the forecast error variance decomposition (FEVD) from an RBFM-VAR model.
fevd(object, horizon = 20)fevd(object, horizon = 20)
object |
An |
horizon |
Integer. Number of periods for the FEVD. Default is 20. |
The FEVD shows the proportion of the forecast error variance of each variable that is attributable to shocks in each of the structural innovations. The decomposition is based on the Cholesky identification scheme, so the ordering of variables matters.
At each horizon h, the FEVD sums to 1 (100
An object of class "rbfmvar_fevd" containing:
Array of FEVD values (horizon x n x n). Element [h, i, j] is the proportion of variable i's forecast error variance at horizon h explained by shocks in variable j.
FEVD horizon.
Variable names.
Lutkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer-Verlag. doi:10.1007/978-3-540-27752-1
# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) fv <- fevd(fit, horizon = 20) plot(fv)# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) fv <- fevd(fit, horizon = 20) plot(fv)
Extract Fitted Values from rbfmvar Object
## S3 method for class 'rbfmvar' fitted(object, ...)## S3 method for class 'rbfmvar' fitted(object, ...)
object |
An |
... |
Additional arguments (currently ignored). |
Matrix of fitted values.
The generic function forecast computes forecasts from time series models.
forecast(object, ...)forecast(object, ...)
object |
A model object. |
... |
Additional arguments passed to methods. |
Depends on the method dispatched. See forecast.rbfmvar
for the RBFM-VAR method, which returns an object of class
"rbfmvar_forecast".
Generates out-of-sample forecasts from an RBFM-VAR model.
## S3 method for class 'rbfmvar' forecast(object, h = 10, level = 95, ...)## S3 method for class 'rbfmvar' forecast(object, h = 10, level = 95, ...)
object |
An |
h |
Integer. Forecast horizon (number of periods ahead). Default is 10. |
level |
Numeric. Confidence level for prediction intervals (0-100). Default is 95. |
... |
Additional arguments (currently ignored). |
Forecasts are generated iteratively using the estimated VAR coefficients. Standard errors are computed assuming normally distributed innovations.
Note that since the RBFM-VAR is estimated on second differences, forecasts
are for , which need to be accumulated to obtain
level forecasts.
An object of class "rbfmvar_forecast" containing:
Matrix of point forecasts (n x h).
Matrix of forecast standard errors (n x h).
Matrix of lower prediction bounds (n x h).
Matrix of upper prediction bounds (n x h).
Forecast horizon.
Confidence level.
Variable names.
# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) fc <- forecast(fit, h = 10) print(fc) plot(fc)# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) fc <- forecast(fit, h = 10) print(fc) plot(fc)
Computes pairwise Granger causality tests for all variable pairs.
granger_matrix(object)granger_matrix(object)
object |
An |
A matrix of p-values for all pairwise Granger causality tests. Row i, column j contains the p-value for "variable j causes variable i".
# Generate example data set.seed(123) n <- 100 mydata <- data.frame(x = cumsum(rnorm(n)), y = cumsum(rnorm(n))) fit <- rbfmvar(mydata, lags = 2) granger_matrix(fit)# Generate example data set.seed(123) n <- 100 mydata <- data.frame(x = cumsum(rnorm(n)), y = cumsum(rnorm(n))) fit <- rbfmvar(mydata, lags = 2) granger_matrix(fit)
Tests for Granger non-causality in the RBFM-VAR framework using a modified Wald statistic. The test is asymptotically chi-squared under the null hypothesis, regardless of the integration order of the variables.
granger_test(object, cause, effect)granger_test(object, cause, effect)
object |
An |
cause |
Character string. Name of the causing variable. |
effect |
Character string. Name of the affected variable. |
The Granger non-causality hypothesis is:
This is tested by examining whether the coefficients on lagged values of
cause in the equation for effect are jointly zero.
Under the FM+ framework of Chang (2000), the Wald statistic has an asymptotic chi-squared distribution that provides a conservative (valid) p-value even when variables have unknown integration orders.
A list of class "rbfmvar_granger" containing:
Name of the causing variable.
Name of the affected variable.
Modified Wald statistic.
Degrees of freedom.
P-value (conservative).
Restricted coefficients being tested.
Chang, Y. (2000). Vector Autoregressions with Unknown Mixtures of I(0), I(1), and I(2) Components. Econometric Theory, 16(6), 905-926. doi:10.1017/S0266466600166071
Toda, H. Y., & Yamamoto, T. (1995). Statistical Inference in Vector Autoregressions with Possibly Integrated Processes. Journal of Econometrics, 66(1-2), 225-250. doi:10.1016/0304-4076(94)01616-8
# Simulate VAR data set.seed(42) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("x", "y", "z") for (t in 3:n) { y[t, "x"] <- 0.5 * y[t-1, "x"] + e[t, 1] y[t, "y"] <- 0.3 * y[t-1, "y"] + 0.4 * y[t-1, "x"] + e[t, 2] y[t, "z"] <- 0.2 * y[t-1, "z"] + e[t, 3] } fit <- rbfmvar(y, lags = 2) # Test if x Granger-causes y (should be significant) test1 <- granger_test(fit, cause = "x", effect = "y") print(test1) # Test if z Granger-causes y (should not be significant) test2 <- granger_test(fit, cause = "z", effect = "y") print(test2)# Simulate VAR data set.seed(42) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("x", "y", "z") for (t in 3:n) { y[t, "x"] <- 0.5 * y[t-1, "x"] + e[t, 1] y[t, "y"] <- 0.3 * y[t-1, "y"] + 0.4 * y[t-1, "x"] + e[t, 2] y[t, "z"] <- 0.2 * y[t-1, "z"] + e[t, 3] } fit <- rbfmvar(y, lags = 2) # Test if x Granger-causes y (should be significant) test1 <- granger_test(fit, cause = "x", effect = "y") print(test1) # Test if z Granger-causes y (should not be significant) test2 <- granger_test(fit, cause = "z", effect = "y") print(test2)
Returns a table of information criteria values for different lag orders.
ic_table(object, max_lags = 8)ic_table(object, max_lags = 8)
object |
An |
max_lags |
Maximum lag order to evaluate. |
A data frame with AIC, BIC, and HQ values.
# Generate example data set.seed(123) n <- 100 mydata <- data.frame(x = cumsum(rnorm(n)), y = cumsum(rnorm(n))) fit <- rbfmvar(mydata, lags = 2) ic_table(fit, max_lags = 6)# Generate example data set.seed(123) n <- 100 mydata <- data.frame(x = cumsum(rnorm(n)), y = cumsum(rnorm(n))) fit <- rbfmvar(mydata, lags = 2) ic_table(fit, max_lags = 6)
Computes orthogonalized impulse response functions (IRF) from an RBFM-VAR model with optional bootstrap confidence intervals.
irf(object, horizon = 20, ortho = TRUE, boot = 0, ci = 90, seed = NULL)irf(object, horizon = 20, ortho = TRUE, boot = 0, ci = 90, seed = NULL)
object |
An |
horizon |
Integer. Number of periods for the IRF. Default is 20. |
ortho |
Logical. If |
boot |
Integer. Number of bootstrap replications for confidence intervals. If 0 (default), no bootstrap is performed. |
ci |
Numeric. Confidence level for bootstrap intervals (0-100). Default is 90. |
seed |
Integer. Random seed for reproducibility. Default is |
The IRF measures the response of each variable to a one-standard-deviation
shock in each of the structural innovations. When ortho = TRUE,
the structural shocks are identified using the Cholesky decomposition of
the residual covariance matrix (recursive identification).
Bootstrap confidence intervals are computed using the recursive-design bootstrap following Kilian (1998).
An object of class "rbfmvar_irf" containing:
Array of IRF values (horizon x n x n). Element [h, i, j] is the response of variable i to a shock in variable j at horizon h.
Lower confidence bounds (if bootstrap was performed).
Upper confidence bounds (if bootstrap was performed).
IRF horizon.
Variable names.
Whether orthogonalized IRFs were computed.
Number of bootstrap replications.
Confidence level.
Kilian, L. (1998). Small-Sample Confidence Intervals for Impulse Response Functions. Review of Economics and Statistics, 80(2), 218-230. doi:10.1162/003465398557465
Lutkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer-Verlag. doi:10.1007/978-3-540-27752-1
# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) ir <- irf(fit, horizon = 20) plot(ir) # With bootstrap confidence intervals ir_boot <- irf(fit, horizon = 20, boot = 500, ci = 95) plot(ir_boot)# Simulate VAR data set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) colnames(y) <- c("y1", "y2", "y3") for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } fit <- rbfmvar(y, lags = 2) ir <- irf(fit, horizon = 20) plot(ir) # With bootstrap confidence intervals ir_boot <- irf(fit, horizon = 20, boot = 500, ci = 95) plot(ir_boot)
Plots forecasts from an RBFM-VAR model.
## S3 method for class 'rbfmvar_forecast' plot(x, ...)## S3 method for class 'rbfmvar_forecast' plot(x, ...)
x |
An |
... |
Additional arguments passed to |
No return value, called for side effects (produces a plot).
Prints a summary of an RBFM-VAR estimation.
## S3 method for class 'rbfmvar' print(x, ...)## S3 method for class 'rbfmvar' print(x, ...)
x |
An |
... |
Additional arguments (currently ignored). |
Invisibly returns the input object.
Prints a summary of an RBFM-VAR forecast.
## S3 method for class 'rbfmvar_forecast' print(x, ...)## S3 method for class 'rbfmvar_forecast' print(x, ...)
x |
An |
... |
Additional arguments (currently ignored). |
Invisibly returns x.
Prints detailed coefficient tables and diagnostics for an RBFM-VAR model summary.
## S3 method for class 'summary.rbfmvar' print(x, digits = 4, ...)## S3 method for class 'summary.rbfmvar' print(x, digits = 4, ...)
x |
A |
digits |
Integer. Number of digits to print. Default is 4. |
... |
Additional arguments (currently ignored). |
Invisibly returns x.
Estimates a Residual-Based Fully Modified Vector Autoregression (RBFM-VAR) model following Chang (2000). The RBFM-VAR procedure extends Phillips (1995) FM-VAR to handle any unknown mixture of I(0), I(1), and I(2) components without prior knowledge of the number or location of unit roots.
rbfmvar( data, lags = 2, max_lags = 8, ic = "none", kernel = "bartlett", bandwidth = -1, level = 95 )rbfmvar( data, lags = 2, max_lags = 8, ic = "none", kernel = "bartlett", bandwidth = -1, level = 95 )
data |
A numeric matrix or data frame containing the time series variables. Must have at least 2 columns. |
lags |
Integer. The VAR lag order p. Must be at least 1. Default is 2. |
max_lags |
Integer. Maximum number of lags to consider for information criterion selection. Default is 8. |
ic |
Character string specifying the information criterion for lag
selection: |
kernel |
Character string specifying the kernel for long-run variance
estimation: |
bandwidth |
Numeric. Bandwidth for kernel estimation. If |
level |
Numeric. Confidence level for coefficient intervals (0-100). Default is 95. |
The RBFM-VAR model is specified as:
where is the difference operator and .
The FM+ correction eliminates the second-order asymptotic bias that arises from the correlation between the regression errors and the innovations in integrated regressors. The estimator achieves:
Zero mean mixed normal limiting distribution
Chi-square Wald statistics for hypothesis testing
Robustness to unknown integration orders
An object of class "rbfmvar" containing:
OLS coefficient matrix.
FM+ corrected coefficient matrix.
Standard errors for FM+ coefficients.
Coefficient matrices for .
Coefficient matrices for .
Coefficient matrices for (if p >= 3).
Residual covariance matrix.
Long-run variance components.
One-sided long-run covariance for FM correction.
Matrix of residuals from FM+ estimation.
Matrix of fitted values.
Number of observations in original data.
Effective sample size after differencing.
Number of variables.
VAR lag order used.
Bandwidth used for LRV estimation.
Kernel used for LRV estimation.
Information criterion used (if any).
Variable names.
The matched call.
Chang, Y. (2000). Vector Autoregressions with Unknown Mixtures of I(0), I(1), and I(2) Components. Econometric Theory, 16(6), 905-926. doi:10.1017/S0266466600166071
Phillips, P. C. B. (1995). Fully Modified Least Squares and Vector Autoregression. Econometrica, 63(5), 1023-1078. doi:10.2307/2171721
Andrews, D. W. K. (1991). Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59(3), 817-858. doi:10.2307/2938229
# Simulate a simple VAR(2) process set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } colnames(y) <- c("y1", "y2", "y3") # Estimate RBFM-VAR fit <- rbfmvar(y, lags = 2) summary(fit) # With automatic lag selection fit_aic <- rbfmvar(y, max_lags = 6, ic = "aic") summary(fit_aic)# Simulate a simple VAR(2) process set.seed(123) n <- 200 e <- matrix(rnorm(n * 3), n, 3) y <- matrix(0, n, 3) for (t in 3:n) { y[t, ] <- 0.3 * y[t-1, ] + 0.2 * y[t-2, ] + e[t, ] } colnames(y) <- c("y1", "y2", "y3") # Estimate RBFM-VAR fit <- rbfmvar(y, lags = 2) summary(fit) # With automatic lag selection fit_aic <- rbfmvar(y, max_lags = 6, ic = "aic") summary(fit_aic)
Extract Residuals from rbfmvar Object
## S3 method for class 'rbfmvar' residuals(object, ...)## S3 method for class 'rbfmvar' residuals(object, ...)
object |
An |
... |
Additional arguments (currently ignored). |
Matrix of residuals.
Provides detailed summary of RBFM-VAR estimation results.
## S3 method for class 'rbfmvar' summary(object, ...)## S3 method for class 'rbfmvar' summary(object, ...)
object |
An |
... |
Additional arguments (currently ignored). |
A list of class "summary.rbfmvar" containing summary information.
Extract Variance-Covariance Matrix from rbfmvar Object
## S3 method for class 'rbfmvar' vcov(object, ...)## S3 method for class 'rbfmvar' vcov(object, ...)
object |
An |
... |
Additional arguments (currently ignored). |
Error covariance matrix.