0% found this document useful (0 votes)
6 views

JCTCSR-published

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JCTCSR-published

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/357802745

ARDL modeling using R software

Preprint · January 2023

CITATIONS READS

0 6,191

1 author:

Sami Mestiri
Faculté des Sciences Économiques et de Gestion de Mahdia
70 PUBLICATIONS 181 CITATIONS

SEE PROFILE

All content following this page was uploaded by Sami Mestiri on 21 February 2024.

The user has requested enhancement of the downloaded file.


ISSN: 2836-8495
Research Article Journal of Current Trends in Computer Science Research
ARDL Modeling Using R Software

Sami Mestiri*
University of Monastir, Tunisia. Rue Ibn Sina Hiboun, *
Corresponding Author
Mahdia Tunisia. Sami Mestiri, University of Monastir, Tunisia. Rue Ibn Sina Hiboun,
Mahdia Tunisia.

Submitted: 2023, Dec 12; Accepted: 2024, Jan 09; Published: 2024, Feb 13

Citation: Mestiri, S. (2024). ARDL Modeling Using R Software. J Curr Trends Comp Sci Res, 3(1), 01-05.

Abstract
AutoRegressive Distributed Lag models (ARDL) are dynamic models which involve variables lagged over time unlike static
models. The paper aims is present how to apply ARDL models using the R software and show how to use the package
dynamac and will make interesting recommendations for estimating models ARDL using R. Then in this paper, i present the
benefit of dynamac package for the statistical language R, demonstrating its main functionalities in a step by step guide.

JEL codes: C15, C88

Keywords: R Software, ARDL, Cointegration Test.

1. Introduction
Pesaran et al. (2001) introduced the bounds test for of types of autoregressive distributed lag models, including
cointegration based on the previous work of Pesaran and error-correction models.
Shin (1999) using the ARDL model as a platform for the
The research paper is organized as follows: We provide
test. Since then, the ARDL framework and the bounds test
AutoRegressive Distributed Lag models in Section 2. Section 3
are used constantly by practitioners who seem to adopt
presents Cointegration test. In section 4, we apply the model.
every new advancement of the initial framework. A recent
And finally, we conclude in section 5.
example combining various techniques, is Wu et al. (2022)
who applied bootstrap ARDL with a Fourier function. This
2. Auto Regressive Distributed Lag models
paper provides a smooth introduction to the dynamac
package in R (R Core Team, 2023) and its main features and
AutoRegressive Distributed Lag models (ARDL), are dynamic
capabilities. models which involve variables lagged over time unlike static
Regarding proprietary software like EViews, although they models. These models have the particularity of taking into account
are generally considered more user-friendly, they lack temporal dynamics (adjustment time, expectations, etc.) in the
flexibility compared to programming languages such as R explanation of a variable (time series), thus improving the
(Mestiri (2019 ) ). Additionally, these software platforms are forecasts and effectiveness of policies (decisions, actions, etc.),
often slow to adopt the latest advancements in research and unlike the simple (non-dynamic) model whose instantaneous
can be prohibitively expensive for many users. explanation (immediate effect or not spread over time) only
restores part of the variation in the variable to explain
On the other hand, open-source software do not provide any
guarantees regarding the quality of results, and it is the
In ARDL models we find, among the explanatory variables (𝑋𝑡 ),
responsibility of the user to verify the code. The problem
the lagged dependent variable (𝑌𝑡−𝑝 ) and the past values of the
lies in the fact that not everyone is an expert in the field,
making it challenging to technically validate the code’s independent variable (𝑋𝑡−𝑞 ). They have the following general
implementation. Many practitioners simply seek reliable form:
software they can trust.
𝑌𝑡 = 𝑓(𝑋𝑡 , 𝑌𝑡−𝑝 , 𝑋𝑡−𝑞 )
The dynamac package is a suite of programs in R designed
to assist users in modeling and visualizing the effects of
autoregressive distributed lag models, as well as testing for
cointegration. The core program is dynardl, a flexible
program designed to dynamically simulate and plot a variety

J Curr Trends Comp Sci Res, 2024 Volume 3 | Issue 1 | 1


𝑝 𝑞−1

In its general (explicit) form, an ARDL model is written as 𝛥𝑦𝑡 = 𝛾1 𝑦𝑡−1 + 𝛾2 𝑥𝑡−1 + ∑ 𝛼𝑖 𝛥𝑦𝑡−𝑖 + ∑ 𝛽𝑗 𝛥𝑥𝑡−𝑗 + 𝜋0 + 𝜋𝑡
𝑖=1 𝑗=0
follows:
+ 𝑒𝑡

