crosscor: Time Difference Relevance (Cross Correlation Coefficient)

Description Usage Arguments Details Value Examples

View source: R/crosscor.R

Description

calculate correlation coefficient when crossing date of two time series, and then separate leading, consistent, lagging indicators from economic indicators.

Usage

1
2
crosscor(base, divergent, lag = 12, group_lag = 3, method = c("pearson",
  "kendall", "spearman"))

Arguments

base

a numeric vector, containing a basic indicator for comparing to other indicators in order to recognize who is leading indicator ...

divergent

a data frame containing indicators to be compared with base , and then to divide to 3 data frame, storing lagging, convenient, lagging indicators respectively.

lag

max lag (forward or afterward) for calculating KL information, at range of [-lag, lag].

group_lag

threshold value of lag for divide different indicator, default is 3, means that lagging or leading lag at range of [-3, 3] will group the indicator to consistent indicator.

method

method to calculate correlation coefficient, refer to cor.

Details

this function and it's role is equal to KL, just base on different method for dividing groups. Compare to KL, crosscor don't request the time series must include only positive values.

Value

A list includes some value as follow :

Coincident_Indicator

data frame, including coincident indicator

Leading_Indicator

data frame, including leading indicator

Lagging_Indicator

data frame, lagging indicator

Cor_Matrix

matrix including correlation coefficient and lag information

Cor_Max

data frame, including vector of Cor_lag : lag corresponding max correlation coefficient and vector of Cor_max : max correlation coefficient

Examples

1
2
3
4
5
x1 <- c( 5, 9, 5, 12, 13, 8, 14, 14, 8, 10)
x2 <- c( 9, 15, 5, 14, 8, 6, 12, 19,8, 7)
base<-c( 26, 13, 25, 27 ,25 ,13 ,32 ,20 ,23 ,29)
dt<-data.frame(x1, x2, base)
crosscor(base,dt,lag = 3,group_lag = 1)

Nisus-Liu/CompositeIndex documentation built on May 7, 2019, 6:18 p.m.