Considering r the person correlation coefficient, this function returns either 1 - abs(r) if cor_type=="abs", 1 - pmax(0, r) if cor_type == "+", or 1 - pmax(0, r * -1) if cor_type == "-". Another possibility is to run a significance test to verify if the r is significant.
tsdist_cor(ts1, ts2, cor_type = "abs", sig_test = FALSE, sig_level = 0.01, ...)Array. Time series 1
Array. Time series 2
String. "abs" (default), "+", or "-". "abs" considers the correlation absolute value. "+" only positive correlations and "-" only negative correlations.
Run a statistical test. Return 0 if significant or 1 otherwise.
The significance level to test if correlation is significant.
Additional parameters to cor.test() function.
Real value [0,1] where 0 means perfect positive (or negative if positive_cor==FALSE) correlation and 1 no positive (or negative if positive_cor==FALSE) correlation.