-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsenderAnalysis_stats.m
115 lines (89 loc) · 3.98 KB
/
senderAnalysis_stats.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function senderAnalysis_stats(participants)
% Fits multiple glm to senders, assessing whether senders can predict
% binaryPriority, binaryWorkload and binaryPleasure and spam.
% Also runs them on shuffled (randomised) instances, just to verify that
% the predictions were valid.
%% make table with top senders
% consider only rows: from, priority, pleasure, workload, spam
% eagerlyExpected
columns = {'from' 'priority' 'pleasure' 'workload' 'spam' 'eagerlyExpected'};
cattable = table();
hold on;
for participantNumber = participants
sfo = ['P' Params.sfo_p];
partString = sprintf(sfo, participantNumber);
outdir = Params.outdir;
partFolder = [outdir filesep partString];
tableMatFile = [partFolder filesep 'datatable.mat'];
disp(['Attempting to read table from ' tableMatFile]);
tables = load(tableMatFile);
tab = tables.tab;
% make sub table with only the desired colums
subtab = tab(:, columns);
%priority = subtab.priority + rand(size(subtab.priority, 1), 1) / 2;
%pleasure = subtab.pleasure + rand(size(subtab.pleasure, 1), 1) / 2;
%workload = subtab.workload + rand(size(subtab.workload, 1), 1) / 2;
%scatter3(priority, pleasure, workload)
subtab.participantNumber = repmat(participantNumber, size(subtab, 1), 1);
cattable = vertcat(cattable, subtab);
end
% tabulate unique senders to compute overall stats
tbl = tabulate(cattable.from);
uniqueFreqs = cell2mat(tbl(:,2));
disp(['Median number of unique senders across all: ' num2str(median(uniqueFreqs)) ]);
disp(['Mean number of unique senders across all: ' num2str(mean(uniqueFreqs)) ]);
disp(['Std of unique senders across all: ' num2str(std(uniqueFreqs)) ]);
% convert sender into numbers
[senderStrings, ~, uniqueIndex] = unique(cattable.from);
cattable.senderNum = categorical(uniqueIndex);
cattable.binaryPriority = ordinal(cattable.priority > 2.5);
cattable.binaryPleasure = ordinal(cattable.pleasure > 2.5);
cattable.binaryWorkload = ordinal(cattable.workload > 2.5);
disp(['For f-test, numerator is ' num2str(size(senderStrings, 1)) ' and denominator is the degrees of freedom outputted by fitglm']);
disp('Note numberator number and press enter to continue');
pause;
m = fitglm(cattable, 'binaryPriority ~ senderNum');
disp(m);
disp('Above: binaryPriority');
pause;
m = fitglm(cattable, 'binaryPleasure ~ senderNum');
disp(m);
disp('Above: binaryPleasure');
pause;
m = fitglm(cattable, 'binaryWorkload ~ senderNum');
disp(m);
disp('Above: binaryWorkload');
pause;
m = fitglm(cattable, 'spam ~ senderNum');
disp(m);
disp('Above: spam');
pause;
shuffledPriority = cattable.binaryPriority;
shuffledPriority = shuffledPriority(randperm(size(shuffledPriority, 1)));
cattable.shuffledPriority = shuffledPriority;
m = fitglm(cattable, 'shuffledPriority ~ senderNum');
disp(m);
disp('Above: shuffledPriority');
pause;
shuffledPleasure = cattable.binaryPleasure;
shuffledPleasure = shuffledPleasure(randperm(size(shuffledPleasure, 1)));
cattable.shuffledPleasure = shuffledPleasure;
m = fitglm(cattable, 'shuffledPleasure ~ senderNum');
disp(m);
disp('Above: shuffledPleasure');
pause;
shuffledWorkload = cattable.binaryWorkload;
shuffledWorkload = shuffledWorkload(randperm(size(shuffledWorkload, 1)));
cattable.shuffledWorkload = shuffledWorkload;
m = fitglm(cattable, 'shuffledWorkload ~ senderNum');
disp(m);
disp('Above: shuffledPriority');
pause;
shuffledSpam = cattable.spam;
shuffledSpam = shuffledSpam(randperm(size(shuffledSpam, 1)));
cattable.shuffledSpam = shuffledSpam;
m = fitglm(cattable, 'shuffledSpam ~ senderNum');
disp(m);
disp('Above: shuffledSpam');
pause;
end