forked from Shlomit-Beker/Test-retest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pearsonTestRetest.m
31 lines (25 loc) · 1.03 KB
/
pearsonTestRetest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% Pearson correlations on all test-retest pairs
ParametersAllTable = readtable('dataMat_forCorrMatrix.csv');
ParametersMatrix = table2array(ParametersAllTable);
flag = 0;
figure;
p=size(ParametersMatrix);
for i = 1:2:size(ParametersMatrix,2)-1
flag = flag+1;
[RHO1(flag),PVAL1(flag)] = corr(ParametersMatrix(:,i),ParametersMatrix(:,i+1),'rows','pairwise');
coefficients = polyfit(ParametersMatrix(isnan(ParametersMatrix(:,i))==0,i),ParametersMatrix(isnan(ParametersMatrix(:,i+1))==0,i+1), 1);
M = max([ParametersMatrix(:,i);ParametersMatrix(:,i+1)]);
N = min([ParametersMatrix(:,i);ParametersMatrix(:,i+1)]);
fittedY = polyval(coefficients,[N:M*1.5]); %the 1.5 is to make the linear line longer
subplot(7,8,i)
scatter(ParametersMatrix(:,i),ParametersMatrix(:,i+1),4)
hold on;
plot([N:M*1.5], fittedY, 'k');
pause
end
% correct for multiple comparisons with bonferroni:
alpha = 0.05;
numSig = find(PVAL1<0.05);
newPVal = alpha/length(numSig);
newSigInd = find(PVAL1<newPVal);
newSigVal = PVAL1(newSigInd)