Description Usage Arguments Value Note Author(s) Examples
Use the phase_scramble function to generate many (Nboot) surrogate-data based correlations, compare to the observed correlation, calculate the fraction of trials exceeding the observed value and return the significance level as a fraction.
1 | getSL(Nboot,method,series1,series2)
|
Nboot |
Number of Monte-Carlo phase-scrambling trials to perform |
method |
pearson, kendall or spearman |
series1,series2 |
the two series of numbers to correlate |
SL |
Significance levels, or fraction of surrogat edata trials exceeding the observed correlation. Two sided! |
Version 0.1, Dec 2019
Peter Thejll, DMI. (pth@dmi.dk)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(PTHfftSURROGATES)
require(gtools)
set.seed(6) # for reproducibility
#Example 1 - two probably uncorrelated series
series1 <- rnorm(1000)
series2 <- rnorm(1000)
method_str="pearson" # pearson, kendall or spearman
Robs <- cor(series1,series2,method=method_str)
print(c("The observed correlation is ",Robs))
Nboot <- 1000
SL <- getSL(Nboot,method=method_str,series1,series2)
print(c("The p-value of the observed correlation is:",SL))
#Example 2 - two probably correlated series
series2 <- 2*rnorm(1000) + 1*series1
Robs <- cor(series1,series2,method=method_str)
print(c("The observed correlation is ",Robs))
SL <- getSL(Nboot,method=method_str,series1,series2)
print(c("The p-value of the observed correlation is",SL))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.