Generic functions for computation of autocorrelations, autocovariances and related quantities. The idea is to free the user from the need to look for specific functions that compute the desired property for their object.
1 2 3 4 5 6 7 8 9
an object for which the requested property makes sense.
the maximal lag to include in the result.
if TRUE include lag zero.
further arguments for methods.
autocorrelations is a generic function for computation of
autocorrelations. It deduces the appropriate type of autocorrelation
from the class of the object. For example, for models it computes
theoretical autocorrelations, while for time series it computes sample
The other functions described are similar for other second order
These functions return objects from suitable classes. A value for lag
zero is included (and is accessed by
r). Functions computing
autocorrelations and partial autocorrelations have argument
lag_0 — if it is set to
FALSE, the value for lag zero
is dropped from the result and the returned object is an ordinary
vector or array, as appropriate.
See the individual methods for the format of the result and further details.
an object from a class suitable for the requested property and
Georgi N. Boshnakov
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
v1 <- rnorm(100) autocorrelations(v1) v1.acf <- autocorrelations(v1, maxlag = 10) v1.acf[1:10] # drop lag zero value (and the class) autocorrelations(v1, maxlag = 10, lag_0 = FALSE) # same partialAutocorrelations(v1) partialAutocorrelations(v1, maxlag = 10) autocovariances(v1) autocovariances(v1, maxlag = 10) partialAutocovariances(v1, maxlag = 6) partialAutocovariances(v1) partialVariances(v1, maxlag = 6) pv1 <- partialVariances(v1) autocovariances(AirPassengers, maxlag = 6) autocorrelations(AirPassengers, maxlag = 6) partialAutocorrelations(AirPassengers, maxlag = 6) partialAutocovariances(AirPassengers, maxlag = 6) partialVariances(AirPassengers, maxlag = 6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.