% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/heterogeneity_tests.R
\name{swamy_test}
\alias{swamy_test}
\title{Swamy Slope Heterogeneity Test}
\usage{
swamy_test(object)
}
\arguments{
\item{object}{A \code{dcce_fit} object (typically with \code{model = "mg"},
\code{"cce"}, or \code{"dcce"}).}
}
\value{
An object of class \code{dcce_swamy} with elements \code{S_stat},
\code{delta_stat}, \code{df}, \code{p_swamy}, \code{p_delta}, \code{N}, \code{k}.
}
\description{
Tests the null hypothesis that all slope coefficients are identical
across cross-sectional units, against the alternative of heterogeneous
slopes. Implements the Swamy (1970) chi-square test and the Pesaran &
Yamagata (2008) standardised dispersion statistic.
}
\details{
The Swamy statistic is
\deqn{\tilde{S} = \sum_{i=1}^N (\hat\beta_i - \hat\beta^*)'
      \frac{X_i' M_\tau X_i}{\hat\sigma_i^2}
      (\hat\beta_i - \hat\beta^*),}
where \eqn{\hat\beta_i} is the unit-level OLS estimate,
\eqn{\hat\beta^*} is the weighted pooled estimate, and
\eqn{M_\tau = I - \tau(\tau'\tau)^{-1}\tau'} projects off the
intercept. Under \eqn{H_0} (homogeneous slopes), \eqn{\tilde{S}}
is asymptotically \eqn{\chi^2_{k(N-1)}}.

Pesaran & Yamagata (2008) propose a standardised version that is
asymptotically standard normal:
\deqn{\tilde\Delta = \sqrt{N} \, \frac{N^{-1}\tilde{S} - k}{\sqrt{2k}}.}
}
\references{
Swamy, P. A. V. B. (1970). Efficient inference in a random coefficient
regression model. \emph{Econometrica}, 38(2), 311-323.

Pesaran, M. H., & Yamagata, T. (2008). Testing slope homogeneity in
large panels. \emph{Journal of Econometrics}, 142(1), 50-93.
}
