auto_corr: Calculate Autocorrelation

View source: R/auto_corr.R

auto_corrR Documentation

Calculate Autocorrelation

Description

This function calculates the autocorrelation for a given time series data. It estimates the autocorrelation coefficients, standard errors, test statistics, and p-values for each lag up to a specified maximum lag.

Usage

auto_corr(x, lag, alpha = 0.05)

Arguments

x

A numeric vector representing the time series data.

lag

The maximum lag for which autocorrelation is to be calculated.

alpha

The significance level for hypothesis tests. Default is 0.05.

Value

A data frame containing the lag, autocorrelation coefficients (ar), standard errors (se), test statistics (statistic), p-values (p_z and p_t), overall standard errors (se_all), Ljung-Box test statistic (q_lb), and p-value for the Ljung-Box test (p_all).

References

Bartlett, M. S. (1946). On the theoretical specification and sampling properties of autocorrelated time-series. Supplement to the Journal of the Royal Statistical Society, 8(1), 27-41.

Ljung, G. M., & Box, G. E. P. (1978). On a measure of lack of fit in time series models. Biometrika, 65(2), 297-303.

https://de.wikipedia.org/wiki/Korrelogramm

http://sfb649.wiwi.hu-berlin.de/fedc_homepage/xplore/tutorials/xegbohtmlnode39.html

https://en.wikipedia.org/wiki/Ljung%E2%80%93Box_test

Examples

data <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
auto_corr(data, lag = 3)

jazznbass/wmisc documentation built on Oct. 29, 2024, 5:42 p.m.