acfIidTest: Carry out IID tests using sample autocorrelations

Description Usage Arguments Details Value Methods Author(s) References See Also Examples

View source: R/autocovariances.R

Description

Carry out tests for IID from sample autocorrelations.

Usage

1
2
3
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 TRUE return a CI for each lag up to max(nlags). Used only if CI's are requested.

...

currently ignored.

Details

Performs one of several tests for IID based on sample autocorrelations. A correction of the degerees 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.

signature(acf = "SampleAutocorrelations")

This is a convenience method in which argument n is taken from acf and thus does not need to be specified by the user.

Author(s)

Georgi N. Boshnakov

References

\insertRef

Li2004diagnosticsarima

See Also

whiteNoiseTest, acfGarchTest, acfMaTest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

sarima documentation built on Aug. 23, 2018, 9:03 a.m.