ccfs.mcgf {mcgf}R Documentation

Extract, calculate, or assign cross-correlations for an mcgf or mcgf_rs object

Description

Extract, calculate, or assign cross-correlations for an mcgf or mcgf_rs object

Usage

## S3 method for class 'mcgf'
ccfs(x, lag_max, ncores = 1, replace = FALSE, ...)

## S3 method for class 'mcgf_rs'
ccfs(x, lag_max, ncores = 1, replace = FALSE, ...)

ccfs(x) <- value

add_ccfs(x, lag_max, ncores = 1, ...)

Arguments

x

An mcgf or mcgf_rs object.

lag_max

Maximum lag at which to calculate the ccfs.

ncores

Number of cpu cores used for computing. The doParallel package is required when ncores > 1.

replace

Logical; if TRUE, acfs are recalculated.

...

Additional parameters or attributes. Not in use.

value

Cross-correlations.

Details

For mcgf objects, ccfs() computes cross-correlations for each time lag. The output is an array of matrices where each matrix corresponds to the cross-correlation for a time lag.

For mcgf_rs objects, ccfs() computes regime-switching cross-correlations for each time lag. The output is a list of array of matrices where each array in the list corresponds to the cross-correlation for a regime.

ccfs<- assigns ccfs to x.

add_ccfs() adds ccfs and sds to x.

Value

ccfs() returns (regime-switching) cross-correlations. add_ccfs() returns the same object with additional attributes of (regime-switching) cross-correlations and (regime-switching) empirical standard deviations.

Examples

# Calculate ccfs for 'sim1'
data(sim1)
sim1_mcgf <- mcgf(sim1$data, dists = sim1$dists)
ccfs(sim1_mcgf, lag_max = 5)

# To use multiple cores, use the `ncores` argument
ccfs(sim1_mcgf, lag_max = 5, ncores = 2)

# Add ccfs and sds to 'sim1_mcgf'
sim1_mcgf <- add_ccfs(sim1_mcgf, lag_max = 5)
print(sim1_mcgf, "ccfs")
print(sim1_mcgf, "sds")

# Calculate ccfs for 'sim2'
data(sim2)
sim2_mcgf <- mcgf_rs(sim2$data, dists = sim2$dists, label = sim2$label)
ccfs(sim2_mcgf, lag_max = 5)

# Add ccfs and sds to 'sim2_mcgf'
sim2_mcgf <- add_ccfs(sim2_mcgf, lag_max = 5)
print(sim2_mcgf, "ccfs")
print(sim2_mcgf, "sds")

[Package mcgf version 1.1.0 Index]