knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ARDL

downloads CRAN status Lifecycle: stable codecov

Overview

ARDL creates complex autoregressive distributed lag (ARDL) models and constructs the underlying unrestricted and restricted error correction model (ECM) automatically, just by providing the order. It also performs the bounds-test for cointegration as described in Pesaran et al. (2001) and provides the multipliers and the cointegrating equation. The validity and the accuracy of this package have been verified by successfully replicating the results of Pesaran et al. (2001) in Natsiopoulos and Tzeremes (2022).

Why ARDL?

Installation

# You can install the released version of ARDL from CRAN:
install.packages("ARDL")

# Or the latest development version from GitHub:
install.packages("devtools")
devtools::install_github("Natsiopoulos/ARDL")

Usage

This is a basic example which shows how to use the main functions of the ARDL package.

Assume that we want to model the LRM (logarithm of real money, M2) as a function of LRY, IBO and IDE (see ?denmark). The problem is that applying an OLS regression on non-stationary data would result into a spurious regression. The estimated parameters would be consistent only if the series were cointegrated.

library(ARDL)
library(ARDL)
data(denmark)

First, we find the best ARDL specification. We search up to order 5.

models <- auto_ardl(LRM ~ LRY + IBO + IDE, data = denmark, max_order = 5)

# The top 20 models according to the AIC
models$top_orders

# The best model was found to be the ARDL(3,1,3,2)
ardl_3132 <- models$best_model
ardl_3132$order
summary(ardl_3132)

Then we can estimate the UECM (Unrestricted Error Correction Model) of the underlying ARDL(3,1,3,2).

uecm_3132 <- uecm(ardl_3132)
summary(uecm_3132)

And also the RECM (Restricted Error Correction Model) of the underlying ARDL(3,1,3,2), allowing the constant to join the long-run relationship (case 2), instead of the short-run (case 3).

recm_3132 <- recm(uecm_3132, case = 2)
summary(recm_3132)

Let's test if there is a long-run levels relationship (cointegration) using the bounds test from Pesaran et al. (2001).

# The bounds F-test (under the case 2) rejects the NULL hypothesis (let's say, assuming alpha = 0.01) with p-value = 0.004418.
bounds_f_test(ardl_3132, case = 2)

# The bounds t-test (under the case 3) rejects the NULL hypothesis (let's say, assuming alpha = 0.01) with p-value = 0.005538.
# We also provide the critical value bounds for alpha = 0.01.
tbounds <- bounds_t_test(uecm_3132, case = 3, alpha = 0.01)
tbounds

# Here is a more clear view of the main results.
tbounds$tab

Here we have the short-run and the long-run multipliers (with standard errors, t-statistics and p-values).

multipliers(ardl_3132, type = "sr")
multipliers(ardl_3132)

We can also estimate and visualize the delay multipliers along with their standard errors.

mult15 <- multipliers(ardl_3132, type = 15, se = TRUE)
plot_delay(mult15, interval = 0.95)

Now let's graphically check the estimated long-run relationship (cointegrating equation) against the dependent variable LRM.

ce <- coint_eq(ardl_3132, case = 2)
plot_lr(ardl_3132, coint_eq = ce, show.legend = TRUE)

Forecasting and using an ardl, uecm, or recm model in other functions are easy as they can be converted in regular lm models.

ardl_3132_lm <- to_lm(ardl_3132)

# Forecast using the in-sample data
insample_data <- ardl_3132$model
predicted_values <- predict(ardl_3132_lm, newdata = insample_data)

# Convert to ts class for the plot
predicted_values <- ts(predicted_values, start = c(1974,4), frequency=4)
plot(denmark$LRM, lwd=2) #The input dependent variable
lines(predicted_values, col="red", lwd=2) #The predicted values

Ease of use

Let's see what it takes to build the above ARDL(3,1,3,2) model.

Using the ARDL package (literally one line of code):

ardl_model <- ardl(LRM ~ LRY + IBO + IDE, data = denmark, order = c(3,1,3,2))

Without the ARDL package:
(Using the dynlm package, because striving with the lm function would require extra data transformation to behave like time-series)

library(dynlm)

dynlm_ardl_model <- dynlm(LRM ~ L(LRM, 1) + L(LRM, 2) + L(LRM, 3) + LRY + L(LRY, 1) +
                           IBO + L(IBO, 1) + L(IBO, 2) + L(IBO, 3) +
                           IDE + L(IDE, 1) + L(IDE, 2), data = denmark)
identical(ardl_model$coefficients, dynlm_ardl_model$coefficients)

An ARDL model has a relatively simple structure, although the difference in typing effort is noticeable.

Not to mention the complex transformation for an ECM. The extra typing is the least of your problems trying to do this. First you would need to figure out the exact structure of the model!

Using the ARDL package (literally one line of code):

uecm_model <- uecm(ardl_model)

Without the ARDL package:

dynlm_uecm_model <- dynlm(d(LRM) ~ L(LRM, 1) + L(LRY, 1) + L(IBO, 1) +
                                   L(IDE, 1) + d(L(LRM, 1)) + d(L(LRM, 2)) +
                                   d(LRY) + d(IBO) + d(L(IBO, 1)) + d(L(IBO, 2)) +
                                   d(IDE) + d(L(IDE, 1)), data = denmark)
identical(uecm_model$coefficients, dynlm_uecm_model$coefficients)

References

Natsiopoulos, Kleanthis, & Tzeremes, Nickolaos G. (2022). ARDL bounds test for cointegration: Replicating the Pesaran et al. (2001) results for the UK earnings equation using R. Journal of Applied Econometrics, 37(5), 1079-1090. https://doi.org/10.1002/jae.2919

Pesaran, M. H., Shin, Y., & Smith, R. J. (2001). Bounds testing approaches to the analysis of level relationships. Journal of Applied Econometrics, 16(3), 289-326



Natsiopoulos/ARDL documentation built on Sept. 2, 2023, 2:33 a.m.