𝑌𝑡 = 𝛼0 + 𝛼1 𝑌𝑡−1 + ⋯ + 𝛼𝑝 𝑌𝑡−𝑝 + 𝛽1 𝑋𝑡 + + ⋯ + 𝛽𝑞 𝑋𝑡−𝑞 + 𝜀𝑡


𝑝 𝑞
This specification presents the ARDL model which can be
𝑌𝑡 = 𝑎0 + ∑ 𝛼𝑖 𝑌𝑡−𝑖 + ∑ 𝛽𝑗 𝑋𝑡−𝑗 + 𝜀𝑡 written as follows:
𝑖=1 𝑗=0
𝑝 𝑞−1

With 𝜀 ∼ (0, 𝜎) error term. 𝛥𝑦𝑡 = 𝜋0 + 𝜋𝑡 + ∑ 𝛼𝑖 𝛥𝑦𝑡−𝑖 + ∑ 𝛽𝑗 𝛥𝑥𝑡−𝑗 + 𝜆𝜀𝑡−1 + 𝑒𝑡


𝛽0 translates the short-term effect of 𝑋𝑡 on 𝑌𝑡 . 𝑖=1 𝑗=0
If we consider the following long-term or equilibrium
relationship 𝑌𝑡 = 𝑘 + 𝜙𝑋𝑡 + 𝑢 , We can calculate the long-run Where ù 𝜆 is the error correction term, adjustment coefficient or
effect of 𝑋𝑡 on 𝑌𝑡 as follows: restoring force .
we conclude à the existence of a cointegration relation between

∑𝛽𝑗
𝜙= 𝑥𝑡 and 𝑦𝑡 if and only if 0 ≺ |𝜆 | ≺ 1 and rejection 𝐻0 : 𝜆 = 0.
1 − ∑𝛼𝑖

As with any dynamic model, we will use the information criteria


There are two à steps to follow to apply the Pesaran cointegration
(AIC, SIC and HQ) to determine the optimal shift (p* or q*); an
test, namely: the determination of the eoptimal calibration above
optimal shift is one whose estimated model offers the minimum
all (AIC, SIC) and uses the Fisher test to verify the hypotheses:
value of one of the stated criteria. These criteria are: that of
𝐻0 : 𝛼1 = 𝛼2 = 0 existence of a cointegration relation
Akaike (AIC), that of Schwarz (SIC) and that of Hannan and
Quinn (HQ). Their Akaike values (AIC) are calculated as 𝐻1 : 𝛼1 ≠ 𝛼2 ≠ 0 absence of a cointegration relation.
follows:
The test procedure is such that we must compare the Fisher
𝑆𝐶𝑅ℎ 2ℎ values obtained with the critical values (bounds) simulated for
𝐴𝐼𝐶(ℎ) = 𝐿𝑛 ( )+ several cases and different thresholds by Pesaran. We will note
𝑛 𝑛
from the critical values that the upper bound takes up the values
with 𝑆𝐶𝑅ℎ = Sums of Squares of Residuals for the model with h for which the variables are integrated of order 1 𝐼(1)and the
delays lower bound concern the variables 𝐼(0).
n = Number of observations
Ln = Natural logarithm Thus: 𝐹𝑐 ≻ 𝐵sup Cointegration exists
𝐹𝑐 ≺ 𝐵inf Cointegration does not exist
These ARDL models generally suffer from error autocorrelation 𝐵inf ≺ 𝐹𝑐 ≺ 𝐵sup There is no conclusion
problems, with the presence of the lagged endogenous variable as
explanatory and from multi-collinearity, which complicates the
estimation of the parameters by Ordinary Least Squares. Here, he 4- Application
has to resort to techniques robust estimation (SUR method, etc.)
to overcome these problems. Also, we note that the variables We illustrate the process autoregressive distributed lag modeling,
considered in these models must be stationary to avoid spurious testing for cointegration with pssbounds, and interpretation of X
regressions. The ARDL model makes it possible to estimate through stochastic simulations using data originally from Wright
short-term dynamics and long-term effects for cointegrated series (2017) on public concern about inequality in the United States.
or even integrated at different orders. For our example, assume that public concern about inequality in
the US, (Concern), is a function of the share of income going to
3- Cointegration test the top ten percent, Income. We also hypothesize that
Unemployment, affects concern over the short-run (i.e., is not
When we have several integrated variables of different orders cointegrating).
(I(0), I(1)), we can use the cointegration test of Pesaran et al.
(2001) called “bounds test to cointegration”, initially developed Before estimating any model using dynamac, users should first
by Pesaran and Shin (1999) . check for stationarity. A variety of unit root tests can be
performed using the urca package (Pfaff et al., 2016) . These
The model which serves as a basis for the test of cointegration by suggest that all three series are integrated of order I(1), as they
staggered lags (test of Pesaran et al. (2001)) is the following appear integrated in levels but stationary in first-differences(𝛥),
cointegrated ARDL specification (it takes the form of an error shown in Table 1
correction model or a VECM), when we study the dynamics
between two series 𝑥𝑡 and 𝑦𝑡 .

