Correlation

Example using your package

correlation-spearman_corr                                                                               -1.0
correlation-spearman_pval                                                                                0.0
correlation-pearson_corr                                                                                -1.0
correlation-pearson_pval                                                                                 0.0
correlation-crosscorr                                                                     [996577.769777203]
correlation-model            {'numpy.correlate': [996577.769777203], 'numpy.corrcoef': [[1.0, -1.0], [-1....
correlation-id                                                                                   Correlation
dtype: object


         Correlation
==============================
Pearson:                -1.000
Spearman:               -1.000
Cross correlation:  996577.770
==============================

Identifier:
Correlation

 9 # Libraries
10 import numpy as np
11 import pandas as pd
12
13 # Import statsmodels
14 from statsmodels.tsa.stattools import adfuller
15
16 # Import pyAMR
17 from pyamr.core.stats.correlation import CorrelationWrapper
18
19 # ----------------------------
20 # set basic configuration
21 # ----------------------------
22 # Set pandas configuration.
23 pd.set_option('display.max_colwidth', 80)
24 pd.set_option('display.width', 150)
25 pd.set_option('display.precision', 4)
26
27 # ----------------------------
28 # create data
29 # ----------------------------
30 # Constants
31 length = 100
32 offset = 100
33 slope = 10
34
35 # Create timeseries.
36 x = np.arange(length)
37 n = np.random.rand(length)
38 y1 = n * slope + offset
39 y2 = n * (-slope) + offset
40
41 # ----------------------------
42 # create correlation object
43 # ----------------------------
44 # Create object
45 correlation = CorrelationWrapper().fit(x1=y1, x2=y2)
46
47 # Print series.
48 print("\n")
49 print(correlation.as_series())
50
51 # Print summary.
52 print("\n")
53 print(correlation.as_summary())
54
55 # Print identifier.
56 print("\nIdentifier:")
57 print(correlation._identifier())

Total running time of the script: ( 0 minutes 0.006 seconds)

Gallery generated by Sphinx-Gallery