| Title: | Fourier ARDL Methods: Quantile, Nonlinear, Multi-Threshold & Unit Root Tests |
|---|---|
| Description: | Comprehensive implementation of advanced ARDL methodologies for cointegration analysis with structural breaks and asymmetric effects. Includes: (1) Fourier Quantile ARDL (FQARDL) - quantile regression with Fourier approximation for analyzing relationships across the conditional distribution; (2) Fourier Nonlinear ARDL (FNARDL) - asymmetric cointegration with partial sum decomposition following Shin, Yu & Greenwood-Nimmo (2014) <doi:10.1007/978-1-4899-8008-3_9>; (3) Multi-Threshold NARDL (MTNARDL) - multiple regime asymmetry analysis; (4) Fourier Unit Root Tests - ADF and KPSS tests with Fourier terms following Enders & Lee (2012) <doi:10.1016/j.econlet.2012.05.019> and Becker, Enders & Lee (2006) <doi:10.1111/j.1467-9892.2006.00490.x>. Features automatic lag and frequency selection, PSS bounds testing following Pesaran, Shin & Smith (2001) <doi:10.1002/jae.616>, bootstrap cointegration tests, Wald tests for asymmetry, dynamic multiplier computation, and publication-ready visualizations. Ported from Stata/Python by Dr. Merwan Roudane. |
| Authors: | Muhammad Alkhalaf [aut, cre, cph] (ORCID: <https://orcid.org/0009-0002-2677-9246>), Merwan Roudane [ctb] (Original Stata/Python implementation) |
| Maintainer: | Muhammad Alkhalaf <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.2 |
| Built: | 2026-06-05 06:49:36 UTC |
| Source: | https://github.com/cran/fqardl |
Comprehensive implementation of advanced ARDL methodologies for cointegration analysis with structural breaks and asymmetric effects.
Main functions:
fqardl: Fourier Quantile ARDL estimation
fnardl: Fourier Nonlinear ARDL with asymmetry
mtnardl: Multi-Threshold NARDL
fourier_adf_test: Fourier ADF unit root test
fourier_kpss_test: Fourier KPSS stationarity test
perform_bounds_test: PSS bounds testing
Muhammad Alkhalaf [email protected]
Contributor: Merwan Roudane (Original Stata/Python implementation)
Shin, Y., Yu, B., & Greenwood-Nimmo, M. (2014). Modelling Asymmetric Cointegration and Dynamic Multipliers in a Nonlinear ARDL Framework.
Enders, W., & Lee, J. (2012). The flexible Fourier form and Dickey-Fuller type unit root tests.
Pesaran, M. H., Shin, Y., & Smith, R. J. (2001). Bounds testing approaches to the analysis of level relationships.
Performs bootstrap-based bounds test for cointegration, following McNown et al. (2018) methodology.
bootstrap_bounds_test( y, X, fourier, p, q, tau, case, n_boot = 1000, verbose = FALSE )bootstrap_bounds_test( y, X, fourier, p, q, tau, case, n_boot = 1000, verbose = FALSE )
y |
Dependent variable |
X |
Independent variables |
fourier |
Fourier terms |
p |
Lag for y |
q |
Lag for X |
tau |
Quantiles |
case |
Model case |
n_boot |
Number of bootstrap replications |
verbose |
Logical. Print progress messages (default: FALSE) |
List with bootstrap p-values
Compute Asymmetric Multipliers
compute_asymmetric_multipliers(nardl_result, decompose, x_names)compute_asymmetric_multipliers(nardl_result, decompose, x_names)
nardl_result |
NARDL estimation results |
decompose |
Decomposed variable names |
x_names |
Original variable names |
List with long-run and short-run asymmetric multipliers
Computes various diagnostic statistics for the QARDL models.
compute_diagnostics(qardl_results)compute_diagnostics(qardl_results)
qardl_results |
List of QARDL estimation results |
List of diagnostics for each quantile
Calculates the long-run and short-run multipliers from QARDL estimates.
compute_multipliers(qardl_results, x_names, tau)compute_multipliers(qardl_results, x_names, tau)
qardl_results |
List of QARDL results for each quantile |
x_names |
Names of independent variables |
tau |
Vector of quantiles |
List with long-run and short-run multiplier matrices
Decomposes a variable into multiple regimes based on thresholds.
decompose_multi_threshold(x, thresholds)decompose_multi_threshold(x, thresholds)
x |
Numeric vector |
thresholds |
Threshold values (must include 0) |
List with regime components and names
Decomposes time series into cumulative positive and negative partial sums.
decompose_variables(data, variables)decompose_variables(data, variables)
data |
Data frame |
variables |
Variables to decompose |
List with positive and negative components
Estimates the Quantile ARDL model for a given quantile tau.
estimate_qardl(y, X, fourier, p, q, tau, case = 3)estimate_qardl(y, X, fourier, p, q, tau, case = 3)
y |
Dependent variable |
X |
Independent variables |
fourier |
Fourier terms |
p |
Lag for dependent variable |
q |
Lag for independent variables |
tau |
Quantile (0 < tau < 1) |
case |
Model case (1-5) |
List with estimation results
Tests H0: gamma1 = gamma2 = 0 (no Fourier terms needed)
fadf_f_test(y, model, k, p)fadf_f_test(y, model, k, p)
y |
Time series |
model |
Model specification |
k |
Fourier frequency |
p |
Number of lags |
List with F-statistic and p-value
Estimates Fourier Nonlinear ARDL models with asymmetric cointegration following Shin, Yu & Greenwood-Nimmo (2014).
fnardl(formula, data, decompose = NULL, max_p = 4, max_q = 4, max_k = 3, criterion = c("BIC", "AIC", "HQ"), case = 3, bootstrap = FALSE, n_boot = 1000, verbose = TRUE)fnardl(formula, data, decompose = NULL, max_p = 4, max_q = 4, max_k = 3, criterion = c("BIC", "AIC", "HQ"), case = 3, bootstrap = FALSE, n_boot = 1000, verbose = TRUE)
formula |
A formula specifying the model. |
data |
A data frame containing the variables. |
decompose |
Character vector of variables to decompose into positive/negative. Default NULL. |
max_p |
Maximum lag order for dependent variable. |
max_q |
Maximum lag order for independent variables. |
max_k |
Maximum Fourier frequency. |
criterion |
Information criterion for selection ("BIC", "AIC", or "HQ"). |
case |
PSS case (1-5), default is 3. |
bootstrap |
Logical. Whether to perform bootstrap bounds test. |
n_boot |
Number of bootstrap replications. |
verbose |
Logical. Print progress messages (default: TRUE). |
An object of class "fnardl" containing estimation results.
Muhammad Alkhalaf
Shin, Y., Yu, B., & Greenwood-Nimmo, M. (2014). Modelling Asymmetric Cointegration and Dynamic Multipliers in a Nonlinear ARDL Framework.
data(macro_data, package = "fqardl") result <- fnardl(gdp ~ oil_price, data = macro_data, decompose = "oil_price") summary(result)data(macro_data, package = "fqardl") result <- fnardl(gdp ~ oil_price, data = macro_data, decompose = "oil_price") summary(result)
Performs the Fourier Augmented Dickey-Fuller test for unit roots with smooth structural breaks.
fourier_adf(y, max_k = 3, max_lag = 8, criterion = c("BIC", "AIC"))fourier_adf(y, max_k = 3, max_lag = 8, criterion = c("BIC", "AIC"))
y |
Time series vector |
max_k |
Maximum Fourier frequency |
max_lag |
Maximum number of lags for ADF |
criterion |
Lag selection criterion |
A list with test results
Tests for unit roots allowing for smooth structural breaks using Fourier approximation. Implements Enders & Lee (2012) methodology.
fourier_adf_test( y, model = c("c", "ct"), max_freq = 3, max_lag = NULL, criterion = c("AIC", "BIC", "t-sig"), verbose = TRUE )fourier_adf_test( y, model = c("c", "ct"), max_freq = 3, max_lag = NULL, criterion = c("AIC", "BIC", "t-sig"), verbose = TRUE )
y |
Numeric vector of time series data |
model |
Model specification: "c" (constant), "ct" (constant + trend) |
max_freq |
Maximum Fourier frequency to test (default: 3) |
max_lag |
Maximum lag for ADF (default: NULL, auto-select) |
criterion |
Lag selection criterion ("AIC", "BIC", "t-sig") |
verbose |
Logical. Print progress messages (default: TRUE) |
Object of class "fadf" with test results
Enders, W., & Lee, J. (2012). The flexible Fourier form and Dickey-Fuller type unit root tests. Economics Letters, 117(1), 196-199.
set.seed(123) y <- cumsum(rnorm(200)) # Random walk result <- fourier_adf_test(y, model = "c", max_freq = 3) print(result)set.seed(123) y <- cumsum(rnorm(200)) # Random walk result <- fourier_adf_test(y, model = "c", max_freq = 3) print(result)
Tests for stationarity allowing for smooth structural breaks. Implements Becker, Enders & Lee (2006) methodology.
fourier_kpss_test(y, model = c("c", "ct"), max_freq = 3, verbose = TRUE)fourier_kpss_test(y, model = c("c", "ct"), max_freq = 3, verbose = TRUE)
y |
Numeric vector of time series data |
model |
Model specification: "c" (constant), "ct" (constant + trend) |
max_freq |
Maximum Fourier frequency (default: 3) |
verbose |
Logical. Print progress messages (default: TRUE) |
Object of class "fkpss" with test results
Becker, R., Enders, W., & Lee, J. (2006). A stationarity test in the presence of an unknown number of smooth breaks. Journal of Time Series Analysis, 27(3), 381-409.
Performs both Fourier ADF and Fourier KPSS tests for comprehensive unit root analysis.
fourier_unit_root_analysis(y, name = "Series", max_freq = 3, verbose = TRUE)fourier_unit_root_analysis(y, name = "Series", max_freq = 3, verbose = TRUE)
y |
Time series |
name |
Optional name for the series |
max_freq |
Maximum Fourier frequency |
verbose |
Logical. Print progress messages (default: TRUE) |
List with results from both tests and joint conclusion
Estimates the Fourier Quantile Autoregressive Distributed Lag (FQARDL) model. This methodology extends QARDL by incorporating Fourier trigonometric terms to capture smooth structural breaks without prior knowledge of break timing.
fqardl(formula, data, tau = c(0.25, 0.5, 0.75), max_p = 4, max_q = 4, max_k = 3, criterion = c("BIC", "AIC", "HQ"), case = 3, bootstrap = FALSE, n_boot = 1000, seed = NULL, verbose = TRUE)fqardl(formula, data, tau = c(0.25, 0.5, 0.75), max_p = 4, max_q = 4, max_k = 3, criterion = c("BIC", "AIC", "HQ"), case = 3, bootstrap = FALSE, n_boot = 1000, seed = NULL, verbose = TRUE)
formula |
A formula of the form y ~ x1 + x2 + ... |
data |
A data frame containing the time series variables. |
tau |
Numeric vector of quantiles to estimate. |
max_p |
Maximum lag for dependent variable. |
max_q |
Maximum lag for independent variables. |
max_k |
Maximum Fourier frequency to test. |
criterion |
Information criterion for lag selection ("BIC", "AIC", "HQ"). |
case |
Model case (1-5) following Pesaran et al. (2001). |
bootstrap |
Logical, perform bootstrap cointegration test. |
n_boot |
Number of bootstrap replications. |
seed |
Random seed for reproducibility. |
verbose |
Logical. Print progress messages (default: TRUE). |
An object of class "fqardl" containing:
coefficients |
Estimated coefficients for each quantile |
long_run |
Long-run multipliers |
short_run |
Short-run multipliers |
optimal_k |
Optimal Fourier frequency |
optimal_lags |
Optimal lag structure |
bounds_test |
Results of bounds test for cointegration |
diagnostics |
Model diagnostics |
Muhammad Alkhalaf
Pesaran, M. H., Shin, Y., & Smith, R. J. (2001). Bounds testing approaches to the analysis of level relationships.
data(macro_data) result <- fqardl(gdp ~ inflation + interest_rate, data = macro_data, tau = c(0.25, 0.5, 0.75)) summary(result)data(macro_data) result <- fqardl(gdp ~ inflation + interest_rate, data = macro_data, tau = c(0.25, 0.5, 0.75)) summary(result)
Generates a comprehensive report with all plots and tables.
generate_fnardl_report( obj, file = "fnardl_report.html", horizon = 20, verbose = TRUE )generate_fnardl_report( obj, file = "fnardl_report.html", horizon = 20, verbose = TRUE )
obj |
FNARDL object |
file |
Output file path (HTML or PDF) |
horizon |
Horizon for dynamic multipliers |
verbose |
Logical. Print completion message (default: TRUE) |
No return value, called for side effects (generates output or plots)
Creates sine and cosine terms for Fourier approximation of structural breaks. Based on Enders & Lee (2012) methodology.
generate_fourier_terms(n, k, cumulative = FALSE)generate_fourier_terms(n, k, cumulative = FALSE)
n |
Sample size (number of observations) |
k |
Fourier frequency (integer >= 1) |
cumulative |
If TRUE, includes all frequencies from 1 to k |
The Fourier terms are computed as:
where t is the time index and T is the sample size.
A matrix with sine and cosine columns
A simulated quarterly dataset containing GDP, inflation, and interest rate with a structural break.
macro_datamacro_data
A data frame with 100 rows and 5 variables: gdp, inflation, interest_rate, oil_price, exchange_rate.
Simulated data for package demonstration
data(macro_data) head(macro_data)data(macro_data) head(macro_data)
Estimates Multi-Threshold NARDL models with multiple regime asymmetry.
mtnardl(formula, data, decompose = NULL, thresholds = NULL, max_p = 4, max_q = 4, criterion = c("BIC", "AIC", "HQ"), case = 3, verbose = TRUE)mtnardl(formula, data, decompose = NULL, thresholds = NULL, max_p = 4, max_q = 4, criterion = c("BIC", "AIC", "HQ"), case = 3, verbose = TRUE)
formula |
A formula specifying the model. |
data |
A data frame containing the variables. |
decompose |
Variable to decompose (default NULL). |
thresholds |
List of threshold values (default NULL). |
max_p |
Maximum lag for dependent variable. |
max_q |
Maximum lag for independent variables. |
criterion |
Information criterion for selection. |
case |
PSS bounds test case. |
verbose |
Logical. Print progress messages (default: TRUE). |
An object of class "mtnardl".
Muhammad Alkhalaf
A simulated quarterly dataset where GDP responds asymmetrically to oil price changes.
oil_gdp_dataoil_gdp_data
A data frame with 200 rows and 3 variables: date, gdp, oil_price.
Simulated data for package demonstration
data(oil_gdp_data) head(oil_gdp_data)data(oil_gdp_data) head(oil_gdp_data)
Performs the PSS (2001) bounds test for cointegration in the ARDL framework. Tests the joint significance of the lagged level variables.
perform_bounds_test(qardl_results, n, k, case = 3)perform_bounds_test(qardl_results, n, k, case = 3)
qardl_results |
List of QARDL estimation results |
n |
Sample size |
k |
Number of regressors |
case |
Model case (1-5) |
The five cases are:
Case 1: No intercept, no trend
Case 2: Restricted intercept, no trend
Case 3: Unrestricted intercept, no trend (most common)
Case 4: Unrestricted intercept, restricted trend
Case 5: Unrestricted intercept, unrestricted trend
List with bounds test results
Plot Cumulative Multipliers
plot_cumulative_multipliers(obj, variable, horizon = 20)plot_cumulative_multipliers(obj, variable, horizon = 20)
obj |
FNARDL object |
variable |
Variable to plot |
horizon |
Number of periods |
No return value, called for side effects (generates output or plots)
Plot Dynamic Multipliers
plot_dynamic_multipliers(obj, variable, horizon = 20)plot_dynamic_multipliers(obj, variable, horizon = 20)
obj |
FNARDL object |
variable |
Variable to plot |
horizon |
Number of periods |
No return value, called for side effects (generates output or plots)
Plots the persistence profile showing the adjustment path to long-run equilibrium after a shock.
plot_persistence(obj, horizons = 20)plot_persistence(obj, horizons = 20)
obj |
FQARDL object |
horizons |
Number of periods for persistence profile |
ggplot object
============================================================================= Visualization Functions for FNARDL Dynamic Multiplier Plots and Asymmetry Analysis ============================================================================= Plot FNARDL Results
## S3 method for class 'fnardl' plot( x, type = c("asymmetry", "dynamic", "cumulative", "comparison"), variable = NULL, horizon = 20, ... )## S3 method for class 'fnardl' plot( x, type = c("asymmetry", "dynamic", "cumulative", "comparison"), variable = NULL, horizon = 20, ... )
x |
An object of class "fnardl" |
type |
Type of plot |
variable |
Variable to plot |
horizon |
Horizon for dynamic multipliers |
... |
Additional arguments |
No return value, called for side effects (generates output or plots)
Creates various diagnostic and result plots for FQARDL models.
## S3 method for class 'fqardl' plot( x, type = c("coefficients", "multipliers", "3d", "heatmap", "residuals"), variable = NULL, ... )## S3 method for class 'fqardl' plot( x, type = c("coefficients", "multipliers", "3d", "heatmap", "residuals"), variable = NULL, ... )
x |
An object of class "fqardl" |
type |
Type of plot: "coefficients", "multipliers", "3d", "heatmap", "residuals" |
variable |
Variable name for coefficient plots |
... |
Additional arguments passed to plotting functions |
A ggplot object or plotly object for 3D plots
Tests whether coefficients are constant across quantiles.
quantile_wald_test(qardl_results, coef_name)quantile_wald_test(qardl_results, coef_name)
qardl_results |
List of QARDL results |
coef_name |
Name of coefficient to test |
List with test results
Selects the optimal Fourier frequency k based on information criteria. Tests all frequencies from 1 to max_k and selects the one minimizing the chosen criterion.
select_fourier_frequency(y, X, max_k = 3, criterion = c("BIC", "AIC", "HQ"))select_fourier_frequency(y, X, max_k = 3, criterion = c("BIC", "AIC", "HQ"))
y |
Dependent variable vector |
X |
Matrix of independent variables |
max_k |
Maximum Fourier frequency to test |
criterion |
Information criterion ("AIC", "BIC", "HQ") |
A list containing:
optimal_k |
The optimal Fourier frequency |
ic_values |
Information criterion values for each k |
criterion |
The criterion used |
Selects optimal lag orders for ARDL model using grid search over all combinations of p and q.
select_optimal_lags( y, X, fourier, max_p, max_q, criterion = c("BIC", "AIC", "HQ") )select_optimal_lags( y, X, fourier, max_p, max_q, criterion = c("BIC", "AIC", "HQ") )
y |
Dependent variable |
X |
Matrix of independent variables |
fourier |
Fourier terms matrix |
max_p |
Maximum lag for dependent variable |
max_q |
Maximum lag for independent variables |
criterion |
Information criterion |
List with optimal lags
Test for Asymmetry (Wald Test)
test_asymmetry(nardl_result, decompose)test_asymmetry(nardl_result, decompose)
nardl_result |
NARDL estimation results |
decompose |
Decomposed variables |
List of Wald test results for each variable