Package 'rbfmvar'

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

Help Index


rbfmvar: Residual-Based Fully Modified Vector Autoregression

Description

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.

Main Functions

rbfmvar

Estimate an RBFM-VAR model.

granger_test

Test for Granger non-causality.

irf

Compute impulse response functions.

fevd

Compute forecast error variance decomposition.

forecast.rbfmvar

Generate out-of-sample forecasts.

Key Features

  • 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

Methodology

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

Author(s)

Maintainer: Muhammad Alkhalaf [email protected] (ORCID) [copyright holder]

Other contributors:

  • Yoosoon Chang (Original RBFM-VAR methodology) [contributor]

References

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

See Also

Useful links:


Extract Coefficients from rbfmvar Object

Description

Extract Coefficients from rbfmvar Object

Usage

## S3 method for class 'rbfmvar'
coef(object, type = "plus", ...)

Arguments

object

An rbfmvar object.

type

Character. Type of coefficients to extract: "plus" (FM+ corrected, default) or "ols".

...

Additional arguments (currently ignored).

Value

Coefficient matrix.


Forecast Error Variance Decomposition

Description

Computes the forecast error variance decomposition (FEVD) from an RBFM-VAR model.

Usage

fevd(object, horizon = 20)

Arguments

object

An rbfmvar object from rbfmvar.

horizon

Integer. Number of periods for the FEVD. Default is 20.

Details

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

Value

An object of class "rbfmvar_fevd" containing:

fevd

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.

horizon

FEVD horizon.

varnames

Variable names.

References

Lutkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer-Verlag. doi:10.1007/978-3-540-27752-1

Examples

# 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

Description

Extract Fitted Values from rbfmvar Object

Usage

## S3 method for class 'rbfmvar'
fitted(object, ...)

Arguments

object

An rbfmvar object.

...

Additional arguments (currently ignored).

Value

Matrix of fitted values.


Out-of-Sample Forecasting

Description

The generic function forecast computes forecasts from time series models.

Usage

forecast(object, ...)

Arguments

object

A model object.

...

Additional arguments passed to methods.

Value

Depends on the method dispatched. See forecast.rbfmvar for the RBFM-VAR method, which returns an object of class "rbfmvar_forecast".


Out-of-Sample Forecasting for RBFM-VAR

Description

Generates out-of-sample forecasts from an RBFM-VAR model.

Usage

## S3 method for class 'rbfmvar'
forecast(object, h = 10, level = 95, ...)

Arguments

object

An rbfmvar object from rbfmvar.

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).

Details

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 Δ2yt+h\Delta^2 y_{t+h}, which need to be accumulated to obtain level forecasts.

Value

An object of class "rbfmvar_forecast" containing:

mean

Matrix of point forecasts (n x h).

se

Matrix of forecast standard errors (n x h).

lower

Matrix of lower prediction bounds (n x h).

upper

Matrix of upper prediction bounds (n x h).

horizon

Forecast horizon.

level

Confidence level.

varnames

Variable names.

Examples

# 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)

Granger Causality Matrix

Description

Computes pairwise Granger causality tests for all variable pairs.

Usage

granger_matrix(object)

Arguments

object

An rbfmvar object.

Value

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".

Examples

# 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)

Granger Non-Causality Test

Description

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.

Usage

granger_test(object, cause, effect)

Arguments

object

An rbfmvar object from rbfmvar.

cause

Character string. Name of the causing variable.

effect

Character string. Name of the affected variable.

Details

The Granger non-causality hypothesis is:

H0:x does not Granger-cause yH_0: x \text{ does not Granger-cause } y

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.

Value

A list of class "rbfmvar_granger" containing:

cause

Name of the causing variable.

effect

Name of the affected variable.

statistic

Modified Wald statistic.

df

Degrees of freedom.

p.value

P-value (conservative).

coefficients

Restricted coefficients being tested.

References

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

Examples

# 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)

Get Information Criteria Table

Description

Returns a table of information criteria values for different lag orders.

Usage

ic_table(object, max_lags = 8)

Arguments

object

An rbfmvar object.

max_lags

Maximum lag order to evaluate.

Value

A data frame with AIC, BIC, and HQ values.

Examples

# 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)

Impulse Response Functions

Description

Computes orthogonalized impulse response functions (IRF) from an RBFM-VAR model with optional bootstrap confidence intervals.

Usage

irf(object, horizon = 20, ortho = TRUE, boot = 0, ci = 90, seed = NULL)

Arguments

object

An rbfmvar object from rbfmvar.

horizon

Integer. Number of periods for the IRF. Default is 20.

ortho

Logical. If TRUE (default), compute orthogonalized IRFs using Cholesky decomposition of the error covariance matrix.

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 NULL.

Details

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).

Value

An object of class "rbfmvar_irf" containing:

irf

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.

irf_lower

Lower confidence bounds (if bootstrap was performed).

