My aim is to calculate the t-statistics and p-value for the following comparison:
- Four lists of data (Core_R, Core_T, Periphery_R, Periphery_T)
- The correlation between two lists is computed, respectivley: correlation Core_R and Core_T; correlation Periphery_R and Periphery_T
- The result are two correlation values
The question I would like to answer is if if the correlation values (between Core and Periphery) significantly differ by showing the corresponding t-statistic and p-value for this comparison.
Here is my code:
import numpy as np
import scipy as sp
from scipy import stats
Core_R = [0.472202, 0.685151, 0.287613, 0.518002, 0.675128, 0.462418, 0.618170, 0.692822]
Core_T = [0.816606, 1.168650, 0.492040, 0.782458, 0.648625, 0.885237, 0.798031, 0.950363]
Periphery_R = [0.685151, 0.287613, 0.546364, 0.518002, 0.518002, 0.675128, 0.462418, 0.618170]
Periphery_T = [1.168650, 0.492040, 0.782458, 0.648625, 0.885237, 0.798031, 0.950363, 0.963140]
# Correlation and paired t-Tests
Pearson_core = sp.stats.pearsonr(Core_R, Core_T)
Pearson_periphery = sp.stats.pearsonr(Periphery_R, Periphery_T)
t_Test = sp.stats.ttest_rel([Core_R, Core_T], [Periphery_R, Periphery_T], axis=None, alternative="two-sided")
print(f"Pearson's r Core: {Pearson_core}")
print(f"Pearson's r Periphery: {Pearson_periphery}")
print(f"t Test: {t_Test}")
This code works. It first computes the correlation between Core_R and Core_T, and then between Periphery_R and Periphery_T.
However, from my understanding, the line
t_Test = sp.stats.ttest_rel([Core_R, Core_T], [Periphery_R, Periphery_T], axis=None, alternative="two-sided")
does not compute the t-statistic and p-value between both correlations. Instead, the computation only compares the values that are provided by the four lists. The t-test here has consequently nothing to do with the previously obtained correlations.
Changing the code for the t Test to:
t_Test = sp.stats.ttest_rel(Pearson_core, Pearson_periphery, axis=None, alternative="two-sided")
print(t_Test)
will only take the two results from both pearson correlations into consideration, am I correct? Hence the resulting t-statistic and p-value does not represent a t Test that takes all values (from all four lists) into consideration.
My question is how I can solve this problem so that the t-Test compares the results from both correlations, but by including all original data points into the computation?
I am afraid that this line of code for the t-Test
t_Test = sp.stats.ttest_rel(Pearson_core, Pearson_periphery, axis=None, alternative="two-sided")
print(t_Test)
does not really compare the combination of Core_R with Core_T against Periphery_R with Periphery_T, but that it only computes the t-stats and p-value between two single values, namely the results of
Pearson_core = sp.stats.pearsonr(Core_R, Core_T)
Pearson_periphery = sp.stats.pearsonr(Periphery_R, Periphery_T)