% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cointegration.R
\name{cointegration_test}
\alias{cointegration_test}
\title{Westerlund (2007) Panel Cointegration Tests}
\usage{
cointegration_test(
  data,
  unit_index,
  time_index,
  formula,
  lags = 1L,
  leads = 1L,
  test = c("ga", "gt", "pa", "pt"),
  n_bootstrap = 0L,
  seed = NULL,
  show_progress = FALSE
)
}
\arguments{
\item{data}{A panel data.frame.}

\item{unit_index}{Character scalar: unit identifier column.}

\item{time_index}{Character scalar: time identifier column.}

\item{formula}{Two-sided formula of the form \code{y ~ x1 + x2} in
\strong{levels} (not first differences).}

\item{lags}{Integer scalar: ADF lag order for \eqn{\Delta y} lags in the
ECM regression. Default \code{1L}.}

\item{leads}{Integer scalar: number of leads of \eqn{\Delta x}. Default
\code{1L}.}

\item{test}{Character vector: which statistics to compute. Subset of
\code{c("ga", "gt", "pa", "pt")}. Default: all four.}

\item{n_bootstrap}{Integer: number of bootstrap replications for
p-values. Default \code{0L} (asymptotic p-values).}

\item{seed}{Integer: random seed for the bootstrap.}

\item{show_progress}{Logical: print progress? Default \code{FALSE}.}
}
\value{
An object of class \code{dcce_cointegration} with elements
\code{statistics} (a tibble with columns \code{test}, \code{statistic},
\code{p_value}, \code{method}), \code{lags}, \code{leads}, \code{N},
\code{T_bar}, and \code{call}.
}
\description{
Implements the four error-correction-based panel cointegration tests of
Westerlund (2007): two group-mean statistics (Ga, Gt) and two panel
statistics (Pa, Pt). The null hypothesis is \strong{no cointegration} between
the dependent variable and the regressors.
}
\details{
For each unit \eqn{i}, an error-correction regression is fitted
\deqn{\Delta y_{it} = \delta_i d_t + \alpha_i y_{i,t-1}
                     + \lambda_i' x_{i,t-1}
                     + \sum_{j=1}^{p_i} \alpha_{ij} \Delta y_{i,t-j}
                     + \sum_{j=-q_i}^{p_i} \gamma_{ij}' \Delta x_{i,t-j}
                     + e_{it},}
and the t-statistic for \eqn{\alpha_i = 0} is used to construct the
four test statistics:
\itemize{
\item \strong{Gt}: group-mean of the \eqn{\hat\alpha_i / SE(\hat\alpha_i)}.
\item \strong{Ga}: group-mean of \eqn{T \hat\alpha_i / \hat\alpha_i(1)}
(unnormalised form).
\item \strong{Pt}: pooled t-statistic.
\item \strong{Pa}: pooled alpha-statistic.
}

A negative, large-magnitude statistic rejects the null of no
cointegration. Asymptotic p-values are obtained by linear interpolation
on the critical values in Westerlund (2007, Table 3). A bootstrap path
(\code{n_bootstrap > 0}) is also provided, resampling cross-sectional
units with replacement to account for cross-sectional dependence.
}
\examples{
data(pwt8)
result <- cointegration_test(
  data       = pwt8,
  unit_index = "country",
  time_index = "year",
  formula    = log_rgdpo ~ log_hc + log_ck,
  test       = c("ga", "gt"),
  lags       = 1L
)
print(result)
}
\references{
Westerlund, J. (2007). Testing for Error Correction in Panel Data.
\emph{Oxford Bulletin of Economics and Statistics}, 69(6), 709-748.
}
