ccf_ts {BINCOR}R Documentation

Cross-correlation

Description

The ccf_ts function estimates and plots the cross-correlation between the binned time series. ccf_ts has an option to remove the linear trend of the time series under analysis (other pre-processing methods could be used) and contains several parameters that are described in the following lines.

Usage

ccf_ts(bints1, bints2, lagmax=NULL, ylima=-1, ylimb=1, rmltrd="N", RedL=T, 
 device="screen", Hfig, Wfig, Hpdf, Wpdf, resfig, ofilename)

Arguments

bints1, bints2

The bints1 and bints2 are the binned time series.

lagmax

This parameter indicates the maximum lag for which the cross-correlation is calculated (its value depends on the length of the data set).

ylima, ylimb

This parameters define the extremes of the range in which the CCF will be plotted.

rmltrd

This is the option used to remove the linear trend in the time series under study (by default the linear trend is not removed, but it can be activated with the option “Y” or “y”).

RedL

RedL plots a right red line to highlight the correlation coefficient at the lag-0 (the default option is TRUE).

device

The type of the output device (by default the option is “screen”, and the other options are “jpg”, “png” and “pdf”) for the scatter plot of the binned time series.

Hfig

The height for the CCF plot in “jpg” or “png” format.

Wfig

The width for the CCF plot in “jpg” or “png”format.

Hpdf

The height for the CCF plot in “pdf” format.

Wpdf

The width for the CCF plot in “pdf” format.

resfig

resfig is the plot resolution in “ppi” (by default R does not record a resolution in the image file, except for BMP) for the CCF plot (“jpg” or “png” formats), an adequate value could be 150 ppi.

ofilename

The output filename (CCF plot) for the CCF estimated of the binned time series.

Details

The ccf_ts estimate the cross-correlation between two binned time series by means of the R native function ccf (package:stats).

Value

Output: an object of the form ccf containing the correlation coefficients for the defined number of lags (lagmax) and the statistical significance.

Author(s)

Josué M. Polanco-Martínez (a.k.a. jomopo).
BC3 - Basque Centre for Climate Change, Bilbao, SPAIN.
EPOC UMR CNRS 5805 - U. de Bordeaux, Pessac, FRANCE.
Web1: https://scholar.google.es/citations?user=8djLIhcAAAAJ&hl=en.
Web2: http://www.researchgate.net/profile/Josue_Polanco-Martinez.
Email: josue.m.polanco@gmail.com

References

Polanco-Martínez, J.M., Medina-Elizalde, M.A., Sánchez Goñi, M.F., M. Mudelsee. (2018). BINCOR: an R package to estimate the correlation between two unevenly spaced time series. Ms. under review (second round).

Examples

 #####################################################################
 #::  Figure 5 (Polanco-Martínez et al. (2018), (mimeo)). 
 #####################################################################
 library("BINCOR") 
 library("pracma")

 #####################################################################
 #:: Loading the time series under analysis: example 2 (pollen ACER)  
 #####################################################################
 data(MD04_2845_siteID31)
 data(MD95_2039_siteID32)

 #####################################################################
 # Computing the binned time series though our bin_cor function
 #####################################################################
 bincor.tmp <- bin_cor(ID31.dat, ID32.dat, FLAGTAU=3, "salida_ACER_ABRUPT.tmp")
 binnedts   <- bincor.tmp$Binned_time_series

 # To avoid NA's values  
 bin_ts1    <- na.omit(bincor.tmp$Binned_time_series[,1:2])
 bin_ts2    <- na.omit(bincor.tmp$Binned_time_series[,c(1,3)]) 

 #####################################################################
 # Testing our ccf_ts function
 #####################################################################
 # Screen 
 ccf_ts(bin_ts1, bin_ts2, RedL=TRUE, rmltrd="y") 

 # PDF format  
 ccf_ts(bin_ts1, bin_ts2, RedL=TRUE, rmltrd="y", device="pdf", Hpdf=6, 
  Wpdf=9, resfig=300, ofilename="ccf_ID31_ID32_res")
 
 # JPG format 
 ccf_ts(bin_ts1, bin_ts2, RedL=TRUE, rmltrd="y", device="jpg", 
  Hfig=900, Wfig=1200, resfig=150, ofilename="ccf_ID31_ID32_res")

[Package BINCOR version 0.2.0 Index]