The R Project SVN R

Rev

Rev 85977 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/stats/man/box.test.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
74265 hornik 3
% Copyright 1995-2018 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
27497 ripley 6
\name{Box.test}
56186 murdoch 7
\alias{Box.test}
46873 ripley 8
\concept{portmanteau}
85977 hornik 9
\title{\I{Box}-\I{Pierce} and \I{Ljung}-\I{Box} Tests}
27497 ripley 10
\description{
85977 hornik 11
  Compute the \I{Box}--\I{Pierce} or \I{Ljung}--\I{Box} test statistic for examining the
46867 ripley 12
  null hypothesis of independence in a given time series.  These are
13
  sometimes known as \sQuote{portmanteau} tests.
27497 ripley 14
}
15
\usage{
45713 ripley 16
Box.test(x, lag = 1, type = c("Box-Pierce", "Ljung-Box"), fitdf = 0)
27497 ripley 17
}
18
\arguments{
19
  \item{x}{a numeric vector or univariate time series.}
20
  \item{lag}{the statistic will be based on \code{lag} autocorrelation
21
    coefficients.}
22
  \item{type}{test to be performed: partial matching is used.}
45713 ripley 23
  \item{fitdf}{number of degrees of freedom to be subtracted if \code{x}
24
    is a series of residuals.}
27497 ripley 25
}
45713 ripley 26
\details{
27
  These tests are sometimes applied to the residuals from an
28
  \code{ARMA(p, q)} fit, in which case the references suggest a better
29
  approximation to the null-hypothesis distribution is obtained by
30
  setting \code{fitdf = p+q}, provided of course that \code{lag > fitdf}.
31
}
27497 ripley 32
\note{
33
  Missing values are not handled.
34
}
35
\value{
36
  A list with class \code{"htest"} containing the following components:
37
  \item{statistic}{the value of the test statistic.}
38
  \item{parameter}{the degrees of freedom of the approximate chi-squared
74363 maechler 39
    distribution of the test statistic (taking \code{fitdf} into account).}
27497 ripley 40
  \item{p.value}{the p-value of the test.}
41
  \item{method}{a character string indicating which type of test was
42
    performed.}
43
  \item{data.name}{a character string giving the name of the data.}
44
}
45
\references{
88598 hornik 46
  \bibinfo{R:Harvey:1993}{note}{Pages 44--45}
47
  \bibshow{R:Harvey:1993,
48
    R:Box+Pierce:1970,
49
    R:Ljung+Box:1978}
27497 ripley 50
}
51
\author{A. Trapletti}
52
\examples{
53
x <- rnorm (100)
54
Box.test (x, lag = 1)
61160 ripley 55
Box.test (x, lag = 1, type = "Ljung")
27497 ripley 56
}
57
\keyword{ts}