Box.test {stats}R Documentation

Box-Pierce and Ljung-Box Tests

Description

Compute the Box–Pierce or Ljung–Box test statistic for examining the null hypothesis of independence in a given time series. These are sometimes known as ‘portmanteau’ tests.

Usage

Box.test(x, lag = 1, type = c("Box-Pierce", "Ljung-Box"), fitdf = 0)

Arguments

x

a numeric vector or univariate time series.

lag

the statistic will be based on lag autocorrelation coefficients.

type

test to be performed: partial matching is used.

fitdf

number of degrees of freedom to be subtracted if x is a series of residuals.

Details

These tests are sometimes applied to the residuals from an ARMA(p, q) fit, in which case the references suggest a better approximation to the null-hypothesis distribution is obtained by setting fitdf = p+q, provided of course that lag > fitdf.

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic.

parameter

the degrees of freedom of the approximate chi-squared distribution of the test statistic (taking fitdf into account).

p.value

the p-value of the test.

method

a character string indicating which type of test was performed.

data.name

a character string giving the name of the data.

Note

Missing values are not handled.

Author(s)

A. Trapletti

References

Box GEP, Pierce DA (1970). “Distribution of Residual Autocorrelations in Autoregressive-Integrated Moving Average Time Series Models.” Journal of the American Statistical Association, 65(332), 1509–1526. doi:10.1080/01621459.1970.10481180.

Harvey AC (1993). Time Series Models, Second edition. Harvester Wheatsheaf. Pages 44–45.

Ljung GM, Box GEP (1978). “On a Measure of Lack of Fit in Time Series Models.” Biometrika, 65(2), 297–303. doi:10.1093/biomet/65.2.297.

Examples

x <- rnorm (100)
Box.test (x, lag = 1)
Box.test (x, lag = 1, type = "Ljung")

[Package stats version 4.6.0 Index]