J Curr Trends Comp Sci Res, 2024 Volume 3 | Issue 1 | 2


Table1 : Unit root tests
Augmented Phillips
DF -Perron KPSS
𝐶𝑜𝑛𝑐𝑒𝑟𝑛 0.688 −3.437∗ 0.642∗

𝛥𝐶𝑜𝑛𝑐𝑒𝑟𝑛 −3.507∗ −7.675∗ 0.814∗

𝑈𝑛𝑒𝑚𝑝𝑙𝑜𝑦𝑚𝑒𝑛𝑡 -0.612 -2.762 0.224

𝛥𝑈𝑛𝑒𝑚𝑝𝑙𝑜𝑦𝑚𝑒𝑛𝑡 −3.62∗ −4.879∗ 0.064

𝐼𝑛𝑐𝑜𝑚𝑒 2.992 0.442 2.482∗

𝛥𝐼𝑛𝑐𝑜𝑚𝑒 −3.170∗ −6.244∗ 0.218

Given that all series appear to be I(1), we proceed with estimating


a model in dynardl in error correction form, and then testing for Table 2 : The regression results
cointegration between concern about inequality and the share of
income of the top 10 percent. In general, we suggest using this
Estimate Std. Error t value Pr(>|𝑡|)
strategy with alternative tests for cointegration. Our error-
(Intercept) 0.122043 0.027967 4.364 0.0000∗∗∗
correction model appears as:

𝛥𝐶𝑜𝑛𝑐𝑒𝑟𝑛𝑡 = 𝛼0 + 𝛼1 . 𝐶𝑜𝑛𝑐𝑒𝑟𝑛𝑡−1 + 𝛽0 𝛥𝐼𝑛𝑐𝑜𝑚𝑒𝑡−1 𝑐𝑜𝑛𝑐𝑒𝑟𝑛𝑡−1 0.167655 0.048701 -3.443 0.0013∗∗


+ 𝛽1 𝛥𝐼𝑛𝑐𝑜𝑚𝑒𝑡 + 𝛽2 𝛥𝑈𝑛𝑒𝑚𝑝𝑙𝑜𝑦𝑚𝑒𝑛𝑡𝑡
+ 𝜖𝑡 𝛥𝐼𝑛𝑐𝑜𝑚𝑒𝑡 0.800585 0.296620 2.699 0.0099∗∗

where we assume 𝜖𝑡 ∼ 𝑁(0, 𝜎 2 ). 𝛥𝑈𝑛𝑒𝑚𝑝𝑙𝑜𝑦𝑚𝑒𝑛𝑡


0.001118
𝑡 0.001699 0.658 0.5138

dynardl is simply an engine for regression, but one that allows 𝐼𝑛𝑐𝑜𝑚𝑒𝑡−1 -0.068028 0.031834 -2.137 0.0383∗
users to focus on theoretical specification rather than technical
coding. All variables in the model are entered into the formula.
In this sense, dynardl can be used in any ARDL context, not just
ones in which the user is also expecting cointegration testing or As shown from the Table 2, dynardl has included a constant, the
dynamic simulations.We estimate our example model shown in lagged dependent variable, concern, the first difference of the
Equation 1 using the following R script: two regressors (Income and Unemployment), as well as the lag of
Income.
res1 <- dynardl(concern ∼ Income + Unemployment, data =
ineq, While changes in Income affect changes in Concern in the short-
lags = list("concern" = 1, "Income " = 1), run, changes in Unemployment do not have a statistically
diffs = c("Income ", "Unemployment"), significant effect in the short-run. The lag of Income is negative
ec = TRUE, simulate = FALSE ) and statistically significant
summary(res1) .
Moreover, the parameter on the lagged dependent variable is
negative, between 0 and -1, and statistically significant, giving us
cursory evidence of a cointegrating process taking place; we use
a statistical test for this below.

