Learn R Programming

mcgf (version 1.1.1)

acf_rs: Calculate regime-switching auto-correlation

Description

Calculate regime-switching auto-correlation

Usage

acf_rs(x, label, lag_max, demean = TRUE)

Value

Mean auto-correlations for each group in label.

Arguments

x

A univariate numeric time series.

label

A factor of regime labels.

lag_max

Maximum lag at which to calculate the acf.

demean

Logical. Should the covariances be about the sample means?

Examples

Run this code
set.seed(123)
x <- rnorm(100)
label <- sample(1:2, 100, replace = TRUE)
acf_rs(x, label = factor(label), lag_max = 3)

Run the code above in your browser using DataLab