acfIidTest {sarima} | R Documentation |
Carry out IID tests using sample autocorrelations
Description
Carry out tests for IID from sample autocorrelations.
Usage
acfIidTest(acf, n, npar = 0, nlags = npar + 1,
method = c("LiMcLeod", "LjungBox", "BoxPierce"),
interval = 0.95, expandCI = TRUE, ...)
Arguments
acf |
autocorrelations. |
n |
length of the corresponding time series. |
npar |
number of df to subtract. |
nlags |
number of autocorrelations to use for the portmonteau statistic, can be a vector to request several such statistics. |
method |
a character string, one of "LiMcLeod", "LjungBox" or "BoxPierce". |
interval |
a number or NULL. |
expandCI |
logical flag, if |
... |
additional arguments passed on to methods. In particular, some
methods have argument |
Details
Performs one of several tests for IID based on sample
autocorrelations. A correction of the degrees of freedom
for residuals from fitted models can be specified with argument
npar
. nlags
specifies the number of autocorrelations to
use in the test, it can be a vector to request several tests.
The results of the test are gathered in a matrix with one row for each
element of nlags
. The test statistic is in column "ChiSq",
degrees of freedom in "DF" and the p-value in "pvalue". The method is
in attribute "method".
If interval
is not NULL
confidence intervals for the
autocorrelations are computed, under the null hypothesis of
independence. The coverage probability (or probabilities) is
speciified by interval
.
If argument expandCI
is TRUE
, there is one row
for each lag, up to max(nlags)
. It is best to use this feature
with a single coverage probability.
If expandCI
to FALSE
the confidence intervals are put in
a matrix with one row for each coverage probability.
Value
a list with components "test" and (if requested) "ci", as described in Details
Methods
signature(acf = "ANY")
-
In this method
acf
contains the autocorrelations. signature(acf = "missing")
-
The autocorrelations are computed from argument
x
(the time series). signature(acf = "SampleAutocorrelations")
-
This is a convenience method in which argument
n
is taken fromacf
and thus does not need to be specified by the user.
Author(s)
Georgi N. Boshnakov
References
Li WK (2004). Diagnostic checks in time series. Chapman & Hall/CRC Press.
See Also
whiteNoiseTest
,
acfGarchTest
,
acfMaTest
;
plot-methods
for graphical representations of results
Examples
set.seed(1234)
ts1 <- rnorm(100)
a1 <- drop(acf(ts1)$acf)
acfIidTest(a1, n = 100, nlags = c(5, 10, 20))
acfIidTest(a1, n = 100, nlags = c(5, 10, 20), method = "LjungBox")
acfIidTest(a1, n = 100, nlags = c(5, 10, 20), interval = NULL)
acfIidTest(a1, n = 100, method = "LjungBox", interval = c(0.95, 0.90), expandCI = FALSE)
## acfIidTest() is called behind the scenes by methods for autocorrelation objects
ts1_acrf <- autocorrelations(ts1)
class(ts1_acrf) # "SampleAutocorrelations"
whiteNoiseTest(ts1_acrf, h0 = "iid", nlags = c(5,10,20), method = "LiMcLeod")
plot(ts1_acrf)
## use 10% level of significance in the plot:
plot(ts1_acrf, interval = 0.9)