Carry out tests for IID from sample autocorrelations.
1 2 3
length of the corresponding time series.
number of df to subtract.
number of autocorrelations to use for the portmonteau statistic, can be a vector to request several such statistics.
a character string, one of "LiMcLeod", "LjungBox" or "BoxPierce".
a number or NULL.
logical flag, if
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
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
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".
interval is not
NULL confidence intervals for the
autocorrelations are computed, under the null hypothesis of
independence. The coverage probability (or probabilities) 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.
FALSE the confidence intervals are put in
a matrix with one row for each coverage probability.
a list with components "test" and (if requested) "ci", as described in Details
signature(acf = "ANY")
In this method
acf contains the autocorrelations.
signature(acf = "missing")
The autocorrelations are computed from argument
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.
Georgi N. Boshnakov
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.