In Time Series analysis, you can shift a
series by a given lag k. For
that given lag, the Box-Ljung Qstatistic is defined by:

Qk = n*(n+2)*Sum(ri2/(n-1))

for i = 1 to
k

When the number of observations is large, then the Q statistic has a Chi-squaredistribution with k-p-q
degrees of freedom, where p and
q are the number of autoregressive
and moving average parameters, respectively.