CrossCorr: Cross-Correlation of Time-Dependent Observations

View source: R/CrossCorr.R

CrossCorrR Documentation

Cross-Correlation of Time-Dependent Observations

Description

CrossCorr is the function for the cross-correlation or cross-covariance of two univariate series of observations using numerical vectors. The function is a Wrapper for the ccf function with additional features.

Beware, CrossCorr assumes implicitly that both time series have the same frequency and thus accepts simple numerical vectors.

Usage

CrossCorr(FirstTimeSeries, SecondTimeSeries, 

nLags = 2,type = "correlation",PlotIt=FALSE,main,...)

Arguments

FirstTimeSeries

[1:n] vector or time series, see also input of ccf

SecondTimeSeries

[1:n] vector or time series, see also input of ccf

nLags

Positive scalar, the limit number of lags (in units of observations) to be inspected forward and backward in FirstTimeSeries relative to the fixed SecondTimeSeries, see also input of ccf. Default is 2

type

Character string giving the type of acf to be computed. Allowed values are "correlation" (the default), "covariance"

PlotIt

Optional, if TRUE, output is plotted as a dashboard with values as bars against various lags, for the lag with highest cross correlation or covariance additionally the spearman rank correlation with a scatter plot is shown. Default is FALSE

main

Optional, title of plot.

...

Further arguments passed on to output of ccf

Details

Procedure ist as follows: the timeseries is moved forward from FirstTimeSeries[t+1] to FirstTimeSeries[t+nLags] and backward from FirstTimeSeries[t-1] to FirstTimeSeries[t-nLags] and every lagged time series FirstTimeSeries is compared to SecondTimeSeries.

A cross correlation at lag nlag means that the value nlag-time steps ahead of the FirstTimeSeries correlates with the value of the current time step of the SecondTimeSeries.

Covariance is a measure indicating the extent to which two random variables change in tandem. Correlation is a scalar measure that indicates how strongly two variables are statistically linearly related which does not mean that they are related by causality. For nLags: back shifting: positiv values, forward shifting: negative values.

Value

output of ccf in invisible mode

Note

Covoriance is not normalized, Instead the normalization is in the multiplication of units of both time series.

Author(s)

Michael Thrun


Mthrun/TSAT documentation built on Feb. 5, 2024, 11:15 p.m.