irf_upper

Upper confidence bounds (if bootstrap was performed).

horizon

IRF horizon.

varnames

Variable names.

ortho

Whether orthogonalized IRFs were computed.

boot

Number of bootstrap replications.

ci

Confidence level.

References

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

Examples

# 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)

Plot Method for rbfmvar_forecast Objects

Description

Plots forecasts from an RBFM-VAR model.

Usage

## S3 method for class 'rbfmvar_forecast'
plot(x, ...)

Arguments

x

An rbfmvar_forecast object.

...

Additional arguments passed to plot.

Value

No return value, called for side effects (produces a plot).


Print Method for rbfmvar Objects

Description

Prints a summary of an RBFM-VAR estimation.

Usage

## S3 method for class 'rbfmvar'
print(x, ...)

Arguments

x

An rbfmvar object.

...

Additional arguments (currently ignored).

Value

Invisibly returns the input object.


Print Method for rbfmvar_forecast Objects

Description

Prints a summary of an RBFM-VAR forecast.

Usage

## S3 method for class 'rbfmvar_forecast'
print(x, ...)

Arguments

x

An rbfmvar_forecast object.

...

Additional arguments (currently ignored).

Value

Invisibly returns x.


Print Method for summary.rbfmvar Objects

Description

Prints detailed coefficient tables and diagnostics for an RBFM-VAR model summary.

Usage

## S3 method for class 'summary.rbfmvar'
print(x, digits = 4, ...)

Arguments

x

A summary.rbfmvar object.

digits

Integer. Number of digits to print. Default is 4.

...

Additional arguments (currently ignored).

Value

Invisibly returns x.


Residual-Based Fully Modified VAR Estimation

Description

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.

Usage

rbfmvar(
  data,
  lags = 2,
  max_lags = 8,
  ic = "none",
  kernel = "bartlett",
  bandwidth = -1,
  level = 95
)

Arguments

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: "aic", "bic", "hq", or "none" (use lags directly). Default is "none".

kernel

Character string specifying the kernel for long-run variance estimation: "bartlett", "parzen", or "qs" (Quadratic Spectral). Default is "bartlett".

bandwidth

Numeric. Bandwidth for kernel estimation. If -1 (default), automatic bandwidth selection via Andrews (1991) is used.

level

Numeric. Confidence level for coefficient intervals (0-100). Default is 95.

Details

The RBFM-VAR model is specified as:

Δ2yt=j=1p2ΓjΔ2ytj+Π1Δyt1+Π2yt1+et\Delta^2 y_t = \sum_{j=1}^{p-2} \Gamma_j \Delta^2 y_{t-j} + \Pi_1 \Delta y_{t-1} + \Pi_2 y_{t-1} + e_t

where Δ\Delta is the difference operator and Δ2=ΔΔ\Delta^2 = \Delta \circ \Delta.

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

Value

An object of class "rbfmvar" containing:

F_ols

OLS coefficient matrix.

F_plus

FM+ corrected coefficient matrix.

SE_mat

Standard errors for FM+ coefficients.

Pi1_ols, Pi1_plus

Coefficient matrices for Δyt1\Delta y_{t-1}.

Pi2_ols, Pi2_plus

Coefficient matrices for yt1y_{t-1}.

Gamma_ols, Gamma_plus

Coefficient matrices for Δ2ytj\Delta^2 y_{t-j} (if p >= 3).

Sigma_e

Residual covariance matrix.

Omega_ev, Omega_vv

Long-run variance components.

Delta_vdw

One-sided long-run covariance for FM correction.

residuals

Matrix of residuals from FM+ estimation.

fitted

Matrix of fitted values.

nobs

Number of observations in original data.

T_eff

Effective sample size after differencing.

n_vars

Number of variables.

p_lags

VAR lag order used.

bandwidth

Bandwidth used for LRV estimation.

kernel

Kernel used for LRV estimation.

ic

Information criterion used (if any).

varnames

Variable names.

call

The matched call.

References

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

Examples

# 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

Description

Extract Residuals from rbfmvar Object

Usage

## S3 method for class 'rbfmvar'
residuals(object, ...)

Arguments

object

An rbfmvar object.

...

Additional arguments (currently ignored).

Value

Matrix of residuals.


Summary Method for rbfmvar Objects

Description

Provides detailed summary of RBFM-VAR estimation results.

Usage

## S3 method for class 'rbfmvar'
summary(object, ...)

Arguments

object

An rbfmvar object.

...

Additional arguments (currently ignored).

Value

A list of class "summary.rbfmvar" containing summary information.


Extract Variance-Covariance Matrix from rbfmvar Object

Description

Extract Variance-Covariance Matrix from rbfmvar Object

Usage

## S3 method for class 'rbfmvar'
vcov(object, ...)

Arguments

object

An rbfmvar object.

...

Additional arguments (currently ignored).

Value

Error covariance matrix.