Description Usage Arguments Details Value Author(s) References Examples

View source: R/rolwincor_heatmap.R

The `rolwincor_heatmap`

function estimates the rolling window correlation coefficients and their respective p-values between TWO time series (bi-variate case) sampled on identical time points for all the possible (i.e. from 3 to the number of elements of the time series under analysis) window-lengths (time-scales) or for a band of window-lengths to be plotted as a heat map. To carry out the computational implementation we extend the works of Telford (2013), Polanco-Martínez (2019), and Polanco-Martínez (2020). The `rolwincor_heatmap`

function is highly flexible since this contains several parameters to control the estimation of correlation. A list of parameters are described in the following lines.

1 2 3 4 | ```
rolwincor_heatmap(inputdata, varX="", varY="", CorMethod="pearson",
typewidthwin="FULL", widthwin_1=3,
widthwin_N=dim(inputdata)[1], Align="center",
pvalcorectmethod="BH", rmltrd=TRUE, Scale=TRUE)
``` |

`inputdata` |
Matrix of 3 columns: time, first variable (e.g. |

`varX, varY` |
Names of the first (e.g. |

`CorMethod` |
The method used to estimate the correlations, by default is “pearson” but other options (“spearman” and “kendall”) are available (please look at: |

`typewidthwin` |
“FULL” is to estimate the windows from 2, 4, ..., to dim(inputdata)[1]) if |

`widthwin_1` |
First value for the size (length) of the windows when the option |

`widthwin_N` |
Last value for the size (length) of the windows when the option |

`Align` |
To align the rolling object, RolWinMulCor uses three options: “left”, “center”, and “right” (please look at: |

`pvalcorectmethod` |
The p-value correction method to be used, by default the method of Benjamini and Hochberg (BH) (1995) is used since this is less conservative and performs much better than Bonferroni, but other five methods (Holm, Hochberg, Bonferroni, Hommel, and Benjamini and Yekutieli) are available (please look at: |

`rmltrd` |
Remove (by default is “TRUE”; “FALSE” otherwise) the linear trend in the time series under analysis. |

`Scale` |
Scale (by default is “TRUE”; “FALSE” otherwise) is used to “normalize” or “standardize” the time series under analysis. |

The `rolwincor_heatmap`

function estimates the rolling window correlation between TWO time series (bi-variate case) sampled on identical time points for all the possible (i.e. from 3 to the number of elements of the time series under analysis) window-lengths (time-scales) or for a band of window-lengths to be plotted the rolling correlation coefficients and their respective p-values as a heat map. `rolwincor_heatmap`

uses the functions *running* (package:gtools), the native **R** functions *cor*, *cor.test*, and *p.adjust* (package:stats), and some pieces of code written specifically to our **R** RolWinMulCor package.

Outputs:

Numerical output: three lists *matcor*, *pvalscor*, and *pvalNOTcor* containing the correlation matrix and their corresponding corrected and not corrected p-values, as well as *NoWindows* and *Windows* that contains the number of windows and the window-lengths (time-scales), and *CorMethod*, *left_win*, and *righ_win*, which have been previously described.

Josué M. Polanco-Martínez (a.k.a. jomopo).

DeustoTech - Deusto Institute of Technology,

Faculty of Engineering, University of Deusto,

Avda. Universidades, 24, Bilbao, SPAIN.

Web1: https://scholar.google.es/citations?user=8djLIhcAAAAJ&hl=en.

Web2: https://www.researchgate.net/profile/Josue_Polanco-Martinez.

Email: josue.m.polanco@gmail.com, josue.polanco@deusto.es

Benjamini, Y., and Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society Series B, 57 (1), 289-300. <URL: https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1995.tb02031.x>.

Polanco-Martínez, J. M. (2019). Dynamic relationship analysis between NAFTA stock markets using nonlinear, nonparametric, non-stationary methods. Nonlinear Dynamics, 97(1), 369-389. <URL: https://doi.org/10.1007/s11071-019-04974-y>.

Polanco-Martínez, J. M. (2020). RolWinMulCor : an R package for estimating rolling window multiple correlation in ecological time series. Ecological Informatics (Ms. ECOINF-D-20-00263 accepted for publication, 19/08/2020).

Telford, R.: Running correlations – running into problems (2013). <URL:

https://quantpalaeo.wordpress.com/2013/01/04/running-correlations-running-into-problems/>.

1 2 3 4 5 6 7 8 9 10 11 | ```
# Testing the function rolwincor_heatmap
# typewidthwin="PARTIAL," window lengths from 21 to 31 and plot output in screen format
test_rolwincor_heatmap <- rolwincor_heatmap(syntDATA, varX="X", varY="Y",
CorMethod="spearman", typewidthwin="PARTIAL", widthwin_1=11,
widthwin_N=101, Align="center", pvalcorectmethod="BH",
rmltrd=TRUE, Scale=TRUE)
# This example could takes a long time since typewidthwin="FULL"
test2_rolwincor_heatmap <- rolwincor_heatmap(syntDATA, varX="X", varY="Y",
CorMethod="spearman", typewidthwin="FULL", Align="center",
pvalcorectmethod="BH", rmltrd=TRUE, Scale=TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.