Learn R Programming

timsac (version 1.3.8)

autcor: Autocorrelation

Description

Estimate autocovariances and autocorrelations.

Usage

autcor(y, lag = NULL, plot = TRUE, lag_axis = TRUE)

Value

acov

autocovariances.

acor

autocorrelations (normalized covariances).

mean

mean of y.

Arguments

y

a univariate time series.

lag

maximum lag. Default is \(2 \sqrt{n}\), where \(n\) is the length of the time series y.

plot

logical. If TRUE (default), autocorrelations are plotted.

lag_axis

logical. If TRUE (default) with plot = TRUE, \(x\)-axis is drawn.

References

H.Akaike and T.Nakagawa (1988) Statistical Analysis and Control of Dynamic Systems. Kluwer Academic publishers.

Examples

Run this code
# Example 1 for the normal distribution 
y <- rnorm(200)
autcor(y, lag_axis = FALSE)

# Example 2 for the ARIMA model
y <- arima.sim(list(order=c(2,0,0), ar=c(0.64,-0.8)), n = 200)
autcor(y, lag = 20)

Run the code above in your browser using DataLab