An essential component of ARDL modeling is ensuring that the


residuals from any ARDL estimation are white noise. One
symptom of residual autocorrelation in the presence of a lagged
dependent variable is that OLS will result in biased and
inconsistent estimates. Autocorrelation is especially pernicious
when using the ARDL-bounds cointegration test, since the test
relies on the assumption of, serially uncorrelated errors for the
validity of the bounds tests
.

J Curr Trends Comp Sci Res, 2024 Volume 3 | Issue 1 | 3


To assist users in model selection and residual testing, we use
dynardl.auto.correlated. This function takes the residuals from Table 3 : The bounds tests results
an ARDL model estimated by dynardl and conducts two tests for
autocorrelation the Shaprio-Wilk test for normality and the I(0) I(1)
Breusch-Godfrey test for higher-order serial correlation as well as 10% critical value 4.19 4.94
calculates the fit statistics for the Akaike information criterion
(AIC), Bayesian information criterion (BIC), and log-likelihood.
5% critical value 5.22 6.07

1% critical value 7.56 8.69

F-statistic 12.204

For the validity of the bounds tests, we use the command


pssbounds. As shown from the Table 3, since the value of the F-
statistic exceeds the critical value at the upper I(1) bound of the
test at the 1% level, we may conclude that Income and Concern
about inequality are in a cointegrating relationship. As an
auxiliary test, pssbounds displays a one-sided test on the t-
statistic on the lagged dependent variable
.
Since the t-statistic of -3.684 falls below the 5% critical value
I(1) threshold, this lends further support for cointegration. Taken
together, these findings indicate that there is a cointegrating
relationship between concern about inequality and the income,
and that Equation 1 is appropriately specified.

5-Conclusions

This paper serves as a comprehensive step-by-step guide,


showcasing the core functionalities of the dynamac package, a
versatile tool developed in the R language (Mestiri (2020 ) ). In
addition to explaining the package capabilities, we provide
simple examples that end-users can readily adopt and tailor to
suit their unique research requirements.

Throughout the illustrative example, we highlight the user-


friendly dynamac package, which enables effortless estimation of
even the most intricate models. The package flexibility becomes
evident as it easily accommodates the calculation of complex
designs, making it a valuable asset for researchers seeking
reliable and robust results.

J Curr Trends Comp Sci Res, 2024 Volume 3 | Issue 1 | 4


References

1. Jordan, S., Philips, A. Q. (2022). Dynamac: Dynamic


simulation and testing for single-equation ARDL models. The
R Journal
https://doi.org/10.32614/RJ-2018-076

2. Mestiri, S. (2023). Using R software to applied


econometrics, Working Papers hal-04343931
.https://hal.science/hal-04343931

3. Mestiri, S. (2019) How to use the R software. MPRA


Paper 119428, University Library of Munich, Germany.
https://mpra.ub.uni-muenchen.de/119428

4. Mestiri, S. (2021). Bayesian Structural Var Approch To


Tunisian Monetary Policy Farmework. Journal of Smart
Economic Growth, 6(2), 67-77.
https://www.jseg.ro/index.php/jseg/article/view/146

5. Pfaff,B. Zivot, E. and M. Stigler. (2016) Urca: Unit Root


and Cointegration Tests for Time Series Data.

6. 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.v
https://www.jstor.org/stable/2678547

7. Pesaran, M. H., Shin, Y. (1999). An autoregressive


distributed-lag modelling approach to cointegration analysis,
Cambridge University Press, vol. 11, pp. 371-413.
Econometric Society Monographs,

8. Wright. (2017) The political implications of American


concerns about economic inequality. Political Behavior, vol
40 pages 321–343
.https://doi.org/10.1007/s11109-017-9399-3

9. Cheng-Feng Wu , Shian-Chang Huang , Chei-Chang


Chiou, Tsangyao Chang and Yung-Chih Chen, 2022. The
Relationship Between Economic Growth and Electricity
Consumption: Bootstrap ARDL Test with a Fourier Function
and Machine Learning Approach, Computational Economics,
vol. 60(4), pages 1197-1220.
DOI: 10.1007/s10614-021-10097-7

J Curr Trends Comp Sci Res, 2024 Volume 3 | Issue 1 | 5

View publication stats

You might also like