| Title: | Panel Quantile Autoregressive Distributed Lag Model |
|---|---|
| Description: | Estimation of Panel Quantile Autoregressive Distributed Lag (PQARDL) models that combine panel ARDL methodology with quantile regression. Supports Pooled Mean Group (PMG), Mean Group (MG), and Dynamic Fixed Effects (DFE) estimators across multiple quantiles. Computes long-run cointegrating parameters, error correction term speed of adjustment, half-life of adjustment, and performs Wald tests for parameter equality across quantiles. Based on the econometric frameworks of Pesaran, Shin, and Smith (1999) <doi:10.1080/01621459.1999.10474156>, Cho, Kim, and Shin (2015) <doi:10.1016/j.jeconom.2015.05.003>, and Bildirici and Kayikci (2022). |
| Authors: | Muhammad Alkhalaf [aut, cre, cph] (ORCID: <https://orcid.org/0009-0002-2677-9246>) |
| Maintainer: | Muhammad Alkhalaf <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.5 |
| Built: | 2026-10-31 07:23:02 UTC |
| Source: | https://github.com/muhammedalkhalaf/xtpqardl |
Extract estimated coefficients from a Panel Quantile ARDL model.
## S3 method for class 'xtpqardl' coef(object, type = c("beta", "rho", "all"), ...)## S3 method for class 'xtpqardl' coef(object, type = c("beta", "rho", "all"), ...)
object |
An object of class |
type |
Character string specifying which coefficients to extract:
|
... |
Additional arguments (currently unused). |
A named numeric vector or list of coefficients.
data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) coef(fit) coef(fit, type = "rho")data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) coef(fit) coef(fit, type = "rho")
Computes the impulse response function (IRF) for Panel Quantile ARDL models, showing the response to a one-unit shock via the error correction mechanism.
compute_irf(object, horizon = 20)compute_irf(object, horizon = 20)
object |
An object of class |
horizon |
Integer specifying the number of periods for the IRF. Default is 20. |
The IRF for the error correction model is computed as:
which shows the decay of a unit shock over time through the error
correction mechanism. Values approach zero as grows when
; for the response
oscillates in sign (the half-life of xtpqardl is defined
for only). Outside the entries are
NA (printed as "div.").
A matrix with rows representing time periods and columns representing quantiles. Each entry shows the response at that period for that quantile.
data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) irf <- compute_irf(fit, horizon = 15) print(irf)data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) irf <- compute_irf(fit, horizon = 15) print(irf)
A simulated panel dataset for demonstrating Panel Quantile ARDL estimation. Contains 10 countries observed over 30 years with variables suitable for error correction modeling.
pqardl_samplepqardl_sample
A data frame with 300 rows and 9 variables:
Factor indicating the panel unit (10 countries)
Integer year variable (1990-2019)
Dependent variable in levels (e.g., GDP per capita)
First explanatory variable in levels (e.g., investment)
Second explanatory variable in levels (e.g., trade openness)
Lagged dependent variable (y at t-1)
First difference of y
First difference of x1
First difference of x2
The data are simulated from a panel error correction model with heterogeneous adjustment speeds across countries. The true long-run relationship is:
with error correction dynamics:
where varies by panel.
Simulated data for package demonstration.
data(pqardl_sample) head(pqardl_sample) # Check panel structure table(pqardl_sample$country)data(pqardl_sample) head(pqardl_sample) # Check panel structure table(pqardl_sample$country)
Print Method for irf.xtpqardl Objects
## S3 method for class 'irf.xtpqardl' print(x, ...)## S3 method for class 'irf.xtpqardl' print(x, ...)
x |
An object of class |
... |
Additional arguments (currently unused). |
Invisibly returns the input object.
Print Method for summary.xtpqardl Objects
## S3 method for class 'summary.xtpqardl' print(x, digits = 4, ...)## S3 method for class 'summary.xtpqardl' print(x, digits = 4, ...)
x |
An object of class |
digits |
Number of significant digits to display. Default is 4. |
... |
Additional arguments (currently unused). |
Invisibly returns the input object.
Print Method for wald_test.xtpqardl Objects
## S3 method for class 'wald_test.xtpqardl' print(x, ...)## S3 method for class 'wald_test.xtpqardl' print(x, ...)
x |
An object of class |
... |
Additional arguments (currently unused). |
Invisibly returns the input object.
Print Method for xtpqardl Objects
## S3 method for class 'xtpqardl' print(x, ...)## S3 method for class 'xtpqardl' print(x, ...)
x |
An object of class |
... |
Additional arguments (currently unused). |
Invisibly returns the input object.
Produces a detailed summary of Panel Quantile ARDL estimation results, including long-run coefficients, ECT speed of adjustment, half-life of adjustment, and short-run parameters by quantile.
## S3 method for class 'xtpqardl' summary(object, ...)## S3 method for class 'xtpqardl' summary(object, ...)
object |
An object of class |
... |
Additional arguments (currently unused). |
An object of class "summary.xtpqardl" containing formatted
tables of results.
data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) summary(fit)data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) summary(fit)
Extract the variance-covariance matrix of the estimated parameters.
## S3 method for class 'xtpqardl' vcov(object, type = c("beta", "rho"), ...)## S3 method for class 'xtpqardl' vcov(object, type = c("beta", "rho"), ...)
object |
An object of class |
type |
Character string specifying which covariance matrix to extract:
|
... |
Additional arguments (currently unused). |
A variance-covariance matrix.
Performs Wald tests for the null hypothesis that parameters are equal across different quantiles. Tests both long-run coefficients (beta) and ECT speed of adjustment (rho).
wald_test(object, joint = TRUE, all = FALSE) ## S3 method for class 'xtpqardl' wald_test(object, joint = TRUE, all = FALSE)wald_test(object, joint = TRUE, all = FALSE) ## S3 method for class 'xtpqardl' wald_test(object, joint = TRUE, all = FALSE)
object |
An object of class |
joint |
Logical. If |
all |
Logical, for |
The Wald test statistic is computed as:
where is the vector of coefficients, is the
variance-covariance matrix, and is a restriction matrix testing
equality of coefficients across quantiles (each quantile against the
first). Under the null hypothesis of equal coefficients, follows a
chi-squared distribution with degrees of freedom equal to the number of
restrictions. For MG the covariance is the Pesaran-Smith between-panel
covariance of the stacked panel estimates; for DFE it is the joint
covariance described in xtpqardl (one estimator for every
block, named in dfe_cov); for PMG the cross-quantile blocks are not
estimated and beta_test is not available.
Koenker-Bassett tests (DFE). kb_test applies the same
restriction scheme to the pooled quantile-regression coefficients
themselves (rho, theta, short run) with the joint covariance
of xtpqardl (Koenker and Bassett 1982, Theorem 3.1, with
the estimator chosen by dfe_cov). As in quantreg::anova the
statistic is reported as against an F distribution with
restrictions and denominator degrees of
freedom ( observations, quantiles); with
dfe_cov = "nid" and all = TRUE the joint and individual
rows reproduce anova(rq_1, ..., rq_m, se = "nid") on the
equivalent regression with factor(id). With the default
all = FALSE the joint test has where
is the number of economic slopes, so the hypothesis is the one stated in
the printout, and the contrasts (whose equality across
quantiles is of no economic interest and dilutes the test) are not
restricted.
Rank of the theta covariance. Cho, Kim and Shin (2015, Theorem
1(ii)) show that the asymptotic covariance of the long-run level
coefficients (theta) has rank one under their
normalisation. In their words, "has a rank equal to unity by Theorem 1(ii).
This implies that, if R has a rank greater than unity, the corresponding
Wald test has a degenerate asymptotic null distribution." (the page numbers
of that passage are not given here; the library copy has no page markers).
The individual rows of kb_test for each theta coefficient restrict
one coefficient across quantiles; the joint test with more than one
long-run regressor restricts several theta coefficients at once and relies
on the finite-sample full rank of their sandwich covariance.
The audit's Monte Carlo is consistent with this concern, but does not
isolate it. In the kb_joint_all column of its size grid (nid
estimator, all non-intercept coefficients restricted, iid N(0,1) errors,
N = 5, T = 20, R = 500) the rejection rate at nominal 5 percent was 16.2
percent with one long-run regressor and 23.2 percent with two. The two
designs also differ in the number of restrictions and the nid density
bias documented in the audit is a confounder, so the increase should be
read as consistent with, not as evidence for, the rank argument. The
long-run beta = -theta/rho is tested in beta_test, with the delta
method.
An object of class "wald_test.xtpqardl" containing:
Wald test result for long-run coefficients
Wald test result for ECT coefficients
Individual tests for each long-run variable (if joint = FALSE)
For model = "dfe": Koenker and Bassett (1982)
equality tests across quantiles on the pooled quantile-regression
coefficients, computed from the joint covariance dfe_coef_V
(estimator dfe_cov of the fit): joint (one row: F
statistic, numerator and denominator degrees of freedom, p-value) and
individual (one row per restricted coefficient), the names of
the restricted coefficients in restricted, the estimator in
se and whether the panel contrasts were included in
all. NULL for MG and PMG.
Quantiles tested
Cho JS, Kim TH, Shin Y (2015). "Quantile Cointegration in the Autoregressive Distributed-Lag Modeling Framework." Journal of Econometrics, 188(1), 281-300. doi:10.1016/j.jeconom.2015.05.003
Koenker R, Bassett G (1982). "Robust Tests for Heteroscedasticity Based on Regression Quantiles." Econometrica, 50(1), 43-61. doi:10.2307/1912528
data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) wald_test(fit)data(pqardl_sample) fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75) ) wald_test(fit)
Estimate Panel Quantile ARDL (PQARDL) models that combine panel ARDL methodology with quantile regression. Supports Pooled Mean Group (PMG), Mean Group (MG), and Dynamic Fixed Effects (DFE) estimators.
xtpqardl( formula, data, id, time, lr, tau = c(0.25, 0.5, 0.75), p = 1, q = 1, model = c("pmg", "mg", "dfe"), lagsel = NULL, pmax = 4, qmax = 4, constant = TRUE, pmg_weights = c("inverse_variance", "equal"), dfe_cov = c("iid", "nid", "ker"), allow_gaps = FALSE, hausman = c("strict", "ginv") )xtpqardl( formula, data, id, time, lr, tau = c(0.25, 0.5, 0.75), p = 1, q = 1, model = c("pmg", "mg", "dfe"), lagsel = NULL, pmax = 4, qmax = 4, constant = TRUE, pmg_weights = c("inverse_variance", "equal"), dfe_cov = c("iid", "nid", "ker"), allow_gaps = FALSE, hausman = c("strict", "ginv") )
formula |
A formula specifying the model. The response variable should
be in first differences (e.g., |
data |
A data frame containing panel data with variables specified in
the formula and |
id |
Character string specifying the panel (cross-section) identifier variable name. |
time |
Character string specifying the time variable name. It must be
numeric (for example the year as an integer). Lags are built by matching
|
lr |
Character vector of long-run level variable names. The first
element should be the lagged dependent variable level (for the error
correction term), and remaining elements are the long-run explanatory
variables. The variables enter the regression exactly as supplied (no
further lag is applied); supply lagged regressors, for example
|
tau |
Numeric vector of quantiles to estimate, each in (0,1).
Default is |
p |
Integer specifying the autoregressive lag order for the dependent variable. Default is 1. |
q |
Integer or integer vector specifying the distributed lag order(s) for explanatory variables. If a single integer, the same lag order is applied to all variables. Default is 1. |
model |
Character string specifying the estimation method:
|
lagsel |
Character string for automatic lag selection. If |
pmax |
Maximum p to consider in lag selection. Default is 4. |
qmax |
Maximum q to consider in lag selection. Default is 4. |
constant |
Logical. Include a constant term? Default is |
pmg_weights |
Character, for |
dfe_cov |
Character, for |
allow_gaps |
Logical. If |
hausman |
Character, for |
The PQARDL model extends the standard panel ARDL framework to allow for heterogeneous effects across the conditional distribution of the response variable. The error correction representation is:
where is the error correction term
built from the lr variables as supplied, is the
speed of adjustment (negative for convergence), and are
the long-run parameters, (the plug-in estimator
of Cho, Kim and Shin 2015, equation (3)).
Lags, gaps and missing values. Within each panel the lag
of a variable at time is the value at time ,
where the unit step is the smallest positive time difference in the data.
Duplicated (id, time) pairs are an error. A gap in a panel's
time index is an error unless allow_gaps = TRUE, in which case the
rows whose lagged period is missing are dropped. Rows with a missing value
in the response, a regressor or a lag are dropped panel by panel (the
leading rows lost to the user's own differencing and lagging are the
usual case); the number of dropped rows is returned in n_dropped.
Exactly collinear regressors stop with an error naming the columns.
model = "mg" averages the panel estimates (Pesaran and Smith
covariance ). With fewer
than three panels this covariance is unreliable (with N = 2 the audit's
Monte Carlo rejected 26 to 31 percent at nominal 5 percent) and the
function warns. model = "pmg" pools the long run by minimum
distance, weighting each panel by the inverse of its delta-method
covariance, then re-estimates every panel with the pooled long run
imposed; the speed of adjustment and the short run are the mean group of
that second stage. A Hausman test of long-run homogeneity (MG against PMG)
is computed quantile by quantile; the statistic is with the difference of the long-run estimates at
that quantile. The quadratic form is defined only when the difference
matrix is positive definite (Hausman 1978 gives non-negative definiteness
asymptotically); see hausman.
DFE covariance. model = "dfe" pools all panels in one
quantile regression per quantile with an intercept and
panel-intercept contrasts. All quantiles share the design , so the
joint covariance of the coefficient vectors ,
is estimated by one formula for every block, with the estimator named in
dfe_cov:
With "iid" (default) , where
is the sparsity estimated as in
summary.rq(se = "iid"); this is Theorem 3.1 of Koenker and Bassett
(1982), whose covariance has typical element
times
, under i.i.d. errors. With "nid"
and "ker", with the local density
estimates of summary.rq(se = "nid") (Hendricks-Koenker) or
summary.rq(se = "ker") (Powell kernel), including quantreg's
bandwidth rule (the bandwidth is halved while leaves
(0, 1)). The diagonal blocks equal summary.rq(se = dfe_cov)$cov.
The default is "iid" because in the audit of version 1.0.4 (panel
designs with N = 5 to 20, T = 20 to 40, i.i.d. errors) the
Hendricks-Koenker densities under-stated the variance of the speed of
adjustment by 23 to 55 percent in the presence of the panel intercepts
(Monte Carlo variance 0.00161 against a mean "nid" estimate 0.00072 at
N = 20, T = 40), so that the "nid" equality tests rejected 9 to 23 percent
at nominal 5 percent for N at most 10 and 47 to 76 percent at N = 20,
whereas the "iid" form rejected 4.3, 5.0 and 7.0 percent in the three
designs checked. For the default in the N = 10, T = 40, k = 1 design (iid
errors, nominal 5 percent) rho_test rejected between 6 and 9 percent
in two independent Monte Carlo batches (R = 200 and R = 500); a third batch
(R = 300) gave 5.7 percent. The test is therefore mildly over-sized in that
cell, against 1.2 percent with the 1.0.4 mixed matrix. "nid" and "ker" remain available for users
who need them; they are not recommended for the cross-quantile tests of
panels with many intercepts. The same joint matrix is the basis of the
Koenker-Bassett tests of wald_test; if the estimator fails
for a quantile (for example an extreme quantile in a small sample), the
affected blocks are NA and a warning names the quantile and the
reason. The standard errors of and come from the
diagonal blocks and the delta method.
Rank of the covariance of theta. Cho, Kim and Shin (2015, Theorem
1(ii)) show that under their normalisation the asymptotic covariance of
the long-run level coefficients (theta here, the
coefficients of lr[-1]) has rank one, and they restrict their Wald
tests on to restriction matrices of rank one, because a
higher rank gives a degenerate null distribution. The finite-sample
sandwich blocks for used here are of full rank, so a joint
test that restricts several coefficients at once (as the
Koenker-Bassett joint test of wald_test does when
) relies on finite-sample full rank of a matrix whose limit
is singular under their assumptions. See wald_test for the
size numbers. Tests on a single across quantiles (the
individual rows) are of rank in the quantile direction.
Lag selection. lagsel fits every (p, q) combination with
pmax, qmax (the same q for all
regressors) by least squares (lm.fit) panel by panel, sums the
residual sums of squares and the sample sizes over panels, and penalises
the total number of estimated coefficients (the sum over the panels of the
columns of their regressions): ,
. The criterion is least squares, not the
quantile check loss, and applies to the mean regression.
Short panels. Each panel regression has coefficients. When is close to that number the
covariance of the panel estimates cannot be estimated by
summary.rq(se = "iid") (its sparsity estimate needs the quantiles at
); the function then tries the other summary.rq
estimators and finally an iid formula with a kernel density estimate of
the sparsity, and warns once naming how many panel-quantile pairs switched
and to which estimator (details in panel_cov_status). If no
covariance is available for at least two panels, PMG stops with a message
listing the status of every panel; pmg_weights = "equal" or a
smaller model are the alternatives. Panels dropped from the PMG pooling
because their covariance is not invertible are named in a warning.
An object of class "xtpqardl" containing:
Matrix of mean group long-run coefficients across quantiles
Vector of mean group ECT speed of adjustment by quantile
Half-life of the mean
group speed of adjustment, by quantile
Matrix of mean group short-run coefficients
Matrix of mean group AR coefficients (if p > 1)
For model = "pmg", a data frame with one row per
quantile: the Hausman test of long-run homogeneity (MG against PMG)
at that quantile, with statistic, df, p.value,
the number of non-positive eigenvalues of the difference matrix and
the method used
Variance-covariance matrix for beta_mg. For MG and DFE the
full matrix is estimated (for DFE every block comes from the estimator
named in dfe_cov, see Details); for PMG the cross-quantile
blocks are NA
Variance-covariance matrix for rho_mg
For model = "dfe", the covariance estimator used
("iid", "nid" or "ker")
For model = "dfe", the matrix of pooled
quantile-regression coefficients (rows: coefficients, columns: tau)
For model = "dfe", the joint covariance matrix
of dfe_coef stacked by quantile, used by
wald_test for the Koenker-Bassett tests
For model = "dfe", the names of the economic
slopes (speed of adjustment, long-run levels, short run), as opposed
to the intercept and the panel-intercept contrasts
For model = "dfe", the list of rq fits (one
per quantile) of the pooled regression
A data frame with one row per panel and quantile (MG, PMG) or per quantile (DFE) reporting whether the covariance could be estimated, which estimator was used and why not
Matrix of per-panel long-run coefficients
Matrix of per-panel ECT coefficients
Matrix of per-panel half-life values
Vector of estimated quantiles
AR lag order used
Distributed lag order(s) used
Estimation method used
Total number of observations
Number of rows dropped because a regressor, the response or a lag was missing
Number of panels
Number of successfully estimated panels
Dependent variable name
Long-run variable names
The matched call
Pesaran MH, Shin Y, Smith RP (1999). "Pooled Mean Group Estimation of Dynamic Heterogeneous Panels." Journal of the American Statistical Association, 94(446), 621-634. doi:10.1080/01621459.1999.10474156
Cho JS, Kim TH, Shin Y (2015). "Quantile Cointegration in the Autoregressive Distributed-Lag Modeling Framework." Journal of Econometrics, 188(1), 281-300. doi:10.1016/j.jeconom.2015.05.003
Bildirici M, Kayikci F (2022). "Uncertainty, Renewable Energy, and CO2 Emissions in Top Renewable Energy Countries: A Panel Quantile Regression Approach." Energy, 247, 124303.
Hausman JA (1978). "Specification Tests in Econometrics." Econometrica, 46(6), 1251-1271. doi:10.2307/1913827
Koenker R, Bassett G (1978). "Regression Quantiles." Econometrica, 46(1), 33-50. doi:10.2307/1913643
Koenker R, Bassett G (1982). "Robust Tests for Heteroscedasticity Based on Regression Quantiles." Econometrica, 50(1), 43-61. doi:10.2307/1912528
# Load example panel data data(pqardl_sample) # Estimate PQARDL model at 25th, 50th, and 75th quantiles fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75), model = "pmg" ) # View results summary(fit) # Wald test for parameter equality across quantiles wald_test(fit)# Load example panel data data(pqardl_sample) # Estimate PQARDL model at 25th, 50th, and 75th quantiles fit <- xtpqardl( formula = d_y ~ d_x1 + d_x2, data = pqardl_sample, id = "country", time = "year", lr = c("L_y", "x1", "x2"), tau = c(0.25, 0.50, 0.75), model = "pmg" ) # View results summary(fit) # Wald test for parameter equality across quantiles wald_test(fit)