getSL: Estimate correlation significance levels using...

Description Usage Arguments Value Note Author(s) Examples

View source: R/getSL.R

Description

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.

Usage

1
getSL(Nboot,method,series1,series2)

Arguments

Nboot

Number of Monte-Carlo phase-scrambling trials to perform

method

pearson, kendall or spearman

series1,series2

the two series of numbers to correlate

Value

SL

Significance levels, or fraction of surrogat edata trials exceeding the observed correlation. Two sided!

Note

Version 0.1, Dec 2019

Author(s)

Peter Thejll, DMI. (pth@dmi.dk)

Examples

 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))

hotblack43/PTHfftSURROGATES documentation built on Dec. 25, 2019, 6:15 